Skip to content

Commit d64cca4

Browse files
committed
Rename determineMergeBaseCommitOid()
The name suggests that the function computes the merge base, which for Git means specifically the best common ancestors between multiple commits or branches (see `git merge-base`). But what the function actually does is to calculate the HEAD commit of the PR base branch, as derived from the PR merge commit that the action analyzes. So even though the function has to do with "merge" and "base", using the term "merge base" is still misleading at best. This commit renames the function to determineBaseBranchHeadCommitOid(), which more clearly indicates what the function does.
1 parent 955d001 commit d64cca4

9 files changed

+29
-25
lines changed

lib/actions-util.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.test.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions-util.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,26 +269,26 @@ test("isAnalyzingDefaultBranch()", async (t) => {
269269
});
270270
});
271271

272-
test("determineMergeBaseCommitOid non-pullrequest", async (t) => {
272+
test("determineBaseBranchHeadCommitOid non-pullrequest", async (t) => {
273273
const infoStub = sinon.stub(core, "info");
274274

275275
process.env["GITHUB_EVENT_NAME"] = "hucairz";
276276
process.env["GITHUB_SHA"] = "100912429fab4cb230e66ffb11e738ac5194e73a";
277-
const result = await actionsUtil.determineMergeBaseCommitOid(__dirname);
277+
const result = await actionsUtil.determineBaseBranchHeadCommitOid(__dirname);
278278
t.deepEqual(result, undefined);
279279
t.deepEqual(0, infoStub.callCount);
280280

281281
infoStub.restore();
282282
});
283283

284-
test("determineMergeBaseCommitOid not git repository", async (t) => {
284+
test("determineBaseBranchHeadCommitOid not git repository", async (t) => {
285285
const infoStub = sinon.stub(core, "info");
286286

287287
process.env["GITHUB_EVENT_NAME"] = "pull_request";
288288
process.env["GITHUB_SHA"] = "100912429fab4cb230e66ffb11e738ac5194e73a";
289289

290290
await withTmpDir(async (tmpDir) => {
291-
await actionsUtil.determineMergeBaseCommitOid(tmpDir);
291+
await actionsUtil.determineBaseBranchHeadCommitOid(tmpDir);
292292
});
293293

294294
t.deepEqual(1, infoStub.callCount);
@@ -301,12 +301,12 @@ test("determineMergeBaseCommitOid not git repository", async (t) => {
301301
infoStub.restore();
302302
});
303303

304-
test("determineMergeBaseCommitOid other error", async (t) => {
304+
test("determineBaseBranchHeadCommitOid other error", async (t) => {
305305
const infoStub = sinon.stub(core, "info");
306306

307307
process.env["GITHUB_EVENT_NAME"] = "pull_request";
308308
process.env["GITHUB_SHA"] = "100912429fab4cb230e66ffb11e738ac5194e73a";
309-
const result = await actionsUtil.determineMergeBaseCommitOid(
309+
const result = await actionsUtil.determineBaseBranchHeadCommitOid(
310310
path.join(__dirname, "../../i-dont-exist"),
311311
);
312312
t.deepEqual(result, undefined);

src/actions-util.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ export const getCommitOid = async function (
108108
};
109109

110110
/**
111-
* If the action was triggered by a pull request, determine the commit sha of the merge base.
112-
* Returns undefined if run by other triggers or the merge base cannot be determined.
111+
* If the action was triggered by a pull request, determine the commit sha at
112+
* the head of the base branch, using the merge commit that this workflow analyzes.
113+
* Returns undefined if run by other triggers or the base branch commit cannot be
114+
* determined.
113115
*/
114-
export const determineMergeBaseCommitOid = async function (
116+
export const determineBaseBranchHeadCommitOid = async function (
115117
checkoutPathOverride?: string,
116118
): Promise<string | undefined> {
117119
if (getWorkflowEventName() !== "pull_request") {

src/upload-lib.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ export async function uploadFiles(
609609
checkoutURI,
610610
environment,
611611
toolNames,
612-
await actionsUtil.determineMergeBaseCommitOid(),
612+
await actionsUtil.determineBaseBranchHeadCommitOid(),
613613
);
614614

615615
// Log some useful debug info about the info

0 commit comments

Comments
 (0)