Skip to content

Commit fbea484

Browse files
authored
Merge pull request #214 from rkotze/selected-author-unique
Fix co-author email filtering by exact
2 parents d7c74b2 + 117d7a6 commit fbea484

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Follows [Semantic Versioning](https://semver.org/).
44

5+
## git-mob-core 0.10.1
6+
7+
### Fixed
8+
9+
- If an email has partially the same email as another co-author they will get included. This addresses this issue. [Issue 213](https://github.com/rkotze/git-mob/issues/213)
10+
511
## git-mob 4.0.0
612

713
### Added

packages/git-mob-core/src/index.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const mockedGetSetCoAuthors = jest.mocked(getSetCoAuthors);
3232
describe('Git Mob core API', () => {
3333
afterEach(() => {
3434
mockedRemoveGitMobSection.mockReset();
35+
mockedGetSetCoAuthors.mockReset();
3536
mockedGitConfig.getGlobalCommitTemplate.mockReset();
3637
mockedGitConfig.getLocalCommitTemplate.mockReset();
3738
});
@@ -137,6 +138,17 @@ describe('Git Mob core API', () => {
137138
const selectedAuthor = listAll[1];
138139
mockedGetSetCoAuthors.mockResolvedValueOnce(selectedAuthor.toString());
139140
const selected = await getSelectedCoAuthors(listAll);
141+
142+
expect(mockedGetSetCoAuthors).toHaveBeenCalledTimes(1);
143+
expect(selected).toEqual([selectedAuthor]);
144+
});
145+
146+
it('Use exact email for selected co-authors', async () => {
147+
const listAll = buildAuthorList(['ab', 'efcd', 'cd']);
148+
const selectedAuthor = listAll[1];
149+
mockedGetSetCoAuthors.mockResolvedValueOnce(selectedAuthor.toString());
150+
const selected = await getSelectedCoAuthors(listAll);
151+
140152
expect(mockedGetSetCoAuthors).toHaveBeenCalledTimes(1);
141153
expect(selected).toEqual([selectedAuthor]);
142154
});

packages/git-mob-core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async function getSelectedCoAuthors(allAuthors: Author[]) {
8484
const coAuthorConfigValue = await getSetCoAuthors();
8585
if (coAuthorConfigValue) coAuthorsString = coAuthorConfigValue;
8686

87-
return allAuthors.filter(author => coAuthorsString.includes(author.email));
87+
return allAuthors.filter(author => coAuthorsString.includes('<' + author.email));
8888
}
8989

9090
async function solo() {

0 commit comments

Comments
 (0)