Skip to content

Commit 5085457

Browse files
committed
config(commit_flake_update.bash): Add FLAKE_INPUT as a parameter with empty default value
1 parent 0baddf2 commit 5085457

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

scripts/commit_flake_update.bash

Lines changed: 17 additions & 4 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,18 @@ 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+
$(cat $msg_file)
43+
EOF
44+
else
45+
git commit --amend -F - <<EOF
46+
"chore(flake.lock): Update "$FLAKE_INPUT" Flake input ($(date -I))"
3547
3648
$(cat $msg_file)
3749
EOF
50+
fi
3851

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

0 commit comments

Comments
 (0)