summary refs log tree commit diff
path: root/maintainers/scripts
diff options
context:
space:
mode:
authorMalte Brandy <malte.brandy@maralorn.de>2021-05-04 13:43:44 +0200
committerMalte Brandy <malte.brandy@maralorn.de>2021-05-04 14:29:45 +0200
commitf37d5402bca698b8d06829812345e9d55c29ffbb (patch)
tree5ea00537666dbca9afabe890d26755418cc0f280 /maintainers/scripts
parent86c975b00c8111502c972b1aed16dc364f459dd6 (diff)
downloadnixpkgs-f37d5402bca698b8d06829812345e9d55c29ffbb.tar
nixpkgs-f37d5402bca698b8d06829812345e9d55c29ffbb.tar.gz
nixpkgs-f37d5402bca698b8d06829812345e9d55c29ffbb.tar.bz2
nixpkgs-f37d5402bca698b8d06829812345e9d55c29ffbb.tar.lz
nixpkgs-f37d5402bca698b8d06829812345e9d55c29ffbb.tar.xz
nixpkgs-f37d5402bca698b8d06829812345e9d55c29ffbb.tar.zst
nixpkgs-f37d5402bca698b8d06829812345e9d55c29ffbb.zip
maintainers/scripts/haskell: Improve commit messages
Diffstat (limited to 'maintainers/scripts')
-rwxr-xr-xmaintainers/scripts/haskell/regenerate-hackage-packages.sh8
-rwxr-xr-xmaintainers/scripts/haskell/update-hackage.sh10
-rwxr-xr-xmaintainers/scripts/haskell/update-stackage.sh22
3 files changed, 32 insertions, 8 deletions
diff --git a/maintainers/scripts/haskell/regenerate-hackage-packages.sh b/maintainers/scripts/haskell/regenerate-hackage-packages.sh
index a56d8a0a0e2..96131f98fa0 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 a8ad8d9e2ec..3c338e98c64 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 c3be3158b29..b332e8d4dc6 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