From fc86247ce8a3b78a2d76dc29bf41d404c7ab8184 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 16 Apr 2026 15:17:56 +0900 Subject: [PATCH 1/3] Use git ls-remote instead of git tag -l for tag existence check --- .github/scripts/update_dependency_changes.py | 6 +++--- .../workflows/nuget-packages-version-change-detector.yml | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/scripts/update_dependency_changes.py b/.github/scripts/update_dependency_changes.py index 02ab623ff8..060e945486 100644 --- a/.github/scripts/update_dependency_changes.py +++ b/.github/scripts/update_dependency_changes.py @@ -26,13 +26,13 @@ def normalize_version(version): def check_tag_exists(tag): - """Check if a git tag exists.""" + """Check if a git tag exists on the remote.""" result = subprocess.run( - ["git", "tag", "-l", tag], + ["git", "ls-remote", "--tags", "origin", tag], capture_output=True, text=True, ) - return result.returncode == 0 and tag in result.stdout.strip().split("\n") + return result.returncode == 0 and result.stdout.strip() != "" def bump_patch_if_released(version, tag_exists_fn=None): diff --git a/.github/workflows/nuget-packages-version-change-detector.yml b/.github/workflows/nuget-packages-version-change-detector.yml index 4ed7fad8de..45dba3332b 100644 --- a/.github/workflows/nuget-packages-version-change-detector.yml +++ b/.github/workflows/nuget-packages-version-change-detector.yml @@ -44,10 +44,8 @@ jobs: ref: ${{ github.event.pull_request.head.ref }} fetch-depth: 1 - - name: Fetch base branch and tags - run: | - git fetch origin ${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }} --depth=1 - git fetch --tags origin + - name: Fetch base branch + run: git fetch origin ${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }} --depth=1 - uses: actions/setup-python@v5 with: From d9672968d43918a1b825e30e348c873d0f392979 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 16 Apr 2026 15:23:21 +0900 Subject: [PATCH 2/3] Use exact ref path and --exit-code for git ls-remote tag check --- .github/scripts/update_dependency_changes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/update_dependency_changes.py b/.github/scripts/update_dependency_changes.py index 060e945486..0f47d97d5f 100644 --- a/.github/scripts/update_dependency_changes.py +++ b/.github/scripts/update_dependency_changes.py @@ -28,11 +28,11 @@ def normalize_version(version): def check_tag_exists(tag): """Check if a git tag exists on the remote.""" result = subprocess.run( - ["git", "ls-remote", "--tags", "origin", tag], + ["git", "ls-remote", "--exit-code", "--tags", "origin", f"refs/tags/{tag}"], capture_output=True, text=True, ) - return result.returncode == 0 and result.stdout.strip() != "" + return result.returncode == 0 def bump_patch_if_released(version, tag_exists_fn=None): From 06e1d551d244c58d45b2f63304ff5542f497c3f0 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 16 Apr 2026 15:27:33 +0900 Subject: [PATCH 3/3] Handle git ls-remote error codes explicitly --- .github/scripts/update_dependency_changes.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/scripts/update_dependency_changes.py b/.github/scripts/update_dependency_changes.py index 0f47d97d5f..9f39850084 100644 --- a/.github/scripts/update_dependency_changes.py +++ b/.github/scripts/update_dependency_changes.py @@ -32,7 +32,16 @@ def check_tag_exists(tag): capture_output=True, text=True, ) - return result.returncode == 0 + if result.returncode == 0: + return True + if result.returncode == 2: + return False + + stderr = (result.stderr or "").strip() + raise RuntimeError( + f"Failed to check whether git tag '{tag}' exists on remote 'origin' " + f"(exit code {result.returncode}): {stderr or 'No error output provided.'}" + ) def bump_patch_if_released(version, tag_exists_fn=None):