Skip to content

Commit

Permalink
fix(ng-dev): set _ as the username in the URL when creating authent…
Browse files Browse the repository at this point in the history
…icated git URLs

Github requires that both the username and password values are provided when setting a
remote as an authenticated URL.

Previously we did not see any issues with how we set authentication for because all usages of our tooling
was performed in an environment that already had authentication set up, so if the authentication didn't
work via the remote url, git just used the git cached credentials.
  • Loading branch information
josephperrott authored and angular-robot committed Sep 2, 2021
1 parent c4dabf8 commit 3295ba3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions github-actions/slash-commands/main.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ng-dev/utils/git/github-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const GITHUB_TOKEN_GENERATE_URL = 'https://github.com/settings/tokens/new
/** Adds the provided token to the given Github HTTPs remote url. */
export function addTokenToGitHttpsUrl(githubHttpsUrl: string, token: string) {
const url = new URL(githubHttpsUrl);
url.username = token;
url.password = token;
url.username = '_';
return url.href;
}

Expand Down
4 changes: 2 additions & 2 deletions ng-dev/utils/testing/virtual-git-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export function getBranchPushMatcher(options: BranchPushMatchParameters) {
const {targetRepo, targetBranch, baseBranch, baseRepo, expectedCommits} = options;
return jasmine.objectContaining({
remote: {
repoUrl: `https://[email protected]/${targetRepo.owner}/${targetRepo.name}.git`,
repoUrl: `https://_:[email protected]/${targetRepo.owner}/${targetRepo.name}.git`,
name: `refs/heads/${targetBranch}`,
},
head: jasmine.objectContaining({
newCommits: expectedCommits,
ref: {
repoUrl: `https://[email protected]/${baseRepo.owner}/${baseRepo.name}.git`,
repoUrl: `https://_:[email protected]/${baseRepo.owner}/${baseRepo.name}.git`,
name: baseBranch,
},
}),
Expand Down

0 comments on commit 3295ba3

Please sign in to comment.