Skip to content

Commit 136e274

Browse files
authored
Merge pull request #726 from steveukx/fix-pr-711
fix: allow branches without labels
2 parents 0907d00 + 07a1388 commit 136e274

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

simple-git/src/lib/parsers/parse-branch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const parsers: LineParser<BranchSummaryResult>[] = [
1010
name, commit, label
1111
);
1212
}),
13-
new LineParser(/^(\*\s)?(\S+)\s+([a-z0-9]+)\s(.*)$/s, (result, [current, name, commit, label]) => {
13+
new LineParser(/^(\*\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s, (result, [current, name, commit, label]) => {
1414
result.push(
1515
!!current,
1616
false,

simple-git/test/unit/branch.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,38 @@ describe('branch', () => {
209209
all: ['2b2dba2', 'cflynn07-add-git-ignore', 'master'],
210210
}));
211211
});
212+
213+
it('branches without labels', async () => {
214+
const actual = parseBranchSummary(`
215+
* stable f8cc2bc
216+
remotes/origin/stable f8cc2bd
217+
dev f8cc2be wip
218+
`);
219+
expect(actual).toEqual(like({
220+
current: 'stable',
221+
all: ['stable', 'remotes/origin/stable', 'dev'],
222+
branches: {
223+
stable: {
224+
commit: 'f8cc2bc',
225+
current: true,
226+
label: '',
227+
name: 'stable',
228+
},
229+
['remotes/origin/stable']: {
230+
commit: 'f8cc2bd',
231+
current: false,
232+
label: '',
233+
name: 'remotes/origin/stable',
234+
},
235+
dev: {
236+
commit: 'f8cc2be',
237+
current: false,
238+
label: 'wip',
239+
name: 'dev',
240+
},
241+
}
242+
}));
243+
});
212244
});
213245

214246
describe('usage', () => {

0 commit comments

Comments
 (0)