-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
filter author/committer with an array of string
- Loading branch information
1 parent
7cbef29
commit dadb3da
Showing
3 changed files
with
76 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,25 +210,51 @@ describe("gitlog", () => { | |
}); | ||
}); | ||
|
||
it("returns commits only by multiple authors", (done) => { | ||
const command = | ||
`cd ${testRepoLocation}` + | ||
'&& touch new-file' + | ||
'&& git add new-file' + | ||
'&& git commit -m "New commit" --author="A U Thor <[email protected]>"' + | ||
'&& touch loki-file' + | ||
'&& git add loki-file' + | ||
'&& git commit -m "loki commit" --author="A U Loki <[email protected]>"'; | ||
const authors = ["A U Thor", "A U Loki"]; | ||
|
||
// Adding a new commit by different author | ||
exec(command, () => { | ||
const commits = gitlog({ | ||
repo: testRepoLocation, | ||
author: authors, | ||
fields: ["authorName"], | ||
}); | ||
|
||
expect.assertions(2); | ||
commits.forEach((commit) => { | ||
expect(authors.includes(commit.authorName)).toBe(true); | ||
}); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
it("returns commits only by committer", (done) => { | ||
const defaults = ["committerName"] as const; | ||
const command = | ||
`cd ${testRepoLocation} ` + | ||
`&& touch new-file ` + | ||
`&& git add new-file ` + | ||
`&& git commit -m "New commit" ` + | ||
`--committer="A U Thor <[email protected]>"`; | ||
const committer = "Your Name"; | ||
'&& touch new-file ' + | ||
'&& git add new-file ' + | ||
'&& git -c "user.name=A U Thor" -c "[email protected]" commit -m "New commit"'; | ||
const committer = "A U Thor"; | ||
|
||
// Adding a new commit by different author | ||
exec(command, () => { | ||
const commits = gitlog({ | ||
repo: testRepoLocation, | ||
committer, | ||
fields: defaults, | ||
fields: ["committerName"], | ||
}); | ||
|
||
expect.assertions(10); | ||
expect.assertions(1); | ||
commits.forEach((commit) => { | ||
expect(commit.committerName).toBe(committer); | ||
}); | ||
|
@@ -237,6 +263,34 @@ describe("gitlog", () => { | |
}); | ||
}); | ||
|
||
it("returns commits only by multiple committers", (done) => { | ||
const command = | ||
`cd ${testRepoLocation} ` + | ||
'&& touch new-file ' + | ||
'&& git add new-file ' + | ||
'&& git -c "user.name=A U Thor" -c "[email protected]" commit -m "New commit"' + | ||
'&& touch loki-file ' + | ||
'&& git add loki-file ' + | ||
'&& git -c "user.name=A U Loki" -c "[email protected]" commit -m "loki commit"'; | ||
const committer = ["A U Thor", "A U Loki"]; | ||
|
||
// Adding a new commit by different author | ||
exec(command, () => { | ||
const commits = gitlog({ | ||
repo: testRepoLocation, | ||
committer, | ||
fields: ["committerName", "subject"], | ||
}); | ||
|
||
expect.assertions(2); | ||
commits.forEach((commit) => { | ||
expect(committer.includes(commit.committerName)).toBe(true); | ||
}); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
it("returns A status for files that are added", () => { | ||
const commits = gitlog({ repo: testRepoLocation }); | ||
expect(commits[1].status[0]).toBe("A"); | ||
|