Skip to content

Commit 6ae3958

Browse files
authored
Merge pull request #99 from chengbapi/fix/exact-pattern
fix: use more accurate pattern when checking remote branch existence
2 parents 36dfa4c + 6486256 commit 6ae3958

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

apps/sparo-lib/src/services/GitService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,8 @@ Please specify a directory on the command line
496496
const gitPath: string = this.getGitPathOrThrow();
497497
const currentWorkingDirectory: string = this.getRepoInfo().root;
498498
const isDebug: boolean = this._terminalService.isDebug;
499-
const lsRemoteArgs: string[] = ['ls-remote', '--exit-code', '--heads', remote, branch];
499+
const branchPattern: string = `refs/heads/${branch}`;
500+
const lsRemoteArgs: string[] = ['ls-remote', '--exit-code', '--heads', remote, branchPattern];
500501
const { terminal } = this._terminalService;
501502
terminal.writeDebugLine(`Running git ${lsRemoteArgs.join(' ')}...`);
502503
const childProcess: child_process.ChildProcess = Executable.spawn(gitPath, lsRemoteArgs, {
@@ -506,7 +507,7 @@ Please specify a directory on the command line
506507
if (!childProcess.stdout || !childProcess.stderr) {
507508
terminal.writeDebugLine(`Failed to spawn git process, fallback to spawnSync`);
508509
const result: string = this.executeGitCommandAndCaptureOutput({
509-
args: ['ls-remote', remote, branch]
510+
args: ['ls-remote', remote, branchPattern]
510511
}).trim();
511512
return Promise.resolve(!!result);
512513
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "sparo",
5+
"comment": "fix: use more accurate pattern when checking remote branch existence #99",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "sparo"
10+
}

0 commit comments

Comments
 (0)