Skip to content

Commit 5e3bbc4

Browse files
authored
tools: fix Nix diff tools when pushing more than 1 commit
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #66383 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d7ea02d commit 5e3bbc4

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎.github/workflows/nix-changes.yml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,16 @@ jobs:
6868

6969
- name: Compute requisites before change
7070
run: |
71-
git reset HEAD^ --hard
72-
# TODO(aduh95): remove this once list-requisites.sh has reached `main`
73-
[ -f tools/nix/list-requisites.sh ] || git checkout FETCH_HEAD -- tools/nix/list-requisites.sh
71+
BASE_SHA="$(git rev-parse HEAD^)"
72+
if [ -n "$PUSH_BEFORE_SHA" ] && [ "$PUSH_BEFORE_SHA" != "$BASE_SHA" ] \
73+
&& [ "$PUSH_BEFORE_SHA" != "0000000000000000000000000000000000000000" ] \
74+
&& git fetch --no-tags --depth=1 origin "$PUSH_BEFORE_SHA"; then
75+
BASE_SHA="$PUSH_BEFORE_SHA"
76+
fi
77+
git reset "$BASE_SHA" --hard
7478
./tools/nix/list-requisites.sh > requisites-${{ matrix.system }}-before.list
79+
env:
80+
PUSH_BEFORE_SHA: ${{ github.event_name == 'push' && github.event.before || '' }}
7581

7682
- name: Output diff
7783
run: |

0 commit comments

Comments
 (0)