Skip to content

Commit

Permalink
dev: fix --commit when the worktree is dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Jul 15, 2024
1 parent cff06c8 commit c1feced
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions flake-modules/updates/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@
cd "$generated_dir"
git add .
# Construct a msg body from `git status`
# Construct a msg body from `git status -- .`
body=$(
git status \
--short \
--ignored=no \
--untracked-files=no \
--no-ahead-behind \
-- . \
| sed \
-e 's/^\s*\([A-Z]\)\s*/\1 /' \
-e 's/^A/Added/' \
Expand All @@ -60,15 +61,19 @@
)
# Construct the commit message based on the body
count=$(echo "$body" | wc -l)
count=$(echo -n "$body" | wc -l)
if [ "$count" -gt 1 ] || [ ''${#body} -gt 50 ]; then
msg=$(echo -e "generated: Update\n\n$body")
else
msg="generated:''${body:1}"
fi
# Commit if there are changes
[ "$count" -gt 0 ] && git commit -m "$msg" --no-verify
if [ "$count" -gt 0 ]; then
echo "Committing $count changes..."
echo "$msg"
git commit -m "$msg" --no-verify
fi
fi
'';
};
Expand Down

0 comments on commit c1feced

Please sign in to comment.