An open API service indexing awesome lists of open source software.

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

Generate bookmark names from commit messages, to push as branches, with Jujutsu VCS
https://github.com/chriskrycho/jj-gpc

jj jujutsu vcs

Last synced: 9 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# jj-gpc

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

[jj]: https://github.com/martinvonz/jj

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 `,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-`, 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:

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

With Git:

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

- Install it with Cargo:

```sh
cargo install --path . --locked
```

- Install and run [ollama][o].

- Fetch [the `phi3` model][model]:

```sh
ollama pull phi3
```

[o]: https://ollama.com
[model]: https://ollama.com/library/phi3

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 `@`.

A few of the most useful flags:

- `-f`/`--from`: the initial revision to use in the revset for generating the name. Note that the revset is of the form `..`, so the `` 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`.
- `--log-format`: pass `one-line` (the default) to pass just summary messages, or `full` to pass the whole commit message, to the LLM for branch name description.
- `--dry-run`: generate a branch name but neither create the bookmark nor push it.

For the full set of flags and more details, run `jj-gpc --help`!

## 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`