Skip to content
Merged
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion development/master-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ async function runGitCommands() {
console.log('Executed: git commit');

console.log('Your local master-sync branch is now ready to become a PR.');
console.log('You likely now need to do `git push --force`');
console.log(
'You likely now need to do `git push --set-upstream origin master-sync`',
);
Copy link
Contributor

@MajorLift MajorLift Jul 17, 2025

Choose a reason for hiding this comment

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

Maybe we should execute the set-upstream-to step in the script since in this new command sequence it's always necessary?

It might be better to leave the forced push message as well, since there might be unexpected cases where a master-sync branch is already present and it's diverged from main, requiring a hard reset. We could provide guidance for the git push --force step but leave its execution to the user's discretion.

Suggested change
console.log(
'You likely now need to do `git push --set-upstream origin master-sync`',
);
await exec('git branch --set-upstream-to=origin/master-sync');
console.log('Executed: git branch --set-upstream-to');
console.log('You now need to run `git push`. If this fails, try `git push --force`');

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait this wouldn't work if master-sync doesn't already exist.
Is there anything preventing us from simply doing the following? The script already runs remote hard resets, and master-sync is intended to be a temporary branch.

Suggested change
console.log(
'You likely now need to do `git push --set-upstream origin master-sync`',
);
await exec('git push --force --set-upstream origin master-sync');
console.log('Executed: git push');

Copy link
Contributor

Choose a reason for hiding this comment

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

Another marginally safer option:

Suggested change
console.log(
'You likely now need to do `git push --set-upstream origin master-sync`',
);
await exec('git push --force-if-includes --set-upstream origin master-sync');
console.log('Executed: git push');
console.log(
'If the previous command failed, you may need to run `git push --force`.',
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestions! I went with --force-if-includes as it's the safest option that still automates the push step. Since master-sync is a temporary branch that gets hard reset anyway, this approach prevents accidentally overwriting unexpected changes while eliminating the manual push step.

The script now handles the complete workflow automatically. Thanks for the feedback! 💟 80501a9

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little bit worried about edge cases where the push fails. A message to force push if that happens would be nice to have, but also the command should almost never fail since the script runs git fetch at the start. The script should work well as is.

} catch (error) {
console.error(`Error: ${error.message}`);
process.exit(1);
Expand Down
Loading