Skip to content

Commit

Permalink
Merge pull request #1115 from intuit/gitlog
Browse files Browse the repository at this point in the history
include first commit in changelogs
  • Loading branch information
hipstersmoothie authored Apr 5, 2020
2 parents b849543 + 5e5cad2 commit 0a38701
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 17 deletions.
84 changes: 69 additions & 15 deletions packages/core/src/__tests__/__snapshots__/git.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`github getGitLog 1`] = `
Array [
Object {
"authorEmail": "lisowski54@gmail.com",
"authorName": "Andrew Lisowski",
"files": Array [
"<PROJECT_ROOT>/src/__tests__/git.test.ts",
],
"hash": "a7f6634429731055a5a44bae24ac88c5f9822e58",
"subject": "update tests
",
},
]
`;

exports[`github getGitLog - merge commits 1`] = `
Object {
"authorEmail": "lisowski54@gmail.com",
Expand All @@ -32,3 +17,72 @@ Object {
determine if branch behind remote and exit before trying to publish",
}
`;

exports[`github getGitLog 1`] = `
Array [
Object {
"authorEmail": "lisowski54@gmail.com",
"authorName": "Andrew Lisowski",
"files": Array [
"<PROJECT_ROOT>/src/__tests__/git.test.ts",
],
"hash": "a7f6634429731055a5a44bae24ac88c5f9822e58",
"subject": "update tests
",
},
Object {
"authorEmail": "lisowski54@gmail.com",
"authorName": "Andrew Lisowski",
"files": Array [
"<PROJECT_ROOT>/.circleci/config.yml",
"<PROJECT_ROOT>/.gitignore",
"<PROJECT_ROOT>/.vscode/settings.json",
"<PROJECT_ROOT>/CHANGELOG.md",
"<PROJECT_ROOT>/LICENSE",
"<PROJECT_ROOT>/README.md",
"<PROJECT_ROOT>/package.json",
"<PROJECT_ROOT>/scripts/post-install.sh",
"<PROJECT_ROOT>/scripts/release.sh",
"<PROJECT_ROOT>/src/__tests__/__snapshots__/git.test.ts.snap",
"<PROJECT_ROOT>/src/__tests__/__snapshots__/log-parse.test.ts.snap",
"<PROJECT_ROOT>/src/__tests__/__snapshots__/main.test.ts.snap",
"<PROJECT_ROOT>/src/__tests__/git-changed-packages.test.ts",
"<PROJECT_ROOT>/src/__tests__/git.test.ts",
"<PROJECT_ROOT>/src/__tests__/github-responses/bad-credentials.json",
"<PROJECT_ROOT>/src/__tests__/github-responses/pr-labels.json",
"<PROJECT_ROOT>/src/__tests__/log-parse.test.ts",
"<PROJECT_ROOT>/src/__tests__/main.test.ts",
"<PROJECT_ROOT>/src/__tests__/make-commit-from-msg.ts",
"<PROJECT_ROOT>/src/__tests__/semver.test.ts",
"<PROJECT_ROOT>/src/auto-rc.json",
"<PROJECT_ROOT>/src/bin/__tests__/bin.test.ts",
"<PROJECT_ROOT>/src/bin/auto.ts",
"<PROJECT_ROOT>/src/cli/__tests__/args.test.ts",
"<PROJECT_ROOT>/src/cli/args.ts",
"<PROJECT_ROOT>/src/git.ts",
"<PROJECT_ROOT>/src/log-parse.ts",
"<PROJECT_ROOT>/src/main.ts",
"<PROJECT_ROOT>/src/semver.ts",
"<PROJECT_ROOT>/src/types/parse-git.d.ts",
"<PROJECT_ROOT>/src/types/registry-url.d.ts",
"<PROJECT_ROOT>/src/utils/__tests__/__snapshots__/slack.test.ts.snap",
"<PROJECT_ROOT>/src/utils/__tests__/exec-promise.test.ts",
"<PROJECT_ROOT>/src/utils/__tests__/github-token.test.ts",
"<PROJECT_ROOT>/src/utils/__tests__/package-config.test.ts",
"<PROJECT_ROOT>/src/utils/__tests__/slack.test.ts",
"<PROJECT_ROOT>/src/utils/exec-promise.ts",
"<PROJECT_ROOT>/src/utils/github-token.ts",
"<PROJECT_ROOT>/src/utils/logger.ts",
"<PROJECT_ROOT>/src/utils/package-config.ts",
"<PROJECT_ROOT>/src/utils/slack.ts",
"<PROJECT_ROOT>/tsconfig.build.json",
"<PROJECT_ROOT>/tsconfig.json",
"<PROJECT_ROOT>/tslint.json",
"<PROJECT_ROOT>/yarn.lock",
],
"hash": "0b2af75d8b55c8869cda93d0e5589ad9f2677e18",
"subject": "init
",
},
]
`;
2 changes: 1 addition & 1 deletion packages/core/src/__tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe("github", () => {
expect(await gh.getLastTagNotInBaseBranch("alpha")).toBe("0.4.0-alpha.1");
});

test("getGitLog ", async () => {
test("getGitLog", async () => {
const gh = new Git(options);

expect(
Expand Down
13 changes: 12 additions & 1 deletion packages/core/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,21 @@ export default class Git {
@memoize()
async getGitLog(start: string, end = "HEAD"): Promise<ICommit[]> {
try {
const first = await this.getFirstCommit();
// This "shaExists" is just so we don't have to refactor all the tests
// in auto.test.ts. If the SHA doesn't really exist then the call to
// gitlog will fail too.
const startSha = (await this.shaExists(start))
? await execPromise("git", ["rev-parse", start])
: "";

const log = await gitlog<ICommit>({
repo: process.cwd(),
number: Number.MAX_SAFE_INTEGER,
fields: ["hash", "authorName", "authorEmail", "rawBody"],
branch: `${start.trim()}..${end.trim()}`,
// If start === firstCommit then we want to include that commit in the changelog
// Otherwise it was that last release and should not be included in the release.
branch: first === startSha ? end : `${start.trim()}..${end.trim()}`,
execOptions: { maxBuffer: 1000 * 1024 },
});

Expand All @@ -334,6 +344,7 @@ export default class Git {
files: (commit.files || []).map((file) => path.resolve(file)),
}));
} catch (error) {
console.log(error);
const tag = error.match(/ambiguous argument '(\S+)\.\.\S+'/);

if (tag) {
Expand Down

0 comments on commit 0a38701

Please sign in to comment.