Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 ng-dev/pr/common/checkout-pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export async function checkOutPullRequestLocally(
// https://git-scm.com/docs/git-push#Documentation/git-push.txt---force-with-leaseltrefnamegtltexpectgt
/** Flag for a force push with lease back to upstream. */
const forceWithLeaseFlag = `--force-with-lease=${headRefName}:${pr.headRefOid}`;
const escapedHeadRefName = `'${headRefName.replace(/'/g, "'\\''")}'`;
const escapedForceWithLeaseFlag = `--force-with-lease=${escapedHeadRefName}:${pr.headRefOid}`;
Comment thread
josephperrott marked this conversation as resolved.

// If the PR does not allow maintainers to modify it, exit as the rebased PR cannot
// be pushed up.
Expand Down Expand Up @@ -130,7 +132,7 @@ export async function checkOutPullRequestLocally(
resetGitState: (): boolean => {
return git.checkout(previousBranchOrRevision, true);
},
pushToUpstreamCommand: `git push ${upstreamUrlToPush(pr.headRef.repository.url)} HEAD:${headRefName} ${forceWithLeaseFlag}`,
pushToUpstreamCommand: `git push ${upstreamUrlToPush(pr.headRef.repository.url)} HEAD:${escapedHeadRefName} ${escapedForceWithLeaseFlag}`,
Comment thread
josephperrott marked this conversation as resolved.
resetGitStateCommand: `git rebase --abort && git reset --hard && git checkout ${previousBranchOrRevision}`,
pullRequest: pr,
};
Expand Down
6 changes: 5 additions & 1 deletion ng-dev/pr/rebase/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export async function rebasePr(prNumber: number, interactive: boolean = false):
// See:
// https://git-scm.com/docs/git-push#Documentation/git-push.txt---force-with-leaseltrefnamegtltexpectgt
const forceWithLeaseFlag = `--force-with-lease=${headRefName}:${pr.headRefOid}`;
const escapedHeadRefName = `'${headRefName.replace(/'/g, "'\\''")}'`;
const escapedForceWithLeaseFlag = `--force-with-lease=${escapedHeadRefName}:${pr.headRefOid}`;
Comment thread
josephperrott marked this conversation as resolved.

// If the PR does not allow maintainers to modify it, exit as the rebased PR cannot
// be pushed up.
Expand Down Expand Up @@ -143,7 +145,9 @@ export async function rebasePr(prNumber: number, interactive: boolean = false):
Log.info(
`After manually completing rebase, run the following command to update PR #${prNumber}:`,
);
Log.info(` $ git push ${pr.headRef.repository.url} HEAD:${headRefName} ${forceWithLeaseFlag}`);
Log.info(
` $ git push ${pr.headRef.repository.url} HEAD:${escapedHeadRefName} ${escapedForceWithLeaseFlag}`,
);
Comment thread
josephperrott marked this conversation as resolved.
Log.info();
Log.info(`To abort the rebase and return to the state of the repository before this command`);
Log.info(`run the following command:`);
Expand Down
Loading