Skip to content

Commit e4a7c88

Browse files
dsymeCopilotCopilot
authored
🛠️ Improve error messaging for branch sync failure (#23155)
* improve message * Update actions/setup/js/extra_empty_commit.cjs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * commit * fix: update test to expect core.warning instead of core.info for sync failure Agent-Logs-Url: https://github.com/github/gh-aw/sessions/dbb38263-3c2a-480d-acfe-977413337ce6 Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
1 parent 019c373 commit e4a7c88

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

actions/setup/js/extra_empty_commit.cjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,11 @@ async function pushExtraEmptyCommit({ branchName, repoOwner, repoName, commitMes
147147
try {
148148
await exec.exec("git", ["fetch", "ci-trigger", branchName]);
149149
await exec.exec("git", ["reset", "--hard", `ci-trigger/${branchName}`]);
150-
} catch {
150+
} catch (error) {
151151
// Non-fatal: if fetch/reset fails (e.g. branch not yet on remote), continue
152152
// with the local HEAD and attempt the push anyway.
153-
core.info(`Could not sync local branch with remote ${branchName} - will attempt push with local HEAD`);
153+
const syncErrorMessage = error instanceof Error ? error.message : String(error);
154+
core.warning(`Could not sync local branch with remote ${branchName} - will attempt push with local HEAD. Underlying error: ${syncErrorMessage}`);
154155
}
155156

156157
// Create and push an empty commit

actions/setup/js/extra_empty_commit.test.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ describe("extra_empty_commit.cjs", () => {
222222

223223
// Push should still be attempted and succeed (mock returns 0 for push)
224224
expect(result).toEqual({ success: true });
225-
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("Could not sync local branch"));
225+
expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("Could not sync local branch"));
226226

227227
// commit and push should still have been called
228228
const commitCall = mockExec.exec.mock.calls.find(c => c[0] === "git" && c[1] && c[1][0] === "commit");

0 commit comments

Comments
 (0)