Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f85e5e

Browse files
committed
Add a pattern option to getBranchesWithCommit
1 parent eaf0e4a commit 1f85e5e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/git-shell-out-strategy.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,9 @@ export default class GitShellOutStrategy {
985985
} else if (option.showRemote) {
986986
args.splice(1, 0, '--remotes');
987987
}
988+
if (option.pattern) {
989+
args.push(option.pattern);
990+
}
988991
return (await this.exec(args)).trim().split(LINE_ENDING_REGEX);
989992
}
990993

test/git-strategies.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,13 @@ import * as reporterProxy from '../lib/reporter-proxy';
10801080
['refs/remotes/origin/HEAD', 'refs/remotes/origin/master'],
10811081
);
10821082
});
1083+
1084+
it('includes only refs matching a pattern', async function() {
1085+
assert.sameMembers(
1086+
await git.getBranchesWithCommit(SHA, {showLocal: true, showRemote: true, pattern: 'origin/master'}),
1087+
['refs/remotes/origin/master'],
1088+
);
1089+
});
10831090
});
10841091

10851092
describe('getRemotes()', function() {

0 commit comments

Comments
 (0)