diff --git a/.github/workflows/pr-governance.yml b/.github/workflows/pr-governance.yml index 5c62f146..088687d9 100644 --- a/.github/workflows/pr-governance.yml +++ b/.github/workflows/pr-governance.yml @@ -53,13 +53,12 @@ jobs: ).stdout old_shas, new_shas = [], [] for line in raw.splitlines(): - parts = line.split("\t")[0].split() meta, _path = line.split("\t", 1) + # git diff --raw header: :oldmode newmode oldsha newsha status cols = meta.split() - # mode 160000 marks a gitlink change; columns: src dst mode status - if len(cols) >= 5 and cols[2] == "160000": - old_shas.append(cols[3].lstrip(":")) - new_shas.append(cols[4]) + if len(cols) >= 5 and cols[1] == "160000": + old_shas.append(cols[2]) + new_shas.append(cols[3]) context = { "target_branch": os.environ.get("TARGET_BRANCH", ""), "labels": [x.strip() for x in os.environ.get("PR_LABELS", "").split(",") if x.strip()], diff --git a/.github/workflows/submodule-tests.yml b/.github/workflows/submodule-tests.yml index 0329de68..c39c2052 100644 --- a/.github/workflows/submodule-tests.yml +++ b/.github/workflows/submodule-tests.yml @@ -40,7 +40,9 @@ jobs: echo "changed<> "$GITHUB_OUTPUT" echo "$CHANGED" >> "$GITHUB_OUTPUT" echo "EOF" >> "$GITHUB_OUTPUT" - GITLINKS=$(git diff --raw "$BASE_SHA..$HEAD_SHA" | awk '$4 ~ /160000/' | wc -l | tr -d ' ') + # git diff --raw header is ":oldmode newmode oldsha newsha status"; + # gitlinks are marked by mode 160000, which awk sees as $1/$2. + GITLINKS=$(git diff --raw "$BASE_SHA..$HEAD_SHA" | awk '$2 == "160000"' | wc -l | tr -d ' ') echo "count=$GITLINKS" >> "$GITHUB_OUTPUT" - name: Full submodule validation