rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 heartwood3224f8a3f04cc579766cb4f6c3f51ed5ca7604ec
{
"request": "trigger",
"version": 1,
"event_type": "patch",
"repository": {
"id": "rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5",
"name": "heartwood",
"description": "Radicle Heartwood Protocol & Stack",
"private": false,
"default_branch": "master",
"delegates": [
"did:key:z6MksFqXN3Yhqk8pTJdUGLwATkRfQvwZXPqR2qMEhbS9wzpT",
"did:key:z6MkireRatUThvd3qzfKht1S44wpm4FEWSSa4PRMTSQZ3voM",
"did:key:z6MkkPvBfjP4bQmco5Dm7UGsX2ruDBieEHi8n9DVJWX5sTEz"
]
},
"action": "Created",
"patch": {
"id": "ab46c5dfbb42f2a1d40efc7959c1717827c5abdd",
"author": {
"id": "did:key:z6MkkPvBfjP4bQmco5Dm7UGsX2ruDBieEHi8n9DVJWX5sTEz",
"alias": null
},
"title": "Git Pre-Commit Hooks",
"state": {
"status": "merged",
"conflicts": []
},
"before": "77386b0fcedd5bf8f7f9af59dfb678f9a07beb12",
"after": "3224f8a3f04cc579766cb4f6c3f51ed5ca7604ec",
"commits": [
"3224f8a3f04cc579766cb4f6c3f51ed5ca7604ec",
"6f6cf321ed7016438ba0250dd5713e77fc0f8dc2",
"21b29cfb66eb846a691f9aa3bb8067f0e17d9af1",
"3018223328d566c003e2bf37959302c6f314be42",
"6bbe919c4b6ab9639b1130b12f83457f9fafa61c",
"a90aabb1fe2c5d6d969f6c3236f45f93bc6bf3c4",
"f13afe491d169004159a033c4ad7548a7ba76271",
"6dcd56275e606396ec82f4e95fab1d736e8152a4",
"ce8ac663f7fbfa3d28b4677ea28e8b2d47d7a032",
"a9fa31e5e6c5bb2aabf8c8632a7e61afd0204d1d",
"cbca3af260a53b08fbae3864a5b0316aa83c7e40",
"ce07e92a2e634a657a5a6b4324642accb51dc89d"
],
"target": "7e1cb406bb935c3de008d2171e8961f57b4336ea",
"labels": [],
"assignees": [],
"revisions": [
{
"id": "ab46c5dfbb42f2a1d40efc7959c1717827c5abdd",
"author": {
"id": "did:key:z6MkkPvBfjP4bQmco5Dm7UGsX2ruDBieEHi8n9DVJWX5sTEz",
"alias": null
},
"description": "Use [`cachix/git-hooks.nix`](https://github.com/cachix/git-hooks.nix) which wraps [`pre-commit`](https://pre-commit.com) to manage [Git pre-commit hooks](https://git-scm.com/docs/githooks.html#_pre_commit).\n\nCurrently this exposes checks like `cargo check`, `cargo clippy`, `shellcheck` and formatting of Nix files by `alejandra` as a hook. This only works for Nix users and must be initialized by calling `nix develop`.\n\nThe resulting `.pre-commit-config.yaml` is currently ignored, but once we settle on a set of Git hooks that we like, we could add that file so that non-Nix users may use the same hooks via `pre-commit` directly.\n\nHooks are automatically executed by `git commit`, unless the [`--no-verify`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt-code--no-verifycode) flag is passed (escape hatch) and are also part of `nix flake check`.\n\nThe second commit in the patch contains fixes to calm `shellcheck`.",
"base": "77386b0fcedd5bf8f7f9af59dfb678f9a07beb12",
"oid": "0a8790977b598033c1a709f7f1ca81b27cf6a6c2",
"timestamp": 1745324799
},
{
"id": "6da13e39b8a5779bda968b98daec183d02d53df3",
"author": {
"id": "did:key:z6MkkPvBfjP4bQmco5Dm7UGsX2ruDBieEHi8n9DVJWX5sTEz",
"alias": null
},
"description": "Fix `clippy`.",
"base": "77386b0fcedd5bf8f7f9af59dfb678f9a07beb12",
"oid": "cbca3af260a53b08fbae3864a5b0316aa83c7e40",
"timestamp": 1745329459
},
{
"id": "3e2696b95842557934e584389a0e757c4a87c478",
"author": {
"id": "did:key:z6MkkPvBfjP4bQmco5Dm7UGsX2ruDBieEHi8n9DVJWX5sTEz",
"alias": null
},
"description": "Add comment about nixpkgs inputs after review.",
"base": "77386b0fcedd5bf8f7f9af59dfb678f9a07beb12",
"oid": "3dc9ecdb0aed27796d757fe02c905f047849e964",
"timestamp": 1745333582
}
]
}
}
{
"response": "triggered",
"run_id": {
"id": "823712aa-3fe1-4bad-b1b6-75c0efa0cdb3"
},
"info_url": "https://cci.rad.levitte.org//823712aa-3fe1-4bad-b1b6-75c0efa0cdb3.html"
}
Started at: 2026-09-08 17:04:04.824791+02:00
Commands:
$ rad clone rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 .
✓ Creating checkout in ./...
✓ Remote cloudhead@z6MksFqXN3Yhqk8pTJdUGLwATkRfQvwZXPqR2qMEhbS9wzpT added
✓ Remote-tracking branch cloudhead@z6MksFqXN3Yhqk8pTJdUGLwATkRfQvwZXPqR2qMEhbS9wzpT/master created for z6MksFqXN3Yhqk8pTJdUGLwATkRfQvwZXPqR2qMEhbS9wzpT
✓ Remote fintohaps@z6MkireRatUThvd3qzfKht1S44wpm4FEWSSa4PRMTSQZ3voM added
✓ Remote-tracking branch fintohaps@z6MkireRatUThvd3qzfKht1S44wpm4FEWSSa4PRMTSQZ3voM/master created for z6MkireRatUThvd3qzfKht1S44wpm4FEWSSa4PRMTSQZ3voM
✓ Remote lorenz@z6MkkPvBfjP4bQmco5Dm7UGsX2ruDBieEHi8n9DVJWX5sTEz added
✓ Remote-tracking branch lorenz@z6MkkPvBfjP4bQmco5Dm7UGsX2ruDBieEHi8n9DVJWX5sTEz/master created for z6MkkPvBfjP4bQmco5Dm7UGsX2ruDBieEHi8n9DVJWX5sTEz
✓ Repository successfully cloned under /opt/radcis/ci.rad.levitte.org/cci/state/823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/w/
╭────────────────────────────────────╮
│ heartwood │
│ Radicle Heartwood Protocol & Stack │
│ 189 issues · 39 patches │
╰────────────────────────────────────╯
Run `cd ./.` to go to the repository directory.
Exit code: 0
$ rad patch checkout ab46c5dfbb42f2a1d40efc7959c1717827c5abdd
✓ Switched to branch patch/ab46c5d at revision 3e2696b
✓ Branch patch/ab46c5d setup to track rad/patches/ab46c5dfbb42f2a1d40efc7959c1717827c5abdd
Exit code: 0
$ git config advice.detachedHead false
Exit code: 0
$ git checkout 3224f8a3f04cc579766cb4f6c3f51ed5ca7604ec
HEAD is now at 3224f8a3 cob: Add CobAction::requires_reference and validation
Exit code: 0
$ rad patch show ab46c5dfbb42f2a1d40efc7959c1717827c5abdd -p
╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Title Git Pre-Commit Hooks │
│ Patch ab46c5dfbb42f2a1d40efc7959c1717827c5abdd │
│ Author lorenz z6MkkPv…WX5sTEz │
│ Head 3dc9ecdb0aed27796d757fe02c905f047849e964 │
│ Base 77386b0fcedd5bf8f7f9af59dfb678f9a07beb12 │
│ Target master │
│ Branches patch/ab46c5d │
│ Commits ahead 2, behind 1092 │
│ Status merged │
│ │
│ Use [`cachix/git-hooks.nix`](https://github.com/cachix/git-hooks.nix) which │
│ wraps [`pre-commit`](https://pre-commit.com) to manage [Git pre-commit │
│ hooks](https://git-scm.com/docs/githooks.html#_pre_commit). │
│ │
│ Currently this exposes checks like `cargo check`, `cargo clippy`, `shellcheck` │
│ and formatting of Nix files by `alejandra` as a hook. This only works for Nix │
│ users and must be initialized by calling `nix develop`. │
│ │
│ The resulting `.pre-commit-config.yaml` is currently ignored, but once we settle │
│ on a set of Git hooks that we like, we could add that file so that non-Nix users │
│ may use the same hooks via `pre-commit` directly. │
│ │
│ Hooks are automatically executed by `git commit`, unless the │
│ [`--no-verify`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt-code--no-verifycode) │
│ flag is passed (escape hatch) and are also part of `nix flake check`. │
│ │
│ The second commit in the patch contains fixes to calm `shellcheck`. │
├───────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 3dc9ecd chore: shellcheck fixes │
│ 2877593 Add Git pre-commit hooks via Nix │
├───────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ● Revision ab46c5d @ 77386b0..0a87909 by lorenz z6MkkPv…WX5sTEz 1 year ago │
│ ↑ Revision 6da13e3 @ 77386b0..cbca3af by lorenz z6MkkPv…WX5sTEz 1 year ago │
│ └─ ✓ merged by fintohaps z6Mkire…SQZ3voM │
│ ↑ Revision 3e2696b @ 77386b0..3dc9ecd by lorenz z6MkkPv…WX5sTEz 1 year ago │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯
commit 3dc9ecdb0aed27796d757fe02c905f047849e964
Author: Lorenz Leutgeb <lorenz@leutgeb.xyz>
Date: Tue Apr 22 14:25:38 2025 +0200
chore: shellcheck fixes
diff --git a/build/build b/build/build
index c34c83eeac..dc82efe0ae 100755
--- a/build/build
+++ b/build/build
@@ -7,7 +7,8 @@ main() {
# Set minimal locale.
export LC_ALL=C
# Set source date. This is honored by `asciidoctor` and other tools.
- export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
+ SOURCE_DATE_EPOCH="$(git log -1 --pretty=%ct)"
+ export SOURCE_DATE_EPOCH
if ! command -v rad > /dev/null; then
echo "fatal: rad is not installed" >&2 ; exit 1
@@ -21,7 +22,7 @@ main() {
echo "fatal: sha256sum is not installed" >&2 ; exit 1
fi
- rev="$(git rev-parse --short HEAD)"
+ rev="$(git rev-parse HEAD)"
gitarchive="build/heartwood-$rev.tar.gz"
keypath="$(rad path)/keys/radicle.pub"
version="$(build/version)"
@@ -42,38 +43,39 @@ main() {
--build-arg SOURCE_DATE_EPOCH \
--build-arg TZ \
--build-arg LC_ALL \
- --build-arg RADICLE_VERSION=$version \
- --build-arg GIT_HEAD=$rev \
- --arch amd64 --tag $image -f ./build/Dockerfile - < $gitarchive
+ --build-arg "RADICLE_VERSION=$version" \
+ --build-arg "GIT_HEAD=$rev" \
+ --arch amd64 --tag "$image" -f ./build/Dockerfile - < "$gitarchive"
echo "Creating container (radicle-build-container).."
- podman --cgroup-manager=cgroupfs create --ulimit=host --replace --name radicle-build-container $image
+ podman --cgroup-manager=cgroupfs create --ulimit=host --replace --name radicle-build-container "$image"
# Copy build artifacts to output folder.
outdir=build/artifacts
mkdir -p $outdir
podman cp --overwrite radicle-build-container:/builds/. $outdir/
- for target in $(cat build/TARGETS); do
+ while IFS= read -r target
+ do
echo "Signing artifacts for $target.."
filename="radicle-$version-$target.tar.xz"
filepath="$outdir/$filename"
# Output SHA256 digest of archive.
- checksum="$(cd $outdir && sha256sum $filename)"
+ checksum="$(cd $outdir && sha256sum "$filename")"
echo "Checksum of $filepath is $(echo "$checksum" | cut -d' ' -f1)"
- echo "$checksum" > $filepath.sha256
+ echo "$checksum" > "${filepath}.sha256"
# Sign archive and verify archive.
- rm -f $filepath.sig # Delete existing signature
- ssh-keygen -Y sign -n file -f $keypath $filepath
- ssh-keygen -Y check-novalidate -n file -s $filepath.sig < $filepath
- done
+ rm -f "${filepath}.sig" # Delete existing signature
+ ssh-keygen -Y sign -n file -f "$keypath" "$filepath"
+ ssh-keygen -Y check-novalidate -n file -s "$filepath.sig" < "$filepath"
+ done < build/TARGETS
# Remove build artifacts that aren't needed anymore.
podman rm radicle-build-container > /dev/null
- podman rmi --ignore localhost/$image
+ podman rmi --ignore "localhost/$image"
}
# Run build.
diff --git a/build/release b/build/release
index a35d1a9c03..740a971e79 100755
--- a/build/release
+++ b/build/release
@@ -23,12 +23,12 @@ main() {
fi
printf "Releasing Radicle %s? [y/N] " "$version"
- read confirmation
+ read -r confirmation
case "$confirmation" in
[Yy]*)
echo "Creating 'latest' symlink.."
- ssh -i "$SSH_KEY" "$SSH_ADDRESS" ln -snf /mnt/radicle/files/releases/$version /mnt/radicle/files/releases/latest ;;
+ ssh -i "$SSH_KEY" "$SSH_ADDRESS" ln -snf "/mnt/radicle/files/releases/$version" /mnt/radicle/files/releases/latest ;;
*)
echo "Operation aborted."
exit 1 ;;
diff --git a/build/tag b/build/tag
index 7c8b3dbf5e..e3d04db7ec 100755
--- a/build/tag
+++ b/build/tag
@@ -19,8 +19,8 @@ if [ "$signing_key" != "$(rad self --ssh-key)" ]; then
fi
printf "\n"
-printf "Tag the above commit with \033[35m$tag\033[0m, using \033[35m$(rad self --did)\033[0m? [y/N] "
-read confirmation
+printf "Tag the above commit with \033[35m%s\033[0m, using \033[35m$(rad self --did)\033[0m? [y/N] " "$tag"
+read -r confirmation
rad auth
case "$confirmation" in
diff --git a/build/upload b/build/upload
index b8020b5f4a..e0b9439c72 100755
--- a/build/upload
+++ b/build/upload
@@ -17,22 +17,23 @@ main() {
destination="/mnt/radicle/files/releases/$version"
# Create remote folder.
- ssh -i $SSH_KEY $SSH_ADDRESS mkdir -p $destination
+ ssh -i "$SSH_KEY" "$SSH_ADDRESS" mkdir -p "$destination"
# Copy files over.
- scp -i $SSH_KEY build/artifacts/radicle-$version* $SSH_ADDRESS:$destination
- scp -i $SSH_KEY build/artifacts/radicle.json $SSH_ADDRESS:$destination
- scp -i $SSH_KEY build/heartwood-$version.tar.gz $SSH_ADDRESS:$destination
+ scp -i "$SSH_KEY" "build/artifacts/radicle-$version"* "$SSH_ADDRESS:$destination"
+ scp -i "$SSH_KEY" build/artifacts/radicle.json "$SSH_ADDRESS:$destination"
+ scp -i "$SSH_KEY" "build/heartwood-$version.tar.gz" "$SSH_ADDRESS:$destination"
- for target in $(cat build/TARGETS); do
+ while IFS= read -r target
+ do
archive=$destination/radicle-$version-$target.tar.xz
symlink=$destination/radicle-$target.tar.xz
echo "Creating symlinks for $target.."
- ssh -i $SSH_KEY $SSH_ADDRESS ln -snf $archive $symlink
- ssh -i $SSH_KEY $SSH_ADDRESS ln -snf $archive.sig $symlink.sig
- ssh -i $SSH_KEY $SSH_ADDRESS ln -snf $archive.sha256 $symlink.sha256
- done
+ ssh -i "$SSH_KEY" "$SSH_ADDRESS" ln -snf "$archive" "$symlink"
+ ssh -i "$SSH_KEY" "$SSH_ADDRESS" ln -snf "$archive.sig" "$symlink.sig"
+ ssh -i "$SSH_KEY" "$SSH_ADDRESS" ln -snf "$archive.sha256" "$symlink.sha256"
+ done < build/TARGETS
# TODO(cloudhead): Don't pass `--tags` when we have canonical refs.
echo "Pushing tags.."
diff --git a/build/version b/build/version
index 4383147c1c..8a8e573b6a 100755
--- a/build/version
+++ b/build/version
@@ -6,4 +6,4 @@ fi
# Remove `v` prefix from version.
version=${version#v}
-echo $version
+echo "$version"
diff --git a/debian/build-deb b/debian/build-deb
index 6f9ff8bc33..bcd240c981 100755
--- a/debian/build-deb
+++ b/debian/build-deb
@@ -10,6 +10,7 @@ name="$(dpkg-parsechangelog -SSource)"
version="$(dpkg-parsechangelog -SVersion)"
# Get upstream version: everything before the last dash.
+# shellcheck disable=SC2001
uv="$(echo "$version" | sed 's/-[^-]*$//')"
orig="${name}_${uv}.orig.tar.xz"
diff --git a/scripts/changelog b/scripts/changelog
index 4c108ea1c6..324436a7c7 100755
--- a/scripts/changelog
+++ b/scripts/changelog
@@ -24,7 +24,7 @@ done
# Current/latest tag.
current=$(git describe --tags --match='v*' --abbrev=0)
-version=$(echo $current | sed 's/^v//')
+version=$(echo "$current" | sed 's/^v//')
if [ -z "$from" ]; then
previous="$(git describe --abbrev=0 HEAD^)"
@@ -53,14 +53,16 @@ echo "* This update is recommended for everyone. No manual intervention is requi
echo
echo "## Changelog"
-ncommits=$(git rev-list --count $previous..$current)
-ncontribs=$(git log $previous..$current --format='%ae' | sort -u | wc -l)
+range="${previous}..${current}"
+ncommits=$(git rev-list --count "$range")
+ncontribs=$(git log "$range" --format='%ae' | sort -u | wc -l)
echo
echo "This release contains $ncommits commit(s) by $ncontribs contributor(s)."
echo
-git log --pretty=format:'* `%h` **%s** *<%ae>*' $previous..$current
+# shellcheck disable=SC2016
+git log --pretty=format:'* `%h` **%s** *<%ae>*' "$range"
echo
echo "## Checksums"
diff --git a/scripts/clear-refs-db.sh b/scripts/clear-refs-db.sh
index ff70af01bf..32fb3fd95d 100755
--- a/scripts/clear-refs-db.sh
+++ b/scripts/clear-refs-db.sh
@@ -5,8 +5,8 @@ DB="$(rad path)/node/node.db"
if command -v sqlite3 >/dev/null 2>&1; then
if [ -f "$DB" ]; then
- echo -n "Clearing 'refs' table from $DB.. "
- sqlite3 $DB "DELETE FROM refs;"
+ printf "Clearing 'refs' table from %s.. " "$DB"
+ sqlite3 "$DB" "DELETE FROM refs;"
echo "done."
else
echo "fatal: database file does not exist"
diff --git a/scripts/create-env.sh b/scripts/create-env.sh
index 79f98c390e..ff46748061 100755
--- a/scripts/create-env.sh
+++ b/scripts/create-env.sh
@@ -6,12 +6,12 @@ unset SSH_AGENT_PID
tmp="$(mktemp -d)"
-export RAD_HOME=$tmp/.radicle
+export RAD_HOME="$tmp/.radicle"
export RAD_PASSPHRASE=
set -x
-mkdir $tmp/acme
-cd $tmp/acme
+mkdir "$tmp/acme"
+cd "$tmp/acme"
echo "ACME" > README
echo "Copyright (c) 1978-1986 ACME Corp." > COPY
diff --git a/scripts/delete-remote-branches.sh b/scripts/delete-remote-branches.sh
index d2d9e75ea1..6e12f9d3f9 100755
--- a/scripts/delete-remote-branches.sh
+++ b/scripts/delete-remote-branches.sh
@@ -20,7 +20,7 @@ for branch in $(git branch -r --format "%(refname:short)"); do
# Extract the branch name without the "$remote/" prefix.
branch=${branch#"$remote/"}
# Never delete the master branch.
- if [ "$branch" == "master" ]; then
+ if [ "$branch" = "master" ]; then
continue
fi
diff --git a/scripts/delete-remote-refs.sh b/scripts/delete-remote-refs.sh
index 9f93c565c7..d1db83f42a 100755
--- a/scripts/delete-remote-refs.sh
+++ b/scripts/delete-remote-refs.sh
@@ -16,14 +16,14 @@ if [ "$REMOTE" = "$(rad self --nid)" ]; then
exit 1
fi
-cd $RAD_HOME/storage/$REPO
+cd "$RAD_HOME/storage/$REPO"
refs=$(git for-each-ref --format="%(refname)")
pattern="refs/namespaces/$2/refs/*"
for ref in $refs; do
case "$ref" in
- $pattern)
+ "$pattern" )
git update-ref -d "$ref"
printf 'Deleted %s\n' "$ref"
;;
diff --git a/scripts/import-issue.sh b/scripts/import-issue.sh
index c210d11a2f..d293e72ea6 100755
--- a/scripts/import-issue.sh
+++ b/scripts/import-issue.sh
@@ -25,9 +25,12 @@ if ! command -v sed > /dev/null; then
fi
function removeImgTags {
- local html="$(cat)"
- local imgTags="$(echo "$html" | pcregrep -M '<img [^>]*>')"
+ local html
+ html="$(cat)"
+ local imgTags
+ imgTags="$(echo "$html" | pcregrep -M '<img [^>]*>')"
+ # shellcheck disable=SC2066
for imgTag in "$imgTags"; do
html="$(echo "$html" | sed -z "s@$imgTag@@")"
done
diff --git a/scripts/patch-rebase.sh b/scripts/patch-rebase.sh
index 0c0ff6a786..8b0e4211f0 100755
--- a/scripts/patch-rebase.sh
+++ b/scripts/patch-rebase.sh
@@ -6,7 +6,7 @@ if [ "$#" -lt 1 ]; then
exit 1
fi
-rad patch checkout $1
+rad patch checkout "$1"
git rebase master --autosquash
-rad patch update $1 --message "Rebased on master"
+rad patch update "$1" --message "Rebased on master"
git checkout master
diff --git a/scripts/show-sigrefs.sh b/scripts/show-sigrefs.sh
index 3516dabc0c..8279502c5b 100755
--- a/scripts/show-sigrefs.sh
+++ b/scripts/show-sigrefs.sh
@@ -7,16 +7,18 @@ if [ "$#" -lt 2 ]; then
fi
RAD_HOME=${RAD_HOME:-"$HOME/.radicle"}
+# shellcheck disable=SC2001
REPO=$(echo "$1" | sed 's/^rad://')
REMOTE=$2
-cd $RAD_HOME/storage/$REPO
+cd "$RAD_HOME/storage/$REPO"
sigrefs=$(git rev-parse "refs/namespaces/$REMOTE/refs/rad/sigrefs")
signed=$(git show "$sigrefs:refs")
actual=$(git for-each-ref "refs/namespaces/$REMOTE/refs/**" --format="%(objectname) %(refname)")
# Strip namespace prefix.
+# shellcheck disable=SC2001
actual=$(echo "$actual" | sed "s@refs/namespaces/$REMOTE/@@")
# Remove `sigrefs` itself.
actual=$(echo "$actual" | grep -v "refs/rad/sigrefs$")
commit 2877593551e51413de66a19bd71e589fb67c581f
Author: Lorenz Leutgeb <lorenz@leutgeb.xyz>
Date: Tue Apr 22 14:25:00 2025 +0200
Add Git pre-commit hooks via Nix
diff --git a/.gitignore b/.gitignore
index fe8d954e01..aea7fcecc8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
/radicle-cli/target
/build/artifacts
/build/*.tar.gz
+/.pre-commit-config.yaml
diff --git a/flake.lock b/flake.lock
index cd51ecaf0a..7bf9c83f58 100644
--- a/flake.lock
+++ b/flake.lock
@@ -31,6 +31,22 @@
"type": "github"
}
},
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1696426674,
+ "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
"flake-utils": {
"inputs": {
"systems": "systems"
@@ -49,7 +65,44 @@
"type": "github"
}
},
- "nixpkgs": {
+ "gitignore": {
+ "inputs": {
+ "nixpkgs": [
+ "pre-commit-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"
+ }
+ },
+ "nixpkgs-stable": {
+ "locked": {
+ "lastModified": 1740142985,
+ "narHash": "sha256-fCPt2PVnQgiHXGlTRmU5/gFdG/+JT3ycpt+GxY1Vp+s=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "1d1ce35bb6052a23f5692cd89b7cc49acdcb8d0e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "release-24.11",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs-unstable": {
"locked": {
"lastModified": 1740142985,
"narHash": "sha256-fCPt2PVnQgiHXGlTRmU5/gFdG/+JT3ycpt+GxY1Vp+s=",
@@ -65,12 +118,39 @@
"type": "github"
}
},
+ "pre-commit-hooks": {
+ "inputs": {
+ "flake-compat": "flake-compat",
+ "gitignore": "gitignore",
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1742649964,
+ "narHash": "sha256-DwOTp7nvfi8mRfuL1escHDXabVXFGT1VlPD1JHrtrco=",
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "type": "github"
+ }
+ },
"root": {
"inputs": {
"advisory-db": "advisory-db",
"crane": "crane",
"flake-utils": "flake-utils",
- "nixpkgs": "nixpkgs",
+ "nixpkgs": [
+ "nixpkgs-stable"
+ ],
+ "nixpkgs-stable": "nixpkgs-stable",
+ "nixpkgs-unstable": "nixpkgs-unstable",
+ "pre-commit-hooks": "pre-commit-hooks",
"rust-overlay": "rust-overlay"
}
},
diff --git a/flake.nix b/flake.nix
index 77eb4e3018..74fd97c45b 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,17 +2,24 @@
description = "Radicle";
inputs = {
- nixpkgs.url = "github:NixOS/nixpkgs/release-24.11";
+ # This looks redundant, but actually is nice.
+ # Allows to model "stable" vs. "unstable" vs. "don't care".
+ # Don't forget to also adjust the URL for home-manager below
+ # accordingly.
+ nixpkgs-unstable.url = "github:NixOS/nixpkgs/release-24.11";
+ nixpkgs-stable.url = "github:NixOS/nixpkgs/release-24.11";
+ nixpkgs.follows = "nixpkgs-stable";
- crane = {
- url = "github:ipetkov/crane";
+ crane.url = "github:ipetkov/crane";
+
+ pre-commit-hooks = {
+ url = "github:cachix/git-hooks.nix";
+ inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
- inputs = {
- nixpkgs.follows = "nixpkgs";
- };
+ inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
@@ -35,7 +42,7 @@
advisory-db,
rust-overlay,
...
- }:
+ } @ inputs:
flake-utils.lib.eachDefaultSystem (system: let
lib = nixpkgs.lib;
pkgs = import nixpkgs {
@@ -43,8 +50,8 @@
overlays = [(import rust-overlay)];
};
- rustToolChain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
- craneLib = (crane.mkLib pkgs).overrideToolchain rustToolChain;
+ rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
+ craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
srcFilters = path: type:
builtins.any (suffix: lib.hasSuffix suffix path) [
@@ -105,6 +112,23 @@
# Set of checks that are run: `nix flake check`
checks = {
+ pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
+ src = ./.;
+ settings.rust.check.cargoDeps = pkgs.rustPlatform.importCargoLock {lockFile = ./Cargo.lock;};
+ hooks = {
+ alejandra.enable = true;
+ rustfmt.enable = true;
+ cargo-check.enable = true;
+ clippy = {
+ enable = true;
+ settings.denyWarnings = true;
+ packageOverrides.cargo = rustToolchain;
+ packageOverrides.clippy = rustToolchain;
+ };
+ shellcheck.enable = true;
+ };
+ };
+
# Build the crate as part of `nix flake check` for convenience
inherit (self.packages.${system}) radicle;
@@ -230,6 +254,9 @@
};
devShells.default = craneLib.devShell {
+ inherit (self.checks.${system}.pre-commit-check) shellHook;
+ buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
+
# Extra inputs can be added here; cargo and rustc are provided by default.
packages = with pkgs; [
cargo-audit
@@ -241,7 +268,7 @@
sqlite
];
- env.RUST_SRC_PATH = "${rustToolChain}/lib/rustlib/src/rust/library";
+ env.RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
};
});
}
Exit code: 0
shell: 'cargo --version rustc --version cargo fmt --check cargo clippy --all-targets --workspace -- --deny warnings cargo build --all-targets --workspace cargo doc --workspace --no-deps cargo test --workspace --no-fail-fast '
Commands:
$ podman run --name 823712aa-3fe1-4bad-b1b6-75c0efa0cdb3 -v /opt/radcis/ci.rad.levitte.org/cci/state/823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/s:/823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/s:ro -v /opt/radcis/ci.rad.levitte.org/cci/state/823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/w:/823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/w -w /823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/w -v /opt/radcis/ci.rad.levitte.org/.radicle:/${id}/.radicle:ro -e RAD_HOME=/${id}/.radicle rust:trixie bash /823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/s/script.sh
+ cargo --version
info: syncing channel updates for '1.85-x86_64-unknown-linux-gnu'
info: latest update on 2025-03-18, rust version 1.85.1 (4eb161250 2025-03-15)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-src'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-src'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
cargo 1.85.1 (d73d2caf9 2024-12-31)
+ rustc --version
rustc 1.85.1 (4eb161250 2025-03-15)
+ cargo fmt --check
Diff in /823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/w/radicle/src/cob/issue.rs:950:
use crate::cob::{store::CobWithType, ActorId, Reaction};
use crate::git::Oid;
use crate::issue::cache::Issues as _;
- use crate::{assert_matches, test};
use crate::test::arbitrary;
+ use crate::{assert_matches, test};
#[test]
fn test_concurrency() {
Diff in /823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/w/radicle/src/cob/issue.rs:1708:
.unwrap();
// Comments require references, so adding two of them to the same transaction errors.
- let mut tx: Transaction<Issue, test::storage::git::Repository> = Transaction::<Issue, _>::default();
+ let mut tx: Transaction<Issue, test::storage::git::Repository> =
+ Transaction::<Issue, _>::default();
tx.comment("First reply", *issue.id, vec![]).unwrap();
let err = tx.comment("Second reply", *issue.id, vec![]).unwrap_err();
assert_matches!(err, cob::store::Error::ReferenceValidation(_, _));
Diff in /823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/w/radicle/src/cob/patch.rs:320:
_ => vec![],
}
}
-
+
fn requires_reference(&self) -> bool {
- matches!(self, Self::Revision { .. } | Self::RevisionComment { .. } | Self::Review { .. })
+ matches!(
+ self,
+ Self::Revision { .. } | Self::RevisionComment { .. } | Self::Review { .. }
+ )
}
}
Diff in /823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/w/radicle/src/cob/store.rs:124:
err: git::raw::Error,
},
#[error("transaction already contains action {0} which requires a unique reference, denying to add action {1} which also requires a unique reference")]
- ReferenceValidation(String, String)
+ ReferenceValidation(String, String),
}
/// Storage for collaborative objects of a specific type `T` in a single repository.
Diff in /823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/w/radicle/src/cob/store.rs:430:
pub fn push(&mut self, action: T::Action) -> Result<(), Error> {
if action.requires_reference() {
if let Some(index) = self.requires_reference {
- return Err(Error::ReferenceValidation(serde_json::to_string(&self.actions[index])?, serde_json::to_string(&action)?));
+ return Err(Error::ReferenceValidation(
+ serde_json::to_string(&self.actions[index])?,
+ serde_json::to_string(&action)?,
+ ));
} else {
self.requires_reference = Some(self.actions.len())
}
Diff in /823712aa-3fe1-4bad-b1b6-75c0efa0cdb3/w/radicle/src/cob/thread.rs:274:
impl cob::store::CobAction for Action {
fn requires_reference(&self) -> bool {
- matches!(self, Self::Comment {..})
+ matches!(self, Self::Comment { .. })
}
}
Exit code: 1
{
"response": "finished",
"result": "failure"
}