Skip to main content

jj-pre-push

PyPI

A very limited integration between jj and pre-commit allowing you to run your pre-push hooks in a colocated jj/git repository.

I don't expect this to last forever, it's just a stopgap until some jj-native mechanism arrives that can take over.

Prior art:

Usage

Use jj-pre-push push (or an alias - personally I use jj push) as a replacement for jj git push. It takes all the same arguments, and does the following:

  1. Determines which bookmarks the corresponding jj git push will update on the remote, and how they would change.

  2. For each of these bookmarks in turn:

    • Checks out the bookmark to the working copy (or uses the existing working commit if it is empty and based on the bookmark).
    • Runs the pre-push hooks defined in your .pre-commit-config.yaml on the same set of files pre-commit would when pushing the same change. (For existing branches that's the files touched in the range old...new; for new branches it's the files touched in all ancestors of new that aren't present on the remote.)
    • Reports any failures; and if any files were modified reports the change ID(s) in which these modifications can be found.

    Note: If your current working commit is empty and is a direct child of the bookmark being checked, jj-pre-push will run the checks directly in that working commit instead of creating a new one. Any modifications made by the hooks will be preserved in your working commit, ready to be diffed or squashed.

  3. If all hooks succeeded on all branches, executes jj git push with the arguments provided; otherwise nothing is pushed.

  4. Returns the working copy to its original change.

If there is no .pre-commit-config.yaml in your workspace root, jj-pre-push push immediately delegates to jj git push.

By default jj-pre-push produces no console output of its own unless hooks fail. If you'd like to see more details about what's happening, you can use jj-pre-push --log-level=INFO push.

Installation

If you have uv installed and you're planning to use an alias anyway, you can avoid explicitly installing at all with uvx, e.g. with this jj configuration for jj push:

[aliases]
push = ["util", "exec", "--", "uvx", "jj-pre-push", "push"]

Otherwise, install the PyPI package jj-pre-push in whichever way you prefer; e.g. uv tool install jj-pre-push or pip install jj-pre-push, and use jj-pre-push push as described earlier.

Usage with jjui

If you're a jjui fan (I think maybe you should be!), here's an example jjui/config.toml snippet showing how you can define custom actions to invoke jj-pre-push: one to perform the default jj push, and one to push the bookmarks attached to the change you have currently selected in the UI. I've also added some examples of key sequence bindings to perform these actions.

[[actions]]
name = "jj-push"
lua = '''
  jj_async("push")
  revisions.refresh()
'''

[[actions]]
name = "jj-push-selected"
lua = '''
  jj_async("push", "-r", context.commit_id())
  revisions.refresh()
'''

[[bindings]]
action = "jj-push"
seq = ["x", "p"]
scope = "revisions"
desc = "jj push"

[[bindings]]
action = "jj-push-selected"
seq = ["x", "P"]
scope = "revisions"
desc = "jj push selected bookmark(s)"

Note that these depend upon the jj push alias defined in the previous section.

Usage with other checkers/hook managers

jj-pre-push has rudimentary support for checkers other than pre-commit - to use a different checker, specify its name on the command line with jj-pre-push --checker CHECKER ... or set the environment variable JJ_PRE_PUSH_CHECKER. Supported checkers:

Metadata

Release files for jj-pre-push 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jj-pre-push 0.5.2
File Size Uploaded
jj_pre_push-0.5.2.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jj-pre-push 0.5.2
File Interpreter ABI Platform
jj_pre_push-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 24.9 kB

Release files / jj_pre_push-0.5.2.tar.gz

Download URL jj_pre_push-0.5.2.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
381b56135b6af75ec6f29c7b6875cddc64edb97c04e280ae6cae6682677e9035
BLAKE2b-256 checksum
How to use checksums
3bb2edd63ea707618ff4434de9ab232a187d714c4aba9a8e3df15b28469b0a71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / jj_pre_push-0.5.2-py3-none-any.whl

Download URL jj_pre_push-0.5.2-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c9931cda0d7fdec2438b8ee616b5d473dbbcb237b0a590b49727ec9cbb2ee13
BLAKE2b-256 checksum
How to use checksums
d1491e62f1f9ec0f4796b8344d64b51aab8dd1b1ac5616de6573da06c1f685cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.5.2 This release

2 release files

0.5.1

1 release file

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page