Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(git): Prevents getLastTagNotInBaseBranch from returning a commit hash #1262

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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