depot/third_party/nixpkgs/pkgs/tools/admin/azure-cli/commit-update-hunks.sh
Default email fa5436e0a7 Project import generated by Copybara.
GitOrigin-RevId: e8057b67ebf307f01bdcc8fba94d94f75039d1f6
2024-06-05 17:53:02 +02:00

19 lines
851 B
Bash
Executable file

#!/usr/bin/env bash
# Just a tiny imperfect helper script to commit generated updates.
#
# First, ensure that that `git add -p extensions-generated.nix` only
# returns a series of clean update hunks, where each hunk updates a
# single package version. All additions/removals must be committed
# by hand.
# The script will then commit the remaining hunks with fitting commit messages.
while true; do
echo -e "y\nq" | git add -p extensions-generated.nix || break
pname=$(git diff --no-ext-diff --cached | grep "pname =" | cut -d'"' -f2 | head -n1) || break
versions=$(git diff --no-ext-diff --cached | grep "version =" | cut -d'"' -f2) || break
oldver=$(echo "$versions" | head -n1) || break
newver=$(echo "$versions" | tail -n1) || break
commitmsg="azure-cli-extensions.${pname}: ${oldver} -> ${newver}"
git commit -m "$commitmsg"
done