Skip to content

Commit 19d12a6

Browse files
committed
Make sync-pr.sh script more resilient
Now it can be run with nixfmt URLs that have any casing. This was really annoying when I tried to debug CI using ./sync-pr.sh https://github.com/nixos/nixfmt 196 https://github.com/NixOS/nixpkgs until I realised that CI used https://github.com/NixOS/nixfmt with a cased "NixOS"!
1 parent 34d3084 commit 19d12a6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scripts/sync-pr.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,12 @@ else
181181
echo "Checking whether commit with index $(( nixpkgsCommitCount + 1 )) ($nixpkgsCommit) in nixpkgs corresponds to commit with index $nixpkgsCommitCount ($nixfmtCommit) in nixfmt"
182182

183183
# We generate the bodies of the commits to contain the nixfmt commit so we can check against it here to verify it's the same
184-
body=$(git -C nixpkgs.git log -1 "$nixpkgsCommit" --pretty=%B)
185-
expectedBody=$(bodyForCommitIndex "$nixpkgsCommitCount")
186-
if [[ "$body" == "$expectedBody" ]]; then
184+
# Note that `--format=format:` makes it so that there's no extra newline
185+
git -C nixpkgs.git log -1 "$nixpkgsCommit" --format=format:%B > "$tmp/body"
186+
bodyForCommitIndex "$nixpkgsCommitCount" > "$tmp/expected-body"
187+
188+
# Ignore case so that we don't need to be worried about things like NixOS vs nixos in the URL
189+
if diff --ignore-case "$tmp/body" "$tmp/expected-body"; then
187190
echo "It does!"
188191
else
189192
echo "It does not, this indicates a force push was done"

0 commit comments

Comments
 (0)