Skip to content

Commit

Permalink
fix(git): Prevents getLastTagNotInBaseBranch from returning a commit …
Browse files Browse the repository at this point in the history
…hash
  • Loading branch information
10hendersonm committed May 28, 2020
1 parent 9a3c656 commit 3f87c8a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
8 changes: 0 additions & 8 deletions packages/core/src/__tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,6 @@ describe("github", () => {
});

describe("getTagNotInBaseBranch", () => {
test("works with no tags, defaults to first commit", async () => {
const gh = new Git(options);
gh.getTags = () => Promise.resolve([]);
expect(await gh.getTagNotInBaseBranch("branch")).toBe(
"0b2af75d8b55c8869cda93d0e5589ad9f2677e18"
);
});

test("finds greatest tag not in base branch", async () => {
const gh = new Git(options);

Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,9 @@ export default class Auto {
).slice(1);
const lastRelease =
initialForkCommit || (await this.git.getLatestRelease());
const lastTag = await this.git.getLastTagNotInBaseBranch(currentBranch!);
const lastTag =
(await this.git.getLastTagNotInBaseBranch(currentBranch!)) ||
(await this.git.getFirstCommit());
const fullReleaseNotes = await this.release.generateReleaseNotes(
lastRelease
);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,10 +870,10 @@ export default class Git {
this.logger.verbose.info("Tags found in branch:", branchTags);
this.logger.verbose.info(
`${options.first ? "First" : "Latest"} tag in branch:`,
firstGreatestUnique
firstGreatestUnique || "Not Found"
);

return firstGreatestUnique || this.getFirstCommit();
return firstGreatestUnique;
}

/** Get the last tag that isn't in the base branch */
Expand Down

0 comments on commit 3f87c8a

Please sign in to comment.