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

catch errors when finding tags on next #1402

Merged
merged 1 commit into from
Jul 28, 2020
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
25 changes: 25 additions & 0 deletions packages/core/src/__tests__/auto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,31 @@ describe("Auto", () => {
await auto.next({});
expect(afterRelease).toHaveBeenCalled();
});

test("falls back to first commit when there are no tags", async () => {
const auto = new Auto({ ...defaults, plugins: [] });

// @ts-ignore
auto.checkClean = () => Promise.resolve(true);
auto.logger = dummyLog();
await auto.loadConfig();
auto.remote = "origin";
auto.git!.publish = () => Promise.resolve({} as any);
auto.git!.getLastTagNotInBaseBranch = () => Promise.reject(new Error("Test"));
auto.git!.getLatestTagInBranch = () => Promise.reject(new Error("Test"));
auto.git!.getLatestRelease = () => Promise.resolve("abcd");
auto.release!.generateReleaseNotes = () => Promise.resolve("notes");
auto.release!.getCommitsInRelease = () =>
Promise.resolve([makeCommitFromMsg("Test Commit")]);

const afterRelease = jest.fn();
auto.hooks.afterRelease.tap("test", afterRelease);
auto.hooks.next.tap("test", () => ["1.2.4-next.0"]);
jest.spyOn(auto.release!, "getCommits").mockImplementation();

await auto.next({});
expect(afterRelease).toHaveBeenCalled();
});
});

describe("shipit", () => {
Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1279,10 +1279,18 @@ export default class Auto {
);
const lastRelease =
initialForkCommit || (await this.git.getLatestRelease());

const [, lastTagNotInBaseBranch] = await on(
this.git.getLastTagNotInBaseBranch(currentBranch!)
);
const [, latestTagInBranch] = await on(
this.git.getLatestTagInBranch(currentBranch)
);
const lastTag =
(await this.git.getLastTagNotInBaseBranch(currentBranch!)) ||
(await this.git.getLatestTagInBranch(currentBranch)) ||
lastTagNotInBaseBranch ||
latestTagInBranch ||
(await this.git.getFirstCommit());

const fullReleaseNotes = await this.release.generateReleaseNotes(
lastRelease
);
Expand Down