Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
3564230dba
|
|||
|
984630636d
|
|||
|
854136d2a9
|
@@ -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="
|
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.0/direnvrc" "sha256-yMJ2OVMzrFaDPn7q8nCBZFRYpL/f0RcHzhmw/i6btJM="
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export DEVENV_IN_DIRENV_SHELL=true
|
|
||||||
|
|
||||||
# Load .env file if present
|
# Load .env file if present
|
||||||
dotenv_if_exists
|
dotenv_if_exists
|
||||||
|
|
||||||
@@ -20,5 +18,5 @@ if [[ -f .envrc.local ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if ! use flake . --no-pure-eval; then
|
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
|
fi
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: Publish Docker Images
|
name: Run checks and build archives
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -6,7 +6,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
- develop
|
- develop
|
||||||
tags:
|
tags:
|
||||||
- 'v*.*.*'
|
- "v*.*.*"
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
@@ -56,32 +56,36 @@ jobs:
|
|||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
||||||
|
|
||||||
- name: Build Linux release binary
|
build:
|
||||||
run: nix build --no-pure-eval --accept-flake-config
|
needs: coverage-and-sonar
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target: ["linux-x86_64", "linux-aarch64", "windows-x86_64"]
|
||||||
|
|
||||||
- name: Prepare Linux binary
|
runs-on: ubuntu-latest
|
||||||
run: |
|
permissions:
|
||||||
mkdir dist-linux
|
contents: read
|
||||||
cp result/bin/jj-cz dist-linux/
|
pull-requests: read
|
||||||
cp LICENSE.*.md dist-linux/
|
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
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: jj-cz-x86_64-unknown-linux-gnu
|
name: jj-cz-${{matrix.target}}
|
||||||
path: dist-linux/*
|
path: result/dist/*
|
||||||
|
|
||||||
- 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/*
|
|
||||||
|
|||||||
+107
-36
@@ -6,29 +6,12 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
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:
|
release:
|
||||||
needs: checks
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
released: ${{ steps.releasable.outputs.released }}
|
||||||
|
release_id: ${{ steps.create_release.outputs.release_id }}
|
||||||
|
version: ${{ steps.next_version.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -50,57 +33,145 @@ jobs:
|
|||||||
id: releasable
|
id: releasable
|
||||||
run: |
|
run: |
|
||||||
COUNT=$(nix develop --no-pure-eval --command just cliff-count)
|
COUNT=$(nix develop --no-pure-eval --command just cliff-count)
|
||||||
echo "count=$COUNT" >> $GITHUB_OUTPUT
|
if [ "$COUNT" -gt 0 ]; then
|
||||||
|
echo "release=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "release=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Determine next version
|
- name: Determine next version
|
||||||
if: steps.releasable.outputs.count > 0
|
if: steps.releasable.outputs.release = 'true'
|
||||||
id: next_version
|
id: next_version
|
||||||
run: |
|
run: |
|
||||||
CLIFF_NEXT_VERSION=$(nix develop --no-pure-eval --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
|
echo "version=$CLIFF_NEXT_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Update changelog
|
- 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}"
|
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
||||||
run: just cliff-bump
|
run: just cliff-bump
|
||||||
|
|
||||||
- name: Create release commit
|
- name: Create release commit
|
||||||
if: steps.releasable.outputs.count > 0
|
if: steps.releasable.outputs.release = 'true'
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ steps.next_version.outputs.version }}
|
VERSION: ${{ steps.next_version.outputs.version }}
|
||||||
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
||||||
run: just commit-release $VERSION
|
run: just commit-release $VERSION
|
||||||
|
|
||||||
- name: Create version tag
|
- name: Create version tag
|
||||||
if: steps.releasable.outputs.count > 0
|
if: steps.releasable.outputs.release = 'true'
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ steps.next_version.outputs.version }}
|
VERSION: ${{ steps.next_version.outputs.version }}
|
||||||
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
||||||
run: just create-release-tag $VERSION
|
run: just create-release-tag $VERSION
|
||||||
|
|
||||||
- name: Build Linux release binaries
|
- name: Create Gitea release
|
||||||
if: steps.releasable.outputs.count > 0
|
if: steps.releasable.outputs.released == 'true'
|
||||||
run: nix build
|
id: create_release
|
||||||
|
env:
|
||||||
- name: Build Windows release binaries
|
VERSION: ${{ steps.next_version.outputs.version }}
|
||||||
if: steps.releasable.outputs.count > 0
|
CI_TOKEN: ${{ secrets.CI_TOKEN }}
|
||||||
run: nix build .#windows
|
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
|
- name: Publish on crates.io
|
||||||
if: steps.releasable.outputs.count > 0
|
if: steps.releasable.outputs.released == 'true'
|
||||||
env:
|
env:
|
||||||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||||
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
||||||
run: cargo publish
|
run: cargo publish
|
||||||
|
|
||||||
- name: Rebase develop onto main
|
- name: Rebase develop onto main
|
||||||
if: steps.releasable.outputs.count > 0
|
if: steps.releasable.outputs.released == 'true'
|
||||||
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
||||||
run: just rebase-develop
|
run: just rebase-develop
|
||||||
|
|
||||||
- name: Bump to next dev version
|
- name: Bump to next dev version
|
||||||
if: steps.releasable.outputs.count > 0
|
if: steps.releasable.outputs.released == 'true'
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ steps.next_version.outputs.version }}
|
VERSION: ${{ steps.next_version.outputs.version }}
|
||||||
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
||||||
run: just update-develop-version $VERSION
|
run: just update-develop-version $VERSION
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: release
|
||||||
|
if: needs.release.outputs.released == '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"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# name: Release
|
||||||
|
|
||||||
|
# on:
|
||||||
|
# push:
|
||||||
|
# branches:
|
||||||
|
# - main
|
||||||
|
|
||||||
|
# jobs:
|
||||||
|
# release:
|
||||||
|
# needs: checks
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# steps:
|
||||||
|
|
||||||
|
|
||||||
|
# - name: Build Linux release binaries
|
||||||
|
# if: steps.releasable.outputs.release = 'true'
|
||||||
|
# run: nix build
|
||||||
|
|
||||||
|
# - name: Build Windows release binaries
|
||||||
|
# if: steps.releasable.outputs.release = 'true'
|
||||||
|
# run: nix build .#windows
|
||||||
|
|
||||||
|
# - name: Publish on crates.io
|
||||||
|
# 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.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.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
|
||||||
|
|||||||
Generated
+208
-238
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -27,7 +27,7 @@ etcetera = "0.11.0"
|
|||||||
clap = { version = "4.5.57", features = ["derive"] }
|
clap = { version = "4.5.57", features = ["derive"] }
|
||||||
git-conventional = "0.12.9"
|
git-conventional = "0.12.9"
|
||||||
inquire = { version = "0.9.2", features = ["editor"] }
|
inquire = { version = "0.9.2", features = ["editor"] }
|
||||||
jj-lib = "0.40.0"
|
jj-lib = "0.41.0"
|
||||||
lazy-regex = { version = "3.5.1", features = ["lite"] }
|
lazy-regex = { version = "3.5.1", features = ["lite"] }
|
||||||
thiserror = "2.0.18"
|
thiserror = "2.0.18"
|
||||||
tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] }
|
||||||
|
|||||||
Generated
+11
-260
@@ -23,65 +23,6 @@
|
|||||||
"type": "github"
|
"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": {
|
"fenix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@@ -104,58 +45,6 @@
|
|||||||
"type": "github"
|
"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": {
|
"flake-utils": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
@@ -190,141 +79,25 @@
|
|||||||
"type": "github"
|
"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": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1767052823,
|
"lastModified": 1776949667,
|
||||||
"narHash": "sha256-Fhuljcy7pJ8HacYYATRcm5rdKXx8P6D/0g19ppzDRNY=",
|
"narHash": "sha256-GMSVw35Q+294GlrTUKlx087E31z7KurReQ1YHSKp5iw=",
|
||||||
"owner": "cachix",
|
"owner": "NixOS",
|
||||||
"repo": "devenv-nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "538a5124359f0b3d466e1160378c87887e3b51a4",
|
"rev": "01fbdeef22b76df85ea168fbfe1bfd9e63681b30",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "cachix",
|
"owner": "NixOS",
|
||||||
"ref": "rolling",
|
"ref": "nixpkgs-unstable",
|
||||||
"repo": "devenv-nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"alejandra": "alejandra",
|
"alejandra": "alejandra",
|
||||||
"devenv": "devenv",
|
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
@@ -354,11 +127,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1770260791,
|
"lastModified": 1777173302,
|
||||||
"narHash": "sha256-ADTBfENFjRVDQMcCycyX/pAy6NFI/Ct6Mrar3gsmXI0=",
|
"narHash": "sha256-ERiu3cbxvnTDxiDcimRA7af7xp6x1y0sRyLGm28Qzz8=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "42ec85352e419e601775c57256a52f6d48a39906",
|
"rev": "aaec8c50baeaf2f2ba653e8aae71778a2bbbac94",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -381,28 +154,6 @@
|
|||||||
"repo": "default",
|
"repo": "default",
|
||||||
"type": "github"
|
"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",
|
"root": "root",
|
||||||
|
|||||||
@@ -2,16 +2,12 @@
|
|||||||
description = "Conventional commits for Jujutsu";
|
description = "Conventional commits for Jujutsu";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
alejandra = {
|
alejandra = {
|
||||||
url = "github:kamadorueda/alejandra/4.0.0";
|
url = "github:kamadorueda/alejandra/4.0.0";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
devenv = {
|
|
||||||
url = "github:cachix/devenv";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
rust-overlay = {
|
rust-overlay = {
|
||||||
url = "github:oxalica/rust-overlay";
|
url = "github:oxalica/rust-overlay";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
@@ -19,8 +15,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
nixConfig = {
|
nixConfig = {
|
||||||
extra-trusted-public-keys = ["devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=" "phundrak.cachix.org-1:osJAkYO0ioTOPqaQCIXMfIRz1/+YYlVFkup3R2KSexk="];
|
extra-trusted-public-keys = ["phundrak.cachix.org-1:osJAkYO0ioTOPqaQCIXMfIRz1/+YYlVFkup3R2KSexk="];
|
||||||
extra-substituters = ["https://devenv.cachix.org" "https://phundrak.cachix.org"];
|
extra-substituters = ["https://phundrak.cachix.org"];
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {
|
outputs = {
|
||||||
@@ -29,37 +25,17 @@
|
|||||||
rust-overlay,
|
rust-overlay,
|
||||||
alejandra,
|
alejandra,
|
||||||
...
|
...
|
||||||
} @ inputs:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (
|
flake-utils.lib.eachDefaultSystem (
|
||||||
system: let
|
system: let
|
||||||
overlays = [(import rust-overlay)];
|
overlays = [(import rust-overlay)];
|
||||||
pkgs = import nixpkgs {inherit system overlays;};
|
pkgs = import nixpkgs {inherit system overlays;};
|
||||||
rustVersion = pkgs.rust-bin.stable.latest.default;
|
rustVersion = pkgs.rust-bin.stable.latest.default;
|
||||||
rustPlatform = pkgs.makeRustPlatform {
|
packages = import ./nix/packages.nix {inherit pkgs system;};
|
||||||
cargo = rustVersion;
|
|
||||||
rustc = rustVersion;
|
|
||||||
};
|
|
||||||
in {
|
in {
|
||||||
|
inherit packages;
|
||||||
formatter = alejandra.defaultPackage.${system};
|
formatter = alejandra.defaultPackage.${system};
|
||||||
packages = let
|
devShell = import ./nix/shell.nix {inherit pkgs rustVersion;};
|
||||||
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;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,27 @@
|
|||||||
|
{
|
||||||
|
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;
|
||||||
|
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,33 +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;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
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;
|
||||||
|
}
|
||||||
+4
-8
@@ -1,13 +1,8 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
rustVersion,
|
rustVersion,
|
||||||
...
|
|
||||||
}:
|
}:
|
||||||
inputs.devenv.lib.mkShell {
|
pkgs.mkShell {
|
||||||
inherit inputs pkgs;
|
|
||||||
modules = [
|
|
||||||
{
|
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
(rustVersion.override {
|
(rustVersion.override {
|
||||||
extensions = [
|
extensions = [
|
||||||
@@ -25,7 +20,8 @@ inputs.devenv.lib.mkShell {
|
|||||||
git-cliff
|
git-cliff
|
||||||
just
|
just
|
||||||
typos
|
typos
|
||||||
];
|
|
||||||
}
|
# for CI
|
||||||
|
jq
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,20 +179,20 @@ impl JjLib {
|
|||||||
.map_err(|e| Error::from_revset_resolution_error(revset, e))?
|
.map_err(|e| Error::from_revset_resolution_error(revset, e))?
|
||||||
.evaluate(&*repo)
|
.evaluate(&*repo)
|
||||||
.map_err(|e| Error::from_revset_evaluation_error(revset, e))?;
|
.map_err(|e| Error::from_revset_evaluation_error(revset, e))?;
|
||||||
let mut iter = revision.iter();
|
let mut all_ids = revision.commit_change_ids();
|
||||||
let commit_id = iter
|
let commit_id = all_ids
|
||||||
.next()
|
.next()
|
||||||
.ok_or(Error::RevsetResolutionError {
|
.ok_or(Error::RevsetResolutionError {
|
||||||
revset: revset.to_string(),
|
revset: revset.into(),
|
||||||
context: "No matching revision".to_string(),
|
context: "No matching revision".to_string(),
|
||||||
})?
|
})?
|
||||||
.map_err(|e| Error::from_revset_evaluation_error(revset, e))?;
|
.map_err(|e| Error::from_revset_evaluation_error(revset, e))?;
|
||||||
if iter.next().is_some() {
|
match all_ids.next() {
|
||||||
return Err(Error::MultipleRevisions {
|
None => Ok(commit_id.0),
|
||||||
|
Some(_) => Err(Error::MultipleRevisions {
|
||||||
revset: revset.to_string(),
|
revset: revset.to_string(),
|
||||||
});
|
}),
|
||||||
}
|
}
|
||||||
Ok(commit_id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,12 +56,6 @@ impl MockJjExecutor {
|
|||||||
self
|
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
|
/// Check if is_repository() was called
|
||||||
pub fn was_is_repo_called(&self) -> bool {
|
pub fn was_is_repo_called(&self) -> bool {
|
||||||
self.is_repo_called
|
self.is_repo_called
|
||||||
@@ -72,11 +66,6 @@ impl MockJjExecutor {
|
|||||||
pub fn describe_messages(&self) -> Vec<String> {
|
pub fn describe_messages(&self) -> Vec<String> {
|
||||||
self.describe_calls.lock().unwrap().clone()
|
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)]
|
#[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