Skip to content

Commit b0dcbd4

Browse files
galin-sMartinNikov
authored andcommitted
config(commit_flake_update.bash): Add FLAKE_INPUT as a parameter with empty default value
1 parent 0df76e6 commit b0dcbd4

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

scripts/commit_flake_update.bash

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -euo pipefail
44

5+
FLAKE_INPUT=${FLAKE_INPUT:-""}
6+
57
if ! git config --get user.name >/dev/null 2>&1 || \
68
[ "$(git config --get user.name)" = "" ] ||
79
! git config --get user.email >/dev/null 2>&1 || \
@@ -15,11 +17,15 @@ fi
1517
current_commit="$(git rev-parse HEAD)"
1618
export PRE_COMMIT_ALLOW_NO_CONFIG=1
1719

18-
nix flake update --accept-flake-config --commit-lock-file
20+
nix flake update $FLAKE_INPUT --accept-flake-config --commit-lock-file
1921
commit_after_update="$(git rev-parse HEAD)"
2022

2123
if [[ "$commit_after_update" = "$current_commit" ]]; then
22-
echo "All flake inputs are up to date."
24+
if [[ "$FLAKE_INPUT" = "" ]]; then
25+
echo "All flake inputs are up to date."
26+
else
27+
echo "$FLAKE_INPUT input is up to date."
28+
fi
2329
exit 0
2430
fi
2531

@@ -30,11 +36,19 @@ msg_file=./commit_msg_body.txt
3036
echo '```'
3137
} > $msg_file
3238

33-
git commit --amend -F - <<EOF
34-
chore(flake.lock): Update all Flake inputs ($(date -I))
39+
if [[ "$FLAKE_INPUT" = "" ]]; then
40+
git commit --amend -F - <<EOF
41+
chore(flake.lock): Update all Flake inputs ($(date -I))
42+
43+
$(cat $msg_file)
44+
EOF
45+
else
46+
git commit --amend -F - <<EOF
47+
chore(flake.lock): Update \`$FLAKE_INPUT\` Flake input ($(date -I))
3548
36-
$(cat $msg_file)
49+
$(cat $msg_file)
3750
EOF
51+
fi
3852

3953
if [ -z "${CI+x}" ]; then
4054
rm -v $msg_file

0 commit comments

Comments
 (0)