Skip to content

Commit

Permalink
Get commit that adds a file rather than the one that last modified it (
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown authored and Noviny committed Nov 4, 2019
1 parent 9cd1eaf commit b17ed74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-windows-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/git": patch
---

Get commit from the creation of a changeset rather than the last modification
6 changes: 2 additions & 4 deletions packages/git/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ async function tag(tagStr: string, cwd: string) {
async function getCommitThatAddsFile(gitPath: string, cwd: string) {
const gitCmd = await spawn(
"git",
["log", "--reverse", "--max-count=1", "--pretty=format:%h", "-p", gitPath],
["log", "--diff-filter=A", "--max-count=1", "--pretty=format:%h", gitPath],
{ cwd }
);
// For reasons I do not understand, passing pretty format through this is not working
// The slice below is aimed at achieving the same thing.
return gitCmd.stdout.toString().split("\n")[0];
return gitCmd.stdout.toString();
}

async function getChangedFilesSince(
Expand Down

0 comments on commit b17ed74

Please sign in to comment.