mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
update-scripts/update: fix 'has changed' condition when not committing
This commit is contained in:
parent
fcffcca3fd
commit
73e273a50c
1 changed files with 37 additions and 12 deletions
|
@ -31,22 +31,47 @@ writeShellApplication {
|
||||||
update_args+=( "--commit-lock-file" )
|
update_args+=( "--commit-lock-file" )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
currentCommit() {
|
||||||
|
git show --no-patch --format=%h
|
||||||
|
}
|
||||||
|
|
||||||
|
hasChanges() {
|
||||||
|
old="$1"
|
||||||
|
new="$2"
|
||||||
|
if [ -n "$commit" ]; then
|
||||||
|
[ "$old" != "$new" ]
|
||||||
|
elif git diff --quiet; then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
writeGitHubOutput() {
|
writeGitHubOutput() {
|
||||||
if [ -n "$use_github_output" ]; then
|
if [ -n "$use_github_output" ] && [ -n "$commit" ]; then
|
||||||
(
|
{
|
||||||
echo "$1<<EOF"
|
echo "$1<<EOF"
|
||||||
git show --no-patch --format=%b
|
git show --no-patch --format=%b
|
||||||
echo "EOF"
|
echo "EOF"
|
||||||
) >> "$GITHUB_OUTPUT"
|
} >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
versionInfo() {
|
versionInfo() {
|
||||||
|
extra_args=( )
|
||||||
|
if [ "$1" = "--amend" ]; then
|
||||||
|
extra_args+=(
|
||||||
|
"--amend"
|
||||||
|
"--no-edit"
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
nix-build ./update-scripts -A version-info
|
nix-build ./update-scripts -A version-info
|
||||||
./result/bin/version-info
|
./result/bin/version-info
|
||||||
|
|
||||||
if [ -n "$commit" ]; then
|
if [ -n "$commit" ]; then
|
||||||
git add version-info.toml
|
git add version-info.toml
|
||||||
git commit "$@"
|
git commit "''${extra_args[@]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,27 +82,27 @@ writeShellApplication {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update the root lockfile
|
# Update the root lockfile
|
||||||
old=$(git show --no-patch --format=%h)
|
old=$(currentCommit)
|
||||||
echo "Updating root lockfile"
|
echo "Updating root lockfile"
|
||||||
nix flake update "''${update_args[@]}"
|
nix flake update "''${update_args[@]}"
|
||||||
new=$(git show --no-patch --format=%h)
|
new=$(currentCommit)
|
||||||
if [ "$old" != "$new" ]; then
|
if hasChanges "$old" "$new"; then
|
||||||
echo "Updating version-info"
|
echo "Updating version-info"
|
||||||
versionInfo --amend --no-edit
|
versionInfo --amend
|
||||||
writeGitHubOutput root_lock_body
|
writeGitHubOutput root_lock_body
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update the dev lockfile
|
# Update the dev lockfile
|
||||||
root_nixpkgs=$(nix eval --raw --file . 'inputs.nixpkgs.rev')
|
root_nixpkgs=$(nix eval --raw --file . 'inputs.nixpkgs.rev')
|
||||||
old=$(git show --no-patch --format=%h)
|
old=$(currentCommit)
|
||||||
echo "Updating dev lockfile"
|
echo "Updating dev lockfile"
|
||||||
nix flake update "''${update_args[@]}" \
|
nix flake update "''${update_args[@]}" \
|
||||||
--override-input 'dev-nixpkgs' "github:NixOS/nixpkgs/$root_nixpkgs" \
|
--override-input 'dev-nixpkgs' "github:NixOS/nixpkgs/$root_nixpkgs" \
|
||||||
--flake './flake/dev'
|
--flake './flake/dev'
|
||||||
new=$(git show --no-patch --format=%h)
|
new=$(currentCommit)
|
||||||
if [ "$old" != "$new" ]; then
|
if hasChanges "$old" "$new"; then
|
||||||
echo "Updating version-info"
|
echo "Updating version-info"
|
||||||
versionInfo --amend --no-edit
|
versionInfo --amend
|
||||||
writeGitHubOutput dev_lock_body
|
writeGitHubOutput dev_lock_body
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue