Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .github/workflows/fetch-licenses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ jobs:
- name: Checkout this repository
uses: actions/checkout@v6

- name: Determine baseline branch for diffs
id: baseline
run: |
set -euo pipefail

if git ls-remote --exit-code --heads origin auto-update-licenses >/dev/null 2>&1; then
echo "Update Licenses PR exists, so diff against its branch origin/auto-update-licenses."
base_ref="origin/auto-update-licenses"
else
echo "Update Licenses PR does NOT exists, so diff against branch origin/main"
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a grammatical error in this echo message. The word "exists" should be singular here, not "does NOT exists". It should be "does NOT exist".

Suggested change
echo "Update Licenses PR does NOT exists, so diff against branch origin/main"
echo "Update Licenses PR does NOT exist, so diff against branch origin/main"

Copilot uses AI. Check for mistakes.
base_ref="origin/main"
fi

echo "BASE_REF=$base_ref" >> "$GITHUB_ENV"
echo "Baseline ref: $base_ref"

- name: Checkout official SPDX Repository
uses: actions/checkout@v6
with:
Expand All @@ -46,7 +62,7 @@ jobs:
run: |
src_changed=true
# --quiet: Exits with 1 if there are changes; otherwise, exits with 0
git diff --quiet -- cmd/licenses.json cmd/exceptions.json && src_changed=false
git diff --quiet "$BASE_REF" -- cmd/licenses.json cmd/exceptions.json && src_changed=false
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The git diff command is comparing against a remote branch reference (origin/auto-update-licenses or origin/main), but the workflow only performs a checkout without fetching the remote branch first. When actions/checkout@v6 runs, it only fetches the current branch by default. This means that origin/auto-update-licenses may not be available locally for the diff command to use, which could cause the diff to fail or behave unexpectedly. Consider adding a fetch step after determining the baseline branch, or ensure that the baseline branch is fetched before performing the diff operations.

This issue also appears in the following locations of the same file:

  • line 90

Copilot uses AI. Check for mistakes.
if [ $src_changed != 'true' ]; then
if [ ${{ github.event.inputs.force_run }} == 'true' ]; then
echo -e '***************\nNo changes in spdx json, but skipping abort due to force run\n***************'
Expand All @@ -61,7 +77,7 @@ jobs:
if: ${{ env.SRC_CHANGED == 'true' || github.event.inputs.force_run == 'true' }}
run: |
cd cmd
echo "Current branch: $(git branch)"
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
go run . extract -l -e
cd ..
git log --oneline -n 5
Expand All @@ -71,7 +87,7 @@ jobs:
run: |
genfiles_changed=true
# --quiet: Exits with 1 if there are changes; otherwise, exits with 0
git diff --quiet -- spdxexp/spdxlicenses/*.go && genfiles_changed=false
git diff --quiet "$BASE_REF" -- spdxexp/spdxlicenses/*.go && genfiles_changed=false
if [ $genfiles_changed != 'true' ]; then
if [ ${{ github.event.inputs.force_run }} == 'true' ]; then
echo -e '***************\nNo changes to generated files, but skipping abort due to force run\n***************'
Expand All @@ -84,7 +100,7 @@ jobs:
fi
echo "GENFILES_CHANGED=$genfiles_changed" >> $GITHUB_ENV

- name: Create Pull Request
- name: Create/Update Pull Request
if: ${{ env.GENFILES_CHANGED == 'true' || github.event.inputs.force_run == 'true' }}
uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412
with:
Expand Down