Compare commits

8 Commits

Author SHA1 Message Date
phundrak 0ec750eb66 feat(cli): add jj-lib version to version output
Publish Docker Images / coverage-and-sonar (push) Failing after 6m2s
2026-04-21 21:02:14 +02:00
phundrak c65e493571 feat: set message for multiple revsets
Allows to set the revision message of multiple revisions by passing
them as arguments. This only supports simple revisions, such as `@`,
`@-`, `xs`, and so on. Comple revisions such as `@..@-` are not
supported.

Fixes: #5
2026-04-21 20:50:52 +02:00
phundrak 3da214ae4c refactor(prompter): simplify commit type selection
Publish Docker Images / coverage-and-sonar (push) Failing after 14m51s
2026-04-05 16:41:11 +02:00
phundrak 64652fc81d fix(scope): no new string allocation to count characters 2026-04-05 16:41:11 +02:00
phundrak 0ef1f61613 feat(errors): preserve jj-emitted errors when loading config 2026-04-05 16:41:11 +02:00
phundrak 52f0667777 refactor(BreakingChange): rename method ignore to is_absent
Method `ignore` did not carry its meaning well by the way it is named.
This commit renames it to `is_absent` to clearly state this method
returns whether we have a breaking change.
2026-04-05 16:41:11 +02:00
phundrak 61288e8f49 refactor(workflow): remove unnecessary async declarations 2026-04-05 16:41:11 +02:00
phundrak 1c983f3a8d refactor(nix): simplify package declaration 2026-04-05 15:56:24 +02:00
19 changed files with 905 additions and 732 deletions
+3 -1
View File
@@ -4,6 +4,8 @@ if ! has nix_direnv_version || ! nix_direnv_version 3.1.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.0/direnvrc" "sha256-yMJ2OVMzrFaDPn7q8nCBZFRYpL/f0RcHzhmw/i6btJM="
fi
export DEVENV_IN_DIRENV_SHELL=true
# Load .env file if present
dotenv_if_exists
@@ -18,5 +20,5 @@ if [[ -f .envrc.local ]]; then
fi
if ! use flake . --no-pure-eval; then
echo "Development shell could not be built. The environment was not loaded. Make the necessary changes to flake.nix and hit enter to try again." >&2
echo "Devenv could not be built. The devenv environment was not loaded. Make the necessary changes to flake.nix and hit enter to try again." >&2
fi
+27 -31
View File
@@ -1,4 +1,4 @@
name: Run checks and build archives
name: Publish Docker Images
on:
push:
@@ -6,7 +6,7 @@ on:
- main
- develop
tags:
- "v*.*.*"
- 'v*.*.*'
pull_request:
types: [opened, synchronize, reopened]
@@ -56,36 +56,32 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
build:
needs: coverage-and-sonar
strategy:
matrix:
target: ["linux-x86_64", "linux-aarch64", "windows-x86_64"]
- name: Build Linux release binary
run: nix build --no-pure-eval --accept-flake-config
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare Linux binary
run: |
mkdir dist-linux
cp result/bin/jj-cz dist-linux/
cp LICENSE.*.md dist-linux/
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Set up cachix
uses: cachix/cachix-action@v17
with:
name: phundrak
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Build jj-cz archive
run: nix build .#${{matrix.target}}-archive
- name: Upload artifact
- name: Upload Linux artifact
uses: actions/upload-artifact@v3
with:
name: jj-cz-${{matrix.target}}
path: result/dist/*
name: jj-cz-x86_64-unknown-linux-gnu
path: dist-linux/*
- name: Build Windows release binary
run: nix build .#windows --no-pure-eval --accept-flake-config
- name: Prepare Windows binary
run: |
mkdir -p dist-windows
cp result/bin/jj-cz.exe dist-windows/
cp LICENSE.*.md dist-windows/
- name: Upload Windows artifact
uses: actions/upload-artifact@v3
with:
name: jj-cz-x86_64-pc-windows-gnu
path: dist-windows/*
+41 -69
View File
@@ -2,16 +2,33 @@ name: Release
on:
push:
branches:
- main
branches:
- main
jobs:
release:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Set up cachix
uses: cachix/cachix-action@v17
with:
name: phundrak
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Run Checks
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
run: just check-all
release:
needs: checks
runs-on: ubuntu-latest
outputs:
release: ${{ steps.releasable.outputs.release }}
release_id: ${{ steps.create_release.outputs.release_id }}
version: ${{ steps.next_version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
@@ -32,103 +49,58 @@ jobs:
- name: Check for releasable commits
id: releasable
run: |
COUNT=$(nix develop --no-pure-eval --accept-flake-config --command just cliff-count)
if [ "$COUNT" -gt 0 ]; then
echo "release=true" >> $GITHUB_OUTPUT
else
echo "release=false" >> $GITHUB_OUTPUT
fi
COUNT=$(nix develop --no-pure-eval --command just cliff-count)
echo "count=$COUNT" >> $GITHUB_OUTPUT
- name: Determine next version
if: steps.releasable.outputs.release == 'true'
if: steps.releasable.outputs.count > 0
id: next_version
run: |
CLIFF_NEXT_VERSION=$(nix develop --no-pure-eval --accept-flake-config --command just cliff-next-version)
CLIFF_NEXT_VERSION=$(nix develop --no-pure-eval --command just cliff-next-version)
echo "version=$CLIFF_NEXT_VERSION" >> $GITHUB_OUTPUT
- name: Update changelog
if: steps.releasable.outputs.release == 'true'
if: steps.releasable.outputs.count > 0
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
run: just cliff-bump
- name: Create release commit
if: steps.releasable.outputs.release == 'true'
if: steps.releasable.outputs.count > 0
env:
VERSION: ${{ steps.next_version.outputs.version }}
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
run: just commit-release $VERSION
- name: Create version tag
if: steps.releasable.outputs.release == 'true'
if: steps.releasable.outputs.count > 0
env:
VERSION: ${{ steps.next_version.outputs.version }}
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
run: just create-release-tag $VERSION
- name: Create Gitea release
if: steps.releasable.outputs.release == 'true'
id: create_release
env:
VERSION: ${{ steps.next_version.outputs.version }}
CI_TOKEN: ${{ secrets.CI_TOKEN }}
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
run: |
RESPONSE=$(curl -s -X POST \
-H "Authorization: token $CI_TOKEN" \
-H "Content-Type: application/json" \
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" \
-d "{\"tag_name\": \"v${VERSION}\", \"name\": \"v${VERSION}\"}")
echo "release_id=$(echo "$RESPONSE" | jq -r '.id')" >> $GITHUB_OUTPUT
- name: Build Linux release binaries
if: steps.releasable.outputs.count > 0
run: nix build
- name: Build Windows release binaries
if: steps.releasable.outputs.count > 0
run: nix build .#windows
- name: Publish on crates.io
if: steps.releasable.outputs.release == 'true'
if: steps.releasable.outputs.count > 0
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
run: cargo publish
- name: Rebase develop onto main
if: steps.releasable.outputs.release == 'true'
if: steps.releasable.outputs.count > 0
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
run: just rebase-develop
- name: Bump to next dev version
if: steps.releasable.outputs.release == 'true'
if: steps.releasable.outputs.count > 0
env:
VERSION: ${{ steps.next_version.outputs.version }}
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
run: just update-develop-version $VERSION
build:
needs: release
if: needs.release.outputs.release == 'true'
strategy:
matrix:
target: ["linux-x86_64", "linux-aarch64", "windows-x86_64"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Set up cachix
uses: cachix/cachix-action@v17
with:
name: phundrak
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Build jj-cz archive
run: nix build .#${{ matrix.target }}-archive
- name: Upload release asset
env:
CI_TOKEN: ${{ secrets.CI_TOKEN }}
RELEASE_ID: ${{ needs.release.outputs.release_id }}
run: |
curl -s -X POST \
-H "Authorization: token $CI_TOKEN" \
-F "attachment=@$(ls result/dist/*.zip)" \
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets"
+1 -36
View File
@@ -47,8 +47,7 @@ accepted, provided you
assistance);
3. are prepared to discuss it directly with human reviewers.
**All AI usage requires explicit disclosure** (see Attribution section
for commit message requirements), except in these cases:
**All AI usage requires explicit disclosure**, except in these cases:
- Trivial tab autocompletion, but only for completion that you have
already conceptualized in your mind.
- Asking the AI about knowledge that is not directly related to your
@@ -63,40 +62,6 @@ the AI **MUST** be included in the repository. AI **MAY** generate the
initial output, but the final specification **MUST** be entirely
reviewed and understood by a human.
### Attribution
<!-- Inspired by the Linux Kernel AI Coding Assistants guidelines -->
When using AI assistance in contributions:
- **AI cannot be a commit author.** All commits must be authored by a
human contributor.
- **AI cannot sign off commits.** Only humans can legally certify
commits by adding a `Signed-off-by:` tag. AI tools MUST NOT add
`Signed-off-by` tags.
- **The human author bears full responsibility.** The human
contributor is responsible for:
- Reviewing all AI-generated or AI-assisted code
- Ensuring compliance with licensing requirements
- Taking full responsibility for the contribution
- **AI-assisted commits must include an `Assisted-by:` footer**. The
format is:
```
Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]
```
Where:
- `AGENT_NAME` is the name of the AI tool or framework
- `MODEL_VERSION` is the specific model version used
- `[TOOL1] [TOOL2]` are optional specialized analysis tools used
(not basic tools like git, cargo, Nix, editors)
Example:
```
Assisted-by: Claude:claude-3-sonnet
```
---
## Guidelines for AI Agents
+1 -38
View File
@@ -73,44 +73,7 @@ adhere to the following requirements:
(bug reports, feature requests, pull request descriptions,
responding to humans, ...).
### Attribution
When using AI assistance in contributions:
- **AI cannot be a commit author.** All commits must be authored by a
human contributor.
- **AI cannot sign off commits.** Only humans can legally certify
commits by adding a `Signed-off-by:` tag. AI tools MUST NOT add
`Signed-off-by` tags.
- **The human author bears full responsibility.** The human
contributor is responsible for:
- Reviewing all AI-generated or AI-assisted code
- Ensuring compliance with licensing requirements
- Taking full responsibility for the contribution
- **AI-assisted commits must include an `Assisted-by:` footer**. The
format is:
```
Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]
```
Where:
- `AGENT_NAME` is the name of the AI tool or framework
- `MODEL_VERSION` is the specific model version used
- `[TOOL1] [TOOL2]` are optional specialized analysis tools used
(not basic tools like git, cargo, Nix, editors)
Example:
```
Assisted-by: Claude:claude-3-sonnet
```
See the [AGENTS.md](AGENTS.md#attribution) file for the full format
specification.
For more info, please refer to the [AGENTS.md](AGENTS.md)
file.
For more info, please refer to the [AGENTS.md](AGENTS.md) file.
## Code of Conduct
Generated
+360 -299
View File
File diff suppressed because it is too large Load Diff
+10 -11
View File
@@ -24,22 +24,21 @@ test-utils = []
[dependencies]
async-trait = "0.1.89"
etcetera = "0.11.0"
clap = { version = "4.6.1", features = ["derive"] }
git-conventional = "1.1.0"
inquire = { version = "0.9.4", features = ["editor"] }
jj-lib = "0.42.0"
lazy-regex = { version = "3.6.0", features = ["lite"] }
clap = { version = "4.5.57", features = ["derive"] }
git-conventional = "0.12.9"
inquire = { version = "0.9.2", features = ["editor"] }
jj-lib = "0.39.0"
lazy-regex = { version = "3.5.1", features = ["lite"] }
thiserror = "2.0.18"
tokio = { version = "1.52.3", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] }
textwrap = "0.16.2"
unicode-width = "0.2.2"
chrono = "0.4.45"
futures-util = "0.3.32"
chrono = "0.4.44"
[dev-dependencies]
assert_cmd = "2.2.2"
assert_fs = "1.1.4"
predicates = "3.1.4"
assert_cmd = "2.1.2"
assert_fs = "1.1.3"
predicates = "3.1.3"
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
+1 -47
View File
@@ -24,16 +24,6 @@ jj-cz
The tool detects whether you're in a Jujutsu repository, guides you
through the commit message, and applies it to your current change.
You can also set the revision message of a few revisions at once, or
target a single revision other than the current one.
```sh
jj-cz @- xs develop
```
No explicit revision is simply the equivalent of `jj-cz @`, like
`jj desc`.
## Requirements
- A Jujutsu repository
@@ -51,44 +41,8 @@ what `jj-cz` alone would be good for without `jj`.
| 130 | Interrupted |
## Installation
### From crates.io
Simply run the following command:
```
cargo install jj-cz
```
Done! `jj-cz` is now available!
### With Nix Flakes
Notice how theres a `flake.nix` file? This means you can run the
project using this repository as one of your flakes inputs. In fact,
thats how I install it in my own NixOS configuration! Add this
repository to your configuration:
```nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
jj-cz = {
url = "git+https://labs.phundrak.com/phundrak/jj-cz";
inputs.nixpkgs.follows = "nixpkgs";
};
};
}
```
And tadah! you can now install
`inputs.jj-cz.packages.${pkgs.stdenv.hostPlatform.system}.default`
among your other packages. Take a look at my
[`jujutsu.nix`](https://labs.phundrak.com/phundrak/nix-config/src/branch/main/users/modules/dev/vcs/jujutsu.nix)
module if you need some inspiration.
### From source
You can also install `jj-cz` with Cargo by building it from source.
Just make sure Rust is available on your machine (duh!).
You can install jj-cz with Cargo by building it from source.
```sh
cargo install --path .
+1 -6
View File
@@ -2,12 +2,7 @@ use cargo_lock::Lockfile;
fn main() {
let lockfile = Lockfile::load("Cargo.lock").expect("Cargo.lock not found");
let version = lockfile
.packages
.iter()
.find(|p| p.name.as_str() == "jj-lib")
.map(|p| p.version.to_string())
.unwrap_or_else(|| "unknown".to_string());
let version = lockfile.packages.iter().find(|p| p.name.as_str() == "jj-lib").map(|p| p.version.to_string()).unwrap_or_else(|| "unknown".to_string());
println!("cargo:rustc-env=JJ_LIB_VERSION={version}");
println!("cargo:rerun-if-changed=Cargo.lock");
}
Generated
+261 -12
View File
@@ -23,6 +23,65 @@
"type": "github"
}
},
"cachix": {
"inputs": {
"devenv": [
"devenv"
],
"flake-compat": [
"devenv",
"flake-compat"
],
"git-hooks": [
"devenv",
"git-hooks"
],
"nixpkgs": [
"devenv",
"nixpkgs"
]
},
"locked": {
"lastModified": 1760971495,
"narHash": "sha256-IwnNtbNVrlZIHh7h4Wz6VP0Furxg9Hh0ycighvL5cZc=",
"owner": "cachix",
"repo": "cachix",
"rev": "c5bfd933d1033672f51a863c47303fc0e093c2d2",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "latest",
"repo": "cachix",
"type": "github"
}
},
"devenv": {
"inputs": {
"cachix": "cachix",
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"git-hooks": "git-hooks",
"nix": "nix",
"nixd": "nixd",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1770304289,
"narHash": "sha256-+g+XMyB1zi50h2N38GE32l7ZONX4oW7Nw6QSXzfNiwk=",
"owner": "cachix",
"repo": "devenv",
"rev": "fd777e39027d393346e4df672d51ad2bf44b2a12",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
@@ -45,6 +104,58 @@
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1761588595,
"narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"devenv",
"nixpkgs"
]
},
"locked": {
"lastModified": 1760948891,
"narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-root": {
"locked": {
"lastModified": 1723604017,
"narHash": "sha256-rBtQ8gg+Dn4Sx/s+pvjdq3CB2wQNzx9XGFq/JVGCB6k=",
"owner": "srid",
"repo": "flake-root",
"rev": "b759a56851e10cb13f6b8e5698af7b59c44be26e",
"type": "github"
},
"original": {
"owner": "srid",
"repo": "flake-root",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
@@ -79,25 +190,141 @@
"type": "github"
}
},
"nixpkgs": {
"git-hooks": {
"inputs": {
"flake-compat": [
"devenv",
"flake-compat"
],
"gitignore": "gitignore",
"nixpkgs": [
"devenv",
"nixpkgs"
]
},
"locked": {
"lastModified": 1779877693,
"narHash": "sha256-NOF9NAREhxr50bbBfVcVOq+ArCMSoe8dP79Pk2uyARk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4100e830e085863741bc69b156ec4ccd53ab5be0",
"lastModified": 1760663237,
"narHash": "sha256-BflA6U4AM1bzuRMR8QqzPXqh8sWVCNDzOdsxXEguJIc=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "ca5b894d3e3e151ffc1db040b6ce4dcc75d31c37",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"devenv",
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nix": {
"inputs": {
"flake-compat": [
"devenv",
"flake-compat"
],
"flake-parts": [
"devenv",
"flake-parts"
],
"git-hooks-nix": [
"devenv",
"git-hooks"
],
"nixpkgs": [
"devenv",
"nixpkgs"
],
"nixpkgs-23-11": [
"devenv"
],
"nixpkgs-regression": [
"devenv"
]
},
"locked": {
"lastModified": 1769708679,
"narHash": "sha256-uFKkp2/SjIqbu5HtINg/hwHN6qaqcxLIbL/om7dT3kI=",
"owner": "cachix",
"repo": "nix",
"rev": "72bec37fabbfe378d677868ec42eeb83acf07a4c",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "devenv-2.32",
"repo": "nix",
"type": "github"
}
},
"nixd": {
"inputs": {
"flake-parts": [
"devenv",
"flake-parts"
],
"flake-root": "flake-root",
"nixpkgs": [
"devenv",
"nixpkgs"
],
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1763964548,
"narHash": "sha256-JTRoaEWvPsVIMFJWeS4G2isPo15wqXY/otsiHPN0zww=",
"owner": "nix-community",
"repo": "nixd",
"rev": "d4bf15e56540422e2acc7bc26b20b0a0934e3f5e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixd",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1767052823,
"narHash": "sha256-Fhuljcy7pJ8HacYYATRcm5rdKXx8P6D/0g19ppzDRNY=",
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "538a5124359f0b3d466e1160378c87887e3b51a4",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"alejandra": "alejandra",
"devenv": "devenv",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
@@ -127,11 +354,11 @@
]
},
"locked": {
"lastModified": 1779992051,
"narHash": "sha256-4YWGv/0NkAdtTW1MXfaLYpfC9BhpCy9k1pWkR0xI9uw=",
"lastModified": 1770260791,
"narHash": "sha256-ADTBfENFjRVDQMcCycyX/pAy6NFI/Ct6Mrar3gsmXI0=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "e93ad0df1073b2c969a8f0c1f10b84e870469d40",
"rev": "42ec85352e419e601775c57256a52f6d48a39906",
"type": "github"
},
"original": {
@@ -154,6 +381,28 @@
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"devenv",
"nixd",
"nixpkgs"
]
},
"locked": {
"lastModified": 1734704479,
"narHash": "sha256-MMi74+WckoyEWBRcg/oaGRvXC9BVVxDZNRMpL+72wBI=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "65712f5af67234dad91a5a4baee986a8b62dbf8f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",
+31 -15
View File
@@ -2,12 +2,16 @@
description = "Conventional commits for Jujutsu";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
flake-utils.url = "github:numtide/flake-utils";
alejandra = {
url = "github:kamadorueda/alejandra/4.0.0";
inputs.nixpkgs.follows = "nixpkgs";
};
devenv = {
url = "github:cachix/devenv";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
@@ -15,16 +19,8 @@
};
nixConfig = {
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
"phundrak.cachix.org-1:osJAkYO0ioTOPqaQCIXMfIRz1/+YYlVFkup3R2KSexk="
];
extra-substituters = [
"https://nix-community.cachix.org"
"https://devenv.cachix.org"
"https://phundrak.cachix.org"
];
extra-trusted-public-keys = ["devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=" "phundrak.cachix.org-1:osJAkYO0ioTOPqaQCIXMfIRz1/+YYlVFkup3R2KSexk="];
extra-substituters = ["https://devenv.cachix.org" "https://phundrak.cachix.org"];
};
outputs = {
@@ -33,17 +29,37 @@
rust-overlay,
alejandra,
...
}:
} @ inputs:
flake-utils.lib.eachDefaultSystem (
system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {inherit system overlays;};
rustVersion = pkgs.rust-bin.stable.latest.default;
packages = import ./nix/packages.nix {inherit pkgs system;};
rustPlatform = pkgs.makeRustPlatform {
cargo = rustVersion;
rustc = rustVersion;
};
in {
inherit packages;
formatter = alejandra.defaultPackage.${system};
devShell = import ./nix/shell.nix {inherit pkgs rustVersion;};
packages = let
nativeRustVersion = pkgs.rust-bin.stable.latest.default;
nativeRustPlatform = pkgs.makeRustPlatform {
cargo = nativeRustVersion;
rustc = nativeRustVersion;
};
mingwPkgs = pkgs.pkgsCross.mingwW64;
windowsRustVersion = pkgs.rust-bin.stable.latest.default.override {
targets = ["x86_64-pc-windows-gnu"];
};
windowsRustPlatform = mingwPkgs.makeRustPlatform {
cargo = windowsRustVersion;
rustc = windowsRustVersion;
};
in
import ./nix/package.nix {inherit pkgs nativeRustPlatform windowsRustPlatform;};
devShell = import ./nix/shell.nix {
inherit inputs pkgs rustVersion;
};
}
);
}
-16
View File
@@ -1,16 +0,0 @@
{
bin,
pkgs,
archiveName
}:
pkgs.stdenv.mkDerivation rec {
name = "jj-cz-${archiveName}";
src = pkgs.lib.cleanSource ../.;
nativeBuildInputs = [pkgs.zip];
buildPhase = ''
mkdir -p $out/dist
zip -j $out/dist/${name}.zip ${bin}/bin/jj-cz* ${src}/README.md ${src}/LICENSE.*
'';
installPhase = "";
dontConfigure = true;
}
-28
View File
@@ -1,28 +0,0 @@
{
target,
pkgs,
}: let
cargoToml = fromTOML (builtins.readFile ../Cargo.toml);
name = cargoToml.package.name;
version = cargoToml.package.version;
buildArgs = {
pname = name;
inherit version;
src = pkgs.lib.cleanSource ../.;
# cargoLock.lockFile = ../Cargo.lock;
cargoHash = "sha256-yfKaqc+7lvxDukAXxazc57GFs386rr9vUsDk1pobLRM=";
useNextest = true;
meta = {
inherit (cargoToml.package) description homepage;
};
postBuild = "${pkgs.upx}/bin/upx target/*/release/${name}${target.exeSuffix}";
};
rustVersion = pkgs.rust-bin.stable.latest.default.override {
targets = [target.triple];
};
rustPlatform = target.crossPkgs.makeRustPlatform {
cargo = rustVersion;
rustc = rustVersion;
};
in
rustPlatform.buildRustPackage buildArgs
+36
View File
@@ -0,0 +1,36 @@
{
pkgs,
nativeRustPlatform,
windowsRustPlatform,
...
}: let
cargoToml = fromTOML (builtins.readFile ../Cargo.toml);
name = cargoToml.package.name;
version = cargoToml.package.version;
buildArgs = {
pname = name;
inherit version;
src = pkgs.lib.cleanSource ../.;
cargoLock.lockFile = ../Cargo.lock;
useNextest = true;
meta = {
inherit (cargoToml.package) description homepage;
};
postBuild = ''
${pkgs.upx}/bin/upx target/*/release/${name}
'';
};
nativeBuild =
nativeRustPlatform.buildRustPackage buildArgs
// {
postBuild = "${pkgs.upx}/bin/upx target/*/release/${name}";
};
windowsBuild =
windowsRustPlatform.buildRustPackage buildArgs
// {
postBuild = "${pkgs.upx}/bin/upx target/*/release/${name}.exe";
};
in {
default = nativeBuild;
windows = windowsBuild;
}
-82
View File
@@ -1,82 +0,0 @@
{
pkgs,
system,
...
}: let
mkRustBuild = import ./make-binary.nix;
mkArchive = import ./make-archive.nix;
targets = {
linux-x86_64 = {
crossPkgs = pkgs;
triple = "x86_64-unknown-linux-gnu";
exeSuffix = "";
};
linux-aarch64 = {
crossPkgs = pkgs.pkgsCross.aarch64-multiplatform;
triple = "aarch64-unknown-linux-gnu";
exeSuffix = "";
};
windows-x86_64 = {
crossPkgs = pkgs.pkgsCross.mingwW64;
triple = "x86_64-pc-windows-gnu";
exeSuffix = ".exe";
};
windows-aarch64 = {
crossPkgs = pkgs.pkgsCross.aarch64-windows;
triple = "aarch64-pc-windows-gnu";
exeSuffix = ".exe";
};
macos-x86_64 = {
crossPkgs = pkgs.pkgsCross.x86_64-darwin;
triple = "x86_64-apple-darwin";
exeSuffix = "";
};
macos-aarch64 = {
crossPkgs = pkgs.pkgsCross.aarch64-darwin;
triple = "aarch64-apple-darwin";
exeSuffix = "";
};
};
bins = {
linux-x86_64 = mkRustBuild {
inherit pkgs;
target = targets.linux-x86_64;
};
linux-aarch64 = mkRustBuild {
inherit pkgs;
target = targets.linux-aarch64;
};
windows-x86_64 = mkRustBuild {
inherit pkgs;
target = targets.windows-x86_64;
};
};
packages =
{
linux-x86_64-archive = mkArchive {
inherit pkgs;
bin = bins.linux-x86_64;
archiveName = "x86_64-linux";
};
linux-aarch64-archive = mkArchive {
inherit pkgs;
bin = bins.linux-aarch64;
archiveName = "aarch64-linux";
};
windows-x86_64-archive = mkArchive {
inherit pkgs;
bin = bins.windows-x86_64;
archiveName = "x86_64-windows";
};
}
// bins;
defaultBySystem = {
"x86_64-linux" = packages.linux-x86_64;
"aarch64-linux" = packages.linux-aarch64;
"x86_64-windows" = packages.windows-x86_64;
};
in
packages
// {
default = defaultBySystem.${system} or packages.linux-x86_64;
}
+24 -20
View File
@@ -1,27 +1,31 @@
{
inputs,
pkgs,
rustVersion,
...
}:
pkgs.mkShell {
packages = with pkgs; [
(rustVersion.override {
extensions = [
"clippy"
"rust-src"
"rust-analyzer"
"rustfmt"
inputs.devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
{
packages = with pkgs; [
(rustVersion.override {
extensions = [
"clippy"
"rust-src"
"rust-analyzer"
"rustfmt"
];
})
bacon
cargo-deny
cargo-edit
cargo-nextest
cargo-tarpaulin
git-cliff
just
typos
];
})
bacon
cargo-deny
cargo-edit
cargo-nextest
cargo-tarpaulin
git-cliff
just
typos
# for CI
jq
}
];
}
+19 -21
View File
@@ -10,7 +10,6 @@ use std::{
};
use etcetera::BaseStrategy;
use futures_util::StreamExt;
use jj_lib::{
backend::CommitId,
config::{ConfigSource, StackedConfig},
@@ -152,7 +151,7 @@ impl JjLib {
}
/// Resolve a revset string to a commit ID
async fn get_commit_id(&self, revset: &str) -> Result<CommitId, Error> {
fn get_commit_id(&self, revset: &str) -> Result<CommitId, Error> {
let context = RevsetParseContext {
workspace: Some(RevsetWorkspaceContext {
workspace_name: &self.workspace_name,
@@ -180,21 +179,20 @@ impl JjLib {
.map_err(|e| Error::from_revset_resolution_error(revset, e))?
.evaluate(&*repo)
.map_err(|e| Error::from_revset_evaluation_error(revset, e))?;
let mut all_ids = revision.commit_change_ids();
let commit_id = all_ids
let mut iter = revision.iter();
let commit_id = iter
.next()
.await
.ok_or(Error::RevsetResolutionError {
revset: revset.into(),
revset: revset.to_string(),
context: "No matching revision".to_string(),
})?
.map_err(|e| Error::from_revset_evaluation_error(revset, e))?;
match all_ids.next().await {
None => Ok(commit_id.0),
Some(_) => Err(Error::MultipleRevisions {
if iter.next().is_some() {
return Err(Error::MultipleRevisions {
revset: revset.to_string(),
}),
});
}
Ok(commit_id)
}
}
@@ -214,7 +212,7 @@ impl JjExecutor for JjLib {
}
async fn describe(&self, revset: &str, message: &str) -> Result<(), Error> {
let commit_id = self.get_commit_id(revset).await?;
let commit_id = self.get_commit_id(revset)?;
let repo = self.repo.lock()?.clone();
let mut tx = repo.start_transaction();
let commit = tx
@@ -241,8 +239,7 @@ impl JjExecutor for JjLib {
context: format!("{e:?}"),
})?;
let new_repo = tx
.commit("jj-cz: update commit description")
let new_repo = tx.commit("jj-cz: update commit description")
.await
.map_err(|e| Error::JjOperation {
context: e.to_string(),
@@ -253,7 +250,7 @@ impl JjExecutor for JjLib {
}
async fn get_description(&self, revset: &str) -> Result<String, Error> {
let commit_id = self.get_commit_id(revset).await?;
let commit_id = self.get_commit_id(revset)?;
let repo = self.repo.lock()?.clone();
let commit = repo
.store()
@@ -406,16 +403,16 @@ mod tests {
#[tokio::test]
async fn describe_fails_outside_repo() {
// with_working_dir returns Err when not in a repo
let temp_dir = assert_fs::TempDir::new().unwrap();
// with_working_dir returns Err when not in a repo
let executor = JjLib::with_working_dir(temp_dir.path()).await;
assert!(executor.is_err());
let valid_dir = assert_fs::TempDir::new().unwrap();
init_jj_repo(valid_dir.path())
// Use an executor from a valid repo and try to describe a non-existent revset
let executor = JjLib::with_working_dir(std::path::Path::new("."))
.await
.expect("Failed to init jj repo");
let executor = JjLib::with_working_dir(valid_dir.path()).await.unwrap();
.unwrap();
let result = executor
.describe("this-bookmark-does-not-exist", "test: should fail")
.await;
@@ -530,8 +527,9 @@ mod tests {
#[tokio::test]
async fn jj_lib_implements_jj_executor_trait() {
fn assert_implements<T: JjExecutor>() {}
assert_implements::<JjLib>();
let lib = JjLib::with_working_dir(std::path::Path::new(".")).await;
fn accepts_executor(_: impl JjExecutor) {}
accepts_executor(lib.unwrap());
}
mod user_config_paths_tests {
+11
View File
@@ -56,6 +56,12 @@ impl MockJjExecutor {
self
}
/// Configure get_description() to return a specific value
pub fn with_get_description_response(mut self, response: Result<String, Error>) -> Self {
self.get_description_response = response;
self
}
/// Check if is_repository() was called
pub fn was_is_repo_called(&self) -> bool {
self.is_repo_called
@@ -66,6 +72,11 @@ impl MockJjExecutor {
pub fn describe_messages(&self) -> Vec<String> {
self.describe_calls.lock().unwrap().clone()
}
/// Get all revsets visited
pub fn described_revsets(&self) -> Vec<String> {
self.described_revsets.lock().unwrap().clone()
}
}
#[async_trait(?Send)]
+78
View File
@@ -0,0 +1,78 @@
use assert_fs::TempDir;
#[cfg(feature = "test-utils")]
use jj_cz::{Body, BreakingChange, CommitType, Description, MockJjExecutor, MockPrompts, Scope};
use jj_cz::{CommitWorkflow, Error, JjLib};
#[cfg(feature = "test-utils")]
#[tokio::test]
async fn test_happy_path_integration() {
// T037: Happy path integration test
let mock_executor = MockJjExecutor::new();
let mock_prompts = MockPrompts::new()
.with_commit_type(CommitType::Feat)
.with_scope(Scope::empty())
.with_description(Description::parse("add new feature").unwrap())
.with_breaking_change(BreakingChange::No)
.with_body(Body::default())
.with_confirm(true);
let workflow = CommitWorkflow::with_prompts(mock_executor, mock_prompts);
let result = workflow.run_for_revset("@").await;
assert!(
result.is_ok(),
"Workflow should complete successfully: {:?}",
result
);
}
#[tokio::test]
async fn test_not_in_repo() {
// T038: Not-in-repo integration test - with_working_dir itself returns the error
let temp_dir = TempDir::new().unwrap();
let result = JjLib::with_working_dir(temp_dir.path()).await;
assert!(matches!(result, Err(Error::NotARepository)));
}
#[cfg(feature = "test-utils")]
#[tokio::test]
async fn test_cancellation() {
// T039: Cancellation integration test
// This is tricky to test directly without a TTY
// We'll test the error handling path instead
// Create a mock executor that simulates cancellation
struct CancelMock;
#[async_trait::async_trait(?Send)]
impl jj_cz::JjExecutor for CancelMock {
async fn is_repository(&self) -> Result<bool, Error> {
Ok(true)
}
async fn describe(&self, _revset: &str, _message: &str) -> Result<(), Error> {
Err(Error::Cancelled)
}
async fn get_description(&self, _revset: &str) -> Result<String, Error> {
Ok(String::new())
}
}
let executor = CancelMock;
let mock_prompts = MockPrompts::new()
.with_commit_type(CommitType::Feat)
.with_scope(Scope::empty())
.with_description(Description::parse("test").unwrap())
.with_breaking_change(BreakingChange::No)
.with_body(Body::default())
.with_confirm(true);
let workflow = CommitWorkflow::with_prompts(executor, mock_prompts);
let result = workflow.run_for_revset("@").await;
// Should fail with Cancelled error
assert!(matches!(result, Err(Error::Cancelled)));
}