MCPcopy Create free account
hub / github.com/angular/dev-infra / _pushHeadToFork

Function _pushHeadToFork

ng-dev/release/publish/actions.ts:318–340  ·  view source on GitHub ↗

* Pushes the current Git `HEAD` to a fork for the configured project that is owned by * the authenticated user. If the specified branch name exists in the fork already, a * unique one will be generated based on the proposed name to avoid collisions. * @param proposedBranchName Proposed bran

(
    proposedBranchName: string,
    trackLocalBranch: boolean,
  )

Source from the content-addressed store, hash-verified

316 * @returns The fork and branch name containing the pushed changes.
317 */
318 private async _pushHeadToFork(
319 proposedBranchName: string,
320 trackLocalBranch: boolean,
321 ): Promise<{fork: GithubRepo; branchName: string}> {
322 const fork = await this._getForkOfAuthenticatedUser();
323 // Compute a repository URL for pushing to the fork. Note that we want to respect
324 // the SSH option from the dev-infra github configuration.
325 const repoGitUrl = getRepositoryGitUrl(
326 {...fork, useSsh: this.git.remoteConfig.useSsh},
327 this.git.githubToken,
328 );
329 const branchName = await this._findAvailableBranchName(fork, proposedBranchName);
330 const pushArgs: string[] = [];
331 // If a local branch should track the remote fork branch, create a branch matching
332 // the remote branch. Later with the `git push`, the remote is set for the branch.
333 if (trackLocalBranch) {
334 await this.createLocalBranchFromHead(branchName);
335 pushArgs.push('--set-upstream');
336 }
337 // Push the local `HEAD` to the remote branch in the fork.
338 this.git.run(['push', '-q', repoGitUrl, `HEAD:refs/heads/${branchName}`, ...pushArgs]);
339 return {fork, branchName};
340 }
341
342 /**
343 * Pushes changes to a fork for the configured project that is owned by the currently

Callers

nothing calls this directly

Calls 3

getRepositoryGitUrlFunction · 0.85
pushMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected