Skip to content

Commit 4eb4a8d

Browse files
author
Tulga Tsogtgerel
committed
fix: pull with rebase before pushing to handle remote changes
- Add git pull --rebase before push to sync with remote branch - Prevents non-fast-forward errors when remote has new commits - Gracefully handles rebase failures and attempts push anyway
1 parent f4f5585 commit 4eb4a8d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

assistant/src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,19 @@ Automatically generated by Auggie Assistant`;
253253

254254
await exec.exec('git', ['commit', '-m', commitMessage]);
255255

256+
// Pull latest changes from remote branch with rebase to avoid conflicts
257+
core.info(`🔄 Pulling latest changes from ${headBranch}...`);
258+
const remoteUrl = `https://x-access-token:${githubToken}@github.com/${owner}/${repo}.git`;
259+
260+
try {
261+
await exec.exec('git', ['pull', '--rebase', remoteUrl, headBranch]);
262+
core.info('✅ Successfully rebased on latest changes');
263+
} catch (error) {
264+
core.warning('Pull with rebase failed, attempting to push anyway');
265+
}
266+
256267
// Push changes
257268
core.info(`🚀 Pushing to ${headBranch}...`);
258-
const remoteUrl = `https://x-access-token:${githubToken}@github.com/${owner}/${repo}.git`;
259269
await exec.exec('git', ['push', remoteUrl, `HEAD:${headBranch}`]);
260270

261271
core.info('✅ Changes committed and pushed successfully');

0 commit comments

Comments
 (0)