Skip to content

Instantly share code, notes, and snippets.

@nemith
Created July 31, 2026 00:40
Show Gist options
  • Select an option

  • Save nemith/a3e32ec89bb5cb1041bb1bead073aa30 to your computer and use it in GitHub Desktop.

Select an option

Save nemith/a3e32ec89bb5cb1041bb1bead073aa30 to your computer and use it in GitHub Desktop.
❯ jj config get aliases.submit
["util", "exec", "--", "bash", "-c", '''
set -euo pipefail
# Stack = non-empty, described commits between trunk and the target (defaults to @).
target="${1:-@}"
revset="trunk()..$target & ~empty() & ~description(exact:\"\")"
# Auto-create push bookmarks (git_push_bookmark template) and push the whole stack.
jj git push -c "$revset"
# Collect bookmark names oldest-first, the order gh stack link expects (base -> top).
bookmarks=$(jj log -r "$revset" --reversed --no-graph \
-T 'local_bookmarks.map(|b| b.name()).join("\n") ++ "\n"' | grep -v '^$')
if [ -z "$bookmarks" ]; then
echo "no bookmarks to submit in: $revset" >&2
exit 1
fi
# Create (draft) PRs and chain their bases; existing PRs are reused.
gh stack link $bookmarks
# Sync each PR's title/body from its commit description (covers create + update).
for b in $bookmarks; do
desc=$(jj log -r "$b" --no-graph -T description)
title=$(printf '%s\n' "$desc" | head -n1)
body=$(printf '%s\n' "$desc" | tail -n +2 | sed '/./,$!d')
if [ -n "$body" ]; then
gh pr edit "$b" --title "$title" --body "$body"
else
gh pr edit "$b" --title "$title"
fi
done
''', "submit"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment