-
-
Save riwsky/38b17ea3fca70acf20a18c752663aff4 to your computer and use it in GitHub Desktop.
graphite submit script for jujutsu repositories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Exit immediately if a command exits with a non-zero status | |
set -e | |
jj fix | |
# Get the list of mutable branches that are reachable from the current branch | |
# (i.e. that are between us and main). | |
branches=$(jj branch list -r 'reachable(@,mutable())' --template 'name ++ "\n"') | |
# Loop through each branch and track it in Graphite | |
for branch in $branches; do | |
# Track the branch using the most recent ancestor branch as the parent | |
gt track --force "$branch" | |
done | |
# Check if the working directory is dirty | |
if [ "$(jj diff --summary | wc -l)" -gt 1 ]; then | |
jj new | |
fi | |
latest_branch=$(echo "$branches" | tail -n 1) | |
HUSKY=0 gt checkout $latest_branch | |
# Get the repo root and run pre-commit hooks if they exist | |
repo_root=$(git rev-parse --show-toplevel) | |
if [ -f "$repo_root/.husky/pre-commit" ]; then | |
pushd "$repo_root" > /dev/null | |
sh .husky/pre-commit | |
popd > /dev/null | |
fi | |
gt submit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment