From f37d5402bca698b8d06829812345e9d55c29ffbb Mon Sep 17 00:00:00 2001 From: Malte Brandy Date: Tue, 4 May 2021 13:43:44 +0200 Subject: maintainers/scripts/haskell: Improve commit messages --- .../scripts/haskell/regenerate-hackage-packages.sh | 8 ++++++-- maintainers/scripts/haskell/update-hackage.sh | 10 ++++++++-- maintainers/scripts/haskell/update-stackage.sh | 22 ++++++++++++++++++---- 3 files changed, 32 insertions(+), 8 deletions(-) (limited to 'maintainers') diff --git a/maintainers/scripts/haskell/regenerate-hackage-packages.sh b/maintainers/scripts/haskell/regenerate-hackage-packages.sh index a56d8a0a0e2d6..96131f98fa0f3 100755 --- a/maintainers/scripts/haskell/regenerate-hackage-packages.sh +++ b/maintainers/scripts/haskell/regenerate-hackage-packages.sh @@ -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 diff --git a/maintainers/scripts/haskell/update-hackage.sh b/maintainers/scripts/haskell/update-hackage.sh index a8ad8d9e2ecc9..3c338e98c6456 100755 --- a/maintainers/scripts/haskell/update-hackage.sh +++ b/maintainers/scripts/haskell/update-hackage.sh @@ -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 diff --git a/maintainers/scripts/haskell/update-stackage.sh b/maintainers/scripts/haskell/update-stackage.sh index c3be3158b298a..b332e8d4dc616 100755 --- a/maintainers/scripts/haskell/update-stackage.sh +++ b/maintainers/scripts/haskell/update-stackage.sh @@ -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 -- cgit 1.4.1