Skip to content

Commit dcd6553

Browse files
committed
refactor(ng-dev): get the commit rather than the commit sha when getting the latest commit on the branch (#2750)
PR Close #2750
1 parent 54d5678 commit dcd6553

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

ng-dev/release/publish/actions.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {promptToInitiatePullRequestMerge} from './prompt-merge.js';
4343
import {Prompt} from '../../utils/prompt.js';
4444
import {glob} from 'fast-glob';
4545
import {PnpmVersioning} from './pnpm-versioning.js';
46+
import {Commit} from '../../utils/git/octokit-types.js';
4647

4748
/** Interface describing a Github repository. */
4849
export interface GithubRepo {
@@ -150,11 +151,11 @@ export abstract class ReleaseAction {
150151
}
151152

152153
/** Gets the most recent commit of a specified branch. */
153-
protected async getLatestCommitOfBranch(branchName: string): Promise<string> {
154+
protected async getLatestCommitOfBranch(branchName: string): Promise<Commit> {
154155
const {
155156
data: {commit},
156157
} = await this.git.github.repos.getBranch({...this.git.remoteParams, branch: branchName});
157-
return commit.sha;
158+
return commit;
158159
}
159160

160161
/** Checks whether the given revision is ahead to the base by the specified amount. */
@@ -560,7 +561,7 @@ export abstract class ReleaseAction {
560561
// Keep track of the commit where we started the staging process on. This will be used
561562
// later to ensure that no changes, except for the version bump have landed as part
562563
// of the staging time window (where the caretaker could accidentally land other stuff).
563-
const beforeStagingSha = await this.getLatestCommitOfBranch(stagingBranch);
564+
const {sha: beforeStagingSha} = await this.getLatestCommitOfBranch(stagingBranch);
564565

565566
await this.assertPassingGithubStatus(beforeStagingSha, stagingBranch);
566567
await this.checkoutUpstreamBranch(stagingBranch);
@@ -703,7 +704,7 @@ export abstract class ReleaseAction {
703704
npmDistTag: NpmDistTag,
704705
additionalOptions: {showAsLatestOnGitHub: boolean},
705706
) {
706-
const versionBumpCommitSha = await this.getLatestCommitOfBranch(publishBranch);
707+
const {sha: versionBumpCommitSha} = await this.getLatestCommitOfBranch(publishBranch);
707708

708709
// Ensure the latest commit in the publish branch is the bump commit.
709710
if (!(await this._isCommitForVersionStaging(releaseNotes.version, versionBumpCommitSha))) {

ng-dev/release/publish/actions/configure-next-as-major.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class ConfigureNextAsMajorAction extends ReleaseAction {
3333
override async perform() {
3434
const {branchName} = this.active.next;
3535
const newVersion = this._newVersion;
36-
const beforeStagingSha = await this.getLatestCommitOfBranch(branchName);
36+
const {sha: beforeStagingSha} = await this.getLatestCommitOfBranch(branchName);
3737

3838
await this.assertPassingGithubStatus(beforeStagingSha, branchName);
3939
await this.checkoutUpstreamBranch(branchName);

ng-dev/release/publish/actions/exceptional-minor/prepare-exceptional-minor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class PrepareExceptionalMinorAction extends ReleaseAction {
3939
}
4040

4141
async perform(): Promise<void> {
42-
const latestBaseBranchSha = await this.getLatestCommitOfBranch(this._baseBranch);
42+
const {sha: latestBaseBranchSha} = await this.getLatestCommitOfBranch(this._baseBranch);
4343

4444
await this.assertPassingGithubStatus(latestBaseBranchSha, this._baseBranch);
4545

ng-dev/release/publish/actions/shared/branch-off-next-branch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export abstract class BranchOffNextBranchBaseAction extends CutNpmNextPrerelease
5959
const compareVersionForReleaseNotes = await this._computeReleaseNoteCompareVersion();
6060
const newVersion = await this._computeNewVersion();
6161
const newBranch = `${newVersion.major}.${newVersion.minor}.x`;
62-
const beforeStagingSha = await this.getLatestCommitOfBranch(nextBranchName);
62+
const {sha: beforeStagingSha} = await this.getLatestCommitOfBranch(nextBranchName);
6363

6464
// Verify the current next branch has a passing status, before we branch off.
6565
await this.assertPassingGithubStatus(beforeStagingSha, nextBranchName);

ng-dev/utils/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ts_library(
4848
"@npm//@octokit/auth-app",
4949
"@npm//@octokit/core",
5050
"@npm//@octokit/graphql",
51+
"@npm//@octokit/openapi-types",
5152
"@npm//@octokit/plugin-paginate-rest",
5253
"@npm//@octokit/plugin-rest-endpoint-methods",
5354
"@npm//@octokit/request-error",

ng-dev/utils/git/octokit-types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import {components} from '@octokit/openapi-types';
2+
3+
export type Commit = components['schemas']['commit'];

0 commit comments

Comments
 (0)