Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
0e6b559d00
|
|||
|
c1c25e33ff
|
|||
|
8142aee605
|
|||
|
6a702ec205
|
|||
|
412a056e70
|
|||
|
bd6892d91e
|
|||
|
07f5b3e91e
|
|||
|
9a6b94276b
|
|||
|
c5814ab480
|
|||
|
1bab78cb20
|
|||
|
e965a728a1
|
|||
|
95e6250a60
|
|||
|
518d2916b9
|
|||
|
a88f839798
|
|||
|
51cf5bae4e
|
|||
|
825127dbdb
|
@@ -4,8 +4,6 @@ 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
|
||||
|
||||
@@ -20,5 +18,5 @@ if [[ -f .envrc.local ]]; then
|
||||
fi
|
||||
|
||||
if ! use flake . --no-pure-eval; then
|
||||
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
|
||||
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
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Publish Docker Images
|
||||
name: Run checks and build archives
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -6,7 +6,7 @@ on:
|
||||
- main
|
||||
- develop
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
- "v*.*.*"
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
@@ -56,32 +56,36 @@ jobs:
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
||||
|
||||
- name: Build Linux release binary
|
||||
run: nix build --no-pure-eval --accept-flake-config
|
||||
build:
|
||||
needs: coverage-and-sonar
|
||||
strategy:
|
||||
matrix:
|
||||
target: ["linux-x86_64", "linux-aarch64", "windows-x86_64"]
|
||||
|
||||
- name: Prepare Linux binary
|
||||
run: |
|
||||
mkdir dist-linux
|
||||
cp result/bin/jj-cz dist-linux/
|
||||
cp LICENSE.*.md dist-linux/
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Upload Linux artifact
|
||||
- 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
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
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/*
|
||||
name: jj-cz-${{matrix.target}}
|
||||
path: result/dist/*
|
||||
|
||||
@@ -2,33 +2,16 @@ name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
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:
|
||||
@@ -49,58 +32,103 @@ jobs:
|
||||
- name: Check for releasable commits
|
||||
id: releasable
|
||||
run: |
|
||||
COUNT=$(nix develop --no-pure-eval --command just cliff-count)
|
||||
echo "count=$COUNT" >> $GITHUB_OUTPUT
|
||||
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
|
||||
|
||||
- name: Determine next version
|
||||
if: steps.releasable.outputs.count > 0
|
||||
if: steps.releasable.outputs.release == 'true'
|
||||
id: next_version
|
||||
run: |
|
||||
CLIFF_NEXT_VERSION=$(nix develop --no-pure-eval --command just cliff-next-version)
|
||||
CLIFF_NEXT_VERSION=$(nix develop --no-pure-eval --accept-flake-config --command just cliff-next-version)
|
||||
echo "version=$CLIFF_NEXT_VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update changelog
|
||||
if: steps.releasable.outputs.count > 0
|
||||
if: steps.releasable.outputs.release == 'true'
|
||||
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.count > 0
|
||||
if: steps.releasable.outputs.release == 'true'
|
||||
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.count > 0
|
||||
if: steps.releasable.outputs.release == 'true'
|
||||
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: 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: 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: Publish on crates.io
|
||||
if: steps.releasable.outputs.count > 0
|
||||
if: steps.releasable.outputs.release == 'true'
|
||||
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.count > 0
|
||||
if: steps.releasable.outputs.release == 'true'
|
||||
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.count > 0
|
||||
if: steps.releasable.outputs.release == 'true'
|
||||
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"
|
||||
|
||||
@@ -47,7 +47,8 @@ accepted, provided you
|
||||
assistance);
|
||||
3. are prepared to discuss it directly with human reviewers.
|
||||
|
||||
**All AI usage requires explicit disclosure**, except in these cases:
|
||||
**All AI usage requires explicit disclosure** (see Attribution section
|
||||
for commit message requirements), 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
|
||||
@@ -62,6 +63,40 @@ 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
|
||||
|
||||
+38
-1
@@ -73,7 +73,44 @@ adhere to the following requirements:
|
||||
(bug reports, feature requests, pull request descriptions,
|
||||
responding to humans, ...).
|
||||
|
||||
For more info, please refer to the [AGENTS.md](AGENTS.md) file.
|
||||
### 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.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
|
||||
Generated
+300
-361
File diff suppressed because it is too large
Load Diff
+11
-10
@@ -24,21 +24,22 @@ test-utils = []
|
||||
[dependencies]
|
||||
async-trait = "0.1.89"
|
||||
etcetera = "0.11.0"
|
||||
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"] }
|
||||
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"] }
|
||||
thiserror = "2.0.18"
|
||||
tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] }
|
||||
tokio = { version = "1.52.3", features = ["macros", "rt-multi-thread"] }
|
||||
textwrap = "0.16.2"
|
||||
unicode-width = "0.2.2"
|
||||
chrono = "0.4.44"
|
||||
chrono = "0.4.45"
|
||||
futures-util = "0.3.32"
|
||||
|
||||
[dev-dependencies]
|
||||
assert_cmd = "2.1.2"
|
||||
assert_fs = "1.1.3"
|
||||
predicates = "3.1.3"
|
||||
assert_cmd = "2.2.2"
|
||||
assert_fs = "1.1.4"
|
||||
predicates = "3.1.4"
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
|
||||
|
||||
@@ -24,6 +24,16 @@ 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
|
||||
@@ -41,8 +51,44 @@ what `jj-cz` alone would be good for without `jj`.
|
||||
| 130 | Interrupted |
|
||||
|
||||
## Installation
|
||||
### From crates.io
|
||||
Simply run the following command:
|
||||
|
||||
You can install jj-cz with Cargo by building it from source.
|
||||
```
|
||||
cargo install jj-cz
|
||||
```
|
||||
|
||||
Done! `jj-cz` is now available!
|
||||
|
||||
### With Nix Flakes
|
||||
Notice how there’s a `flake.nix` file? This means you can run the
|
||||
project using this repository as one of your flakes inputs. In fact,
|
||||
that’s 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!).
|
||||
|
||||
```sh
|
||||
cargo install --path .
|
||||
|
||||
@@ -2,7 +2,12 @@ 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
+11
-260
@@ -23,65 +23,6 @@
|
||||
"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": [
|
||||
@@ -104,58 +45,6 @@
|
||||
"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"
|
||||
@@ -190,141 +79,25 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"git-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": [
|
||||
"devenv",
|
||||
"flake-compat"
|
||||
],
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"devenv",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1760663237,
|
||||
"narHash": "sha256-BflA6U4AM1bzuRMR8QqzPXqh8sWVCNDzOdsxXEguJIc=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "ca5b894d3e3e151ffc1db040b6ce4dcc75d31c37",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"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",
|
||||
"lastModified": 1779877693,
|
||||
"narHash": "sha256-NOF9NAREhxr50bbBfVcVOq+ArCMSoe8dP79Pk2uyARk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4100e830e085863741bc69b156ec4ccd53ab5be0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"ref": "rolling",
|
||||
"repo": "devenv-nixpkgs",
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"alejandra": "alejandra",
|
||||
"devenv": "devenv",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
@@ -354,11 +127,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1770260791,
|
||||
"narHash": "sha256-ADTBfENFjRVDQMcCycyX/pAy6NFI/Ct6Mrar3gsmXI0=",
|
||||
"lastModified": 1779992051,
|
||||
"narHash": "sha256-4YWGv/0NkAdtTW1MXfaLYpfC9BhpCy9k1pWkR0xI9uw=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "42ec85352e419e601775c57256a52f6d48a39906",
|
||||
"rev": "e93ad0df1073b2c969a8f0c1f10b84e870469d40",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -381,28 +154,6 @@
|
||||
"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",
|
||||
|
||||
@@ -2,16 +2,12 @@
|
||||
description = "Conventional commits for Jujutsu";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
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";
|
||||
@@ -19,8 +15,16 @@
|
||||
};
|
||||
|
||||
nixConfig = {
|
||||
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"];
|
||||
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"
|
||||
];
|
||||
};
|
||||
|
||||
outputs = {
|
||||
@@ -29,37 +33,17 @@
|
||||
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;
|
||||
rustPlatform = pkgs.makeRustPlatform {
|
||||
cargo = rustVersion;
|
||||
rustc = rustVersion;
|
||||
};
|
||||
packages = import ./nix/packages.nix {inherit pkgs system;};
|
||||
in {
|
||||
inherit packages;
|
||||
formatter = alejandra.defaultPackage.${system};
|
||||
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;
|
||||
};
|
||||
devShell = import ./nix/shell.nix {inherit pkgs rustVersion;};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
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
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
{
|
||||
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;
|
||||
}
|
||||
+20
-24
@@ -1,31 +1,27 @@
|
||||
{
|
||||
inputs,
|
||||
pkgs,
|
||||
rustVersion,
|
||||
...
|
||||
}:
|
||||
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
|
||||
pkgs.mkShell {
|
||||
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
|
||||
|
||||
# for CI
|
||||
jq
|
||||
];
|
||||
}
|
||||
|
||||
+21
-19
@@ -10,6 +10,7 @@ use std::{
|
||||
};
|
||||
|
||||
use etcetera::BaseStrategy;
|
||||
use futures_util::StreamExt;
|
||||
use jj_lib::{
|
||||
backend::CommitId,
|
||||
config::{ConfigSource, StackedConfig},
|
||||
@@ -151,7 +152,7 @@ impl JjLib {
|
||||
}
|
||||
|
||||
/// Resolve a revset string to a commit ID
|
||||
fn get_commit_id(&self, revset: &str) -> Result<CommitId, Error> {
|
||||
async fn get_commit_id(&self, revset: &str) -> Result<CommitId, Error> {
|
||||
let context = RevsetParseContext {
|
||||
workspace: Some(RevsetWorkspaceContext {
|
||||
workspace_name: &self.workspace_name,
|
||||
@@ -179,20 +180,21 @@ 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 iter = revision.iter();
|
||||
let commit_id = iter
|
||||
let mut all_ids = revision.commit_change_ids();
|
||||
let commit_id = all_ids
|
||||
.next()
|
||||
.await
|
||||
.ok_or(Error::RevsetResolutionError {
|
||||
revset: revset.to_string(),
|
||||
revset: revset.into(),
|
||||
context: "No matching revision".to_string(),
|
||||
})?
|
||||
.map_err(|e| Error::from_revset_evaluation_error(revset, e))?;
|
||||
if iter.next().is_some() {
|
||||
return Err(Error::MultipleRevisions {
|
||||
match all_ids.next().await {
|
||||
None => Ok(commit_id.0),
|
||||
Some(_) => Err(Error::MultipleRevisions {
|
||||
revset: revset.to_string(),
|
||||
});
|
||||
}),
|
||||
}
|
||||
Ok(commit_id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +214,7 @@ impl JjExecutor for JjLib {
|
||||
}
|
||||
|
||||
async fn describe(&self, revset: &str, message: &str) -> Result<(), Error> {
|
||||
let commit_id = self.get_commit_id(revset)?;
|
||||
let commit_id = self.get_commit_id(revset).await?;
|
||||
let repo = self.repo.lock()?.clone();
|
||||
let mut tx = repo.start_transaction();
|
||||
let commit = tx
|
||||
@@ -239,7 +241,8 @@ 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(),
|
||||
@@ -250,7 +253,7 @@ impl JjExecutor for JjLib {
|
||||
}
|
||||
|
||||
async fn get_description(&self, revset: &str) -> Result<String, Error> {
|
||||
let commit_id = self.get_commit_id(revset)?;
|
||||
let commit_id = self.get_commit_id(revset).await?;
|
||||
let repo = self.repo.lock()?.clone();
|
||||
let commit = repo
|
||||
.store()
|
||||
@@ -403,16 +406,16 @@ mod tests {
|
||||
|
||||
#[tokio::test]
|
||||
async fn describe_fails_outside_repo() {
|
||||
let temp_dir = assert_fs::TempDir::new().unwrap();
|
||||
|
||||
// with_working_dir returns Err when not in a repo
|
||||
let temp_dir = assert_fs::TempDir::new().unwrap();
|
||||
let executor = JjLib::with_working_dir(temp_dir.path()).await;
|
||||
assert!(executor.is_err());
|
||||
|
||||
// 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("."))
|
||||
let valid_dir = assert_fs::TempDir::new().unwrap();
|
||||
init_jj_repo(valid_dir.path())
|
||||
.await
|
||||
.unwrap();
|
||||
.expect("Failed to init jj repo");
|
||||
let executor = JjLib::with_working_dir(valid_dir.path()).await.unwrap();
|
||||
let result = executor
|
||||
.describe("this-bookmark-does-not-exist", "test: should fail")
|
||||
.await;
|
||||
@@ -527,9 +530,8 @@ mod tests {
|
||||
|
||||
#[tokio::test]
|
||||
async fn jj_lib_implements_jj_executor_trait() {
|
||||
let lib = JjLib::with_working_dir(std::path::Path::new(".")).await;
|
||||
fn accepts_executor(_: impl JjExecutor) {}
|
||||
accepts_executor(lib.unwrap());
|
||||
fn assert_implements<T: JjExecutor>() {}
|
||||
assert_implements::<JjLib>();
|
||||
}
|
||||
|
||||
mod user_config_paths_tests {
|
||||
|
||||
@@ -56,12 +56,6 @@ 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
|
||||
@@ -72,11 +66,6 @@ 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)]
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
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)));
|
||||
}
|
||||
Reference in New Issue
Block a user