/jj-gpc

Generate bookmark names from commit messages, to push as branches, with Jujutsu VCS

Primary LanguageRustOtherNOASSERTION

jj-gpc

✨ 100% local LLM-based bookmark (Git branch) name creation for Jujutsu VCS

Jujutsu is a modern, Git-compatible VCS. It supports (and I primarily use) anonymous branches for development. Since Git, and thus all Git-based “forges” (GitHub, GitLab, Bitbucket, etc.) require branch names, though, you need to give a branch name when you push your changes for others to work with.

Jujutsu has native support making this easy. If you run jj git push --change <change ID>,it creates a Jujutsu bookmark (which it maps to Git branches) and then pushes that newly created bookmark. The bookmark names it creates are of the form push-<change id>, though. Those are not especially attractive to most collaborators!

This tiny tool is one “solution”: it generates a bookmark name based on the messages associated with the changes you tell it to use—by default, trunk()..@, or “everything between my current working copy and whatever the ‘trunk’ is for this project (usually main or master”).

gpc is short for git push change.

Installation

Prerequisites: a relatively recent version of Rust. (I built it with Rust 1.82, but it probably works with versions quite a bit earlier than that!)

  • Clone the repo.

    With Jujutsu:

    jj git clone https://github.com/chriskrycho/jj-gpc

    With Git:

    git clone https://github.com/chriskrycho/jj-gpc.git
  • Install it with Cargo:

    cargo install --path . --locked
  • Install and run ollama.

  • Fetch the llama3.2 model:

    ollama fetch llama3.2

That’s it; now you can run jj-gpc to do this.

Usage

jj-gpc [change] [flags]

change is the revset to use to generate the bookmark name. If not passed, it will use @.

Flags:

  • -f/--from: the initial revision to use in the revset for generating the name. Note that the revset is of the form <from>..<change>, so the <from> message will not be included, because the default is trunk(), and the point is to generate a description of what is different from the trunk.
  • -p/--prefix: apply a prefix before the generated bookmark name. For example, jj-gpc -p chriskrycho would produce a name like chriskrycho/did-some-stuff, instead of just did-some-stuff.
  • --dry-run: generate a branch name but neither create the bookmark nor push it.

Example output

A handful of branch names I have actually seen generated by this:

  • update-infra-issues
  • update-mdbook-dependencies
  • software-updates-implemented
  • cleaning-and-fixes
  • small-bug-fixes
  • small-code-updates
  • add-some-examples
  • small-digital-notebook
  • fix-library-errors
  • bump-typescript-version
  • support-ts-versions