Skip to content

Commit

Permalink
fix: allow branches without labels
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoKatel authored and steveukx committed Jan 20, 2022
1 parent 0907d00 commit 07a1388
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion simple-git/src/lib/parsers/parse-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const parsers: LineParser<BranchSummaryResult>[] = [
name, commit, label
);
}),
new LineParser(/^(\*\s)?(\S+)\s+([a-z0-9]+)\s(.*)$/s, (result, [current, name, commit, label]) => {
new LineParser(/^(\*\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s, (result, [current, name, commit, label]) => {
result.push(
!!current,
false,
Expand Down
32 changes: 32 additions & 0 deletions simple-git/test/unit/branch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,38 @@ describe('branch', () => {
all: ['2b2dba2', 'cflynn07-add-git-ignore', 'master'],
}));
});

it('branches without labels', async () => {
const actual = parseBranchSummary(`
* stable f8cc2bc
remotes/origin/stable f8cc2bd
dev f8cc2be wip
`);
expect(actual).toEqual(like({
current: 'stable',
all: ['stable', 'remotes/origin/stable', 'dev'],
branches: {
stable: {
commit: 'f8cc2bc',
current: true,
label: '',
name: 'stable',
},
['remotes/origin/stable']: {
commit: 'f8cc2bd',
current: false,
label: '',
name: 'remotes/origin/stable',
},
dev: {
commit: 'f8cc2be',
current: false,
label: 'wip',
name: 'dev',
},
}
}));
});
});

describe('usage', () => {
Expand Down

0 comments on commit 07a1388

Please sign in to comment.