Skip to content

Commit 511c2b3

Browse files
committed
fix(ng-dev): properly use the fork of the user when updating yarn (#1005)
In the yarn update tool properly discover and use the fork of the user rather than assuming origin. PR Close #1005
1 parent 0e1bb89 commit 511c2b3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ng-dev/misc/update-yarn/cli.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {Spinner} from '../../utils/spinner.js';
1616
import {AuthenticatedGitClient} from '../../utils/git/authenticated-git-client.js';
1717
import {addGithubTokenOption} from '../../utils/git/github-yargs.js';
1818
import {getYarnPathFromNpmGlobalBinaries} from '../../utils/resolve-yarn-bin.js';
19+
import {getRepositoryGitUrl} from '../../utils/git/github-urls.js';
1920

2021
async function builder(argv: Argv) {
2122
return addGithubTokenOption(argv);
@@ -91,15 +92,23 @@ async function handler() {
9192
const commitMessage = `${title}\n\n${body}`;
9293
/** The name of the branch to use on remote. */
9394
const branchName = `yarn-update-v${newYarnVersion}`;
95+
/** The fork of the user */
96+
const userFork = await git.getForkOfAuthenticatedUser();
9497
/** The name of the owner for remote branch on Github. */
95-
const {owner: localOwner} = await git.getForkOfAuthenticatedUser();
98+
const {owner: localOwner} = userFork;
9699

97100
spinner.update('Staging yarn vendoring files and creating commit');
98101
git.run(['add', '.yarn/releases/**', '.yarnrc']);
99102
git.run(['commit', '-q', '--no-verify', '-m', commitMessage], {env: skipHuskyEnv});
100103

101104
spinner.update('Pushing commit changes to github.');
102-
git.run(['push', '-q', 'origin', '--force-with-lease', `HEAD:refs/heads/${branchName}`]);
105+
git.run([
106+
'push',
107+
'-q',
108+
getRepositoryGitUrl(userFork, git.githubToken),
109+
'--force-with-lease',
110+
`HEAD:refs/heads/${branchName}`,
111+
]);
103112

104113
spinner.update('Creating a PR for the changes.');
105114
const {number} = (

0 commit comments

Comments
 (0)