Merge pull request #121688 from maralorn/improve-commit-messages

maintainers/scripts/haskell: Improve commit messages
This commit is contained in:
maralorn 2021-05-04 20:23:25 +02:00 committed by GitHub
commit a47bb0dfd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 8 deletions

View File

@ -20,6 +20,10 @@ unpacked_hackage="$(nix-build -E "$extractionDerivation" --no-out-link)"
hackage2nix --hackage "$unpacked_hackage" --preferred-versions <(for n in "$unpacked_hackage"/*/preferred-versions; do cat "$n"; echo; done) --nixpkgs "$PWD" --config pkgs/development/haskell-modules/configuration-hackage2nix.yaml
if [[ "${1:-}" == "--do-commit" ]]; then
git add pkgs/development/haskell-modules/hackage-packages.nix
git commit -m "hackage-packages.nix: Regenerate based on current config"
git add pkgs/development/haskell-modules/hackage-packages.nix
git commit -F - << EOF
hackage-packages.nix: Regenerate based on current config
This commit has been generated by maintainers/scripts/haskell/regenerate-hackage-packages.sh
EOF
fi

View File

@ -7,9 +7,11 @@ set -euo pipefail
pin_file=pkgs/data/misc/hackage/pin.json
current_commit="$(jq -r .commit $pin_file)"
old_date="$(jq -r .msg $pin_file | sed 's/Update from Hackage at //')"
git_info="$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/commercialhaskell/all-cabal-hashes/branches/hackage)"
head_commit="$(echo "$git_info" | jq -r .commit.sha)"
commit_msg="$(echo "$git_info" | jq -r .commit.commit.message)"
new_date="$(echo "$commit_msg" | sed 's/Update from Hackage at //')"
if [ "$current_commit" != "$head_commit" ]; then
url="https://github.com/commercialhaskell/all-cabal-hashes/archive/$head_commit.tar.gz"
@ -24,6 +26,10 @@ if [ "$current_commit" != "$head_commit" ]; then
fi
if [[ "${1:-}" == "--do-commit" ]]; then
git add pkgs/data/misc/hackage/pin.json
git commit -m "all-cabal-hashes: Changing pin to '$commit_msg'"
git add pkgs/data/misc/hackage/pin.json
git commit -F - << EOF
all-cabal-hashes: $old_date -> $new_date
This commit has been generated by maintainers/scripts/haskell/update-hackage.sh
EOF
fi

View File

@ -4,11 +4,21 @@ set -eu -o pipefail
tmpfile=$(mktemp "update-stackage.XXXXXXX")
# shellcheck disable=SC2064
config_file="pkgs/development/haskell-modules/configuration-hackage2nix.yaml"
trap "rm ${tmpfile} ${tmpfile}.new" 0
touch "$tmpfile" "$tmpfile.new" # Creating files here so that trap creates no errors.
curl -L -s "https://stackage.org/nightly/cabal.config" >"$tmpfile"
old_version=$(grep " # Stackage Nightly" $config_file | sed -E 's/.*([0-9]{4}-[0-9]{2}-[0-9]{2}).*/\1/')
version=$(sed -rn "s/^--.*http:..(www.)?stackage.org.snapshot.nightly-//p" "$tmpfile")
if [[ "$old_version" == "$version" ]]; then
echo "No new stackage version"
exit 0 # Nothing to do
fi
# Create a simple yaml version of the file.
sed -r \
-e '/^--/d' \
@ -43,14 +53,18 @@ sed -r \
# Drop the previous configuration ...
# shellcheck disable=SC1004
sed -e '/ # Stackage Nightly/,/^$/c \TODO\
' -i pkgs/development/haskell-modules/configuration-hackage2nix.yaml
' -i $config_file
# ... and replace it with the new one.
sed -e "/TODO/r $tmpfile" \
-e "s/TODO/ # Stackage Nightly $version/" \
-i pkgs/development/haskell-modules/configuration-hackage2nix.yaml
-i $config_file
if [[ "${1:-}" == "--do-commit" ]]; then
git add pkgs/development/haskell-modules/configuration-hackage2nix.yaml
git commit -m "configuration-hackage2nix.yaml: Changing Stackage pin to Nightly $version"
git add $config_file
git commit -F - << EOF
Stackage Nightly: $old_version -> $version
This commit has been generated by maintainers/scripts/haskell/update-stackage.sh
EOF
fi