Skip to content

Commit 15c012e

Browse files
TECH_DEBT: Fail get_deployed_commit.py when the full hash cannot be resolved
The script warned about an unresolved short hash and then published it anyway. The downstream consumer cannot use it: list-deploy-changes.py fetches both refs with 'git fetch --depth=1 origin <ref>', GitHub rejects unadvertised objects by short SHA, and that fetch discards stderr and ignores its exit code — so the deployment summary came out empty with nothing in the log to explain it. - Replace the short-hash warning with a fail(), reporting the same context on stderr and exiting nonzero - Place it ahead of the FromCommit print and the ##vso[task.setvariable] line, so no unusable value is published This makes the Summarize job fail whenever the GitHub lookup fails for any reason, including a rate limit or transport error, and Deploy is gated on Summarize succeeding. Verified against qa2 that the normal path is unchanged and exits 0. Forced the failure path with an unreachable API host: the warning and the ERROR line are both printed, the exit status is 1, and neither FromCommit nor the ##vso line is emitted.
1 parent b6b550f commit 15c012e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Scripts/get_deployed_commit.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,13 @@ def main():
123123
except Exception as e:
124124
print(f"Warning: Could not resolve full commit hash: {e}", file=sys.stderr)
125125

126-
# A short hash here breaks the downstream fetch in list-deploy-changes.py, which fails
127-
# silently and yields an empty summary. Say so rather than letting it pass unnoticed.
126+
# A short hash breaks the downstream fetch in list-deploy-changes.py: 'git fetch origin
127+
# <ref>' is rejected for anything but a full SHA, and that failure is swallowed, so the
128+
# summary comes out empty with nothing in the log to explain it. Stop here instead of
129+
# publishing a FromCommit that cannot be used.
128130
if len(commit) < 40:
129-
print(f"Warning: '{commit}' is not a full commit hash. "
130-
f"'git fetch origin {commit}' will fail and the deployment summary may be empty.",
131-
file=sys.stderr)
131+
fail(f"'{commit}' is not a full commit hash and could not be resolved to one. "
132+
f"'git fetch origin {commit}' would fail and the deployment summary would be empty.")
132133

133134
print(f"FromCommit: {commit}")
134135

0 commit comments

Comments
 (0)