Skip to content

Commit 2ebc37c

Browse files
committed
fix exceptional case for git-tr to use local branch name as remote
1 parent 9d5c5b0 commit 2ebc37c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

git-origin.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ var ret = exec('git rev-parse --abbrev-ref --symbolic-full-name ' + branch + '@{
99
});
1010
// no tracking branch on remote
1111
if (ret.code) {
12+
// use the first remote listed
1213
echo(exec('git remote', {
1314
silent: 1
1415
}).output.split('\n')[0]);
1516
} else {
1617
echo(/[^\s]+?(?=\/)/.exec(ret.output)[0]);
17-
}
18+
}

git-tr.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ var branch = process.argv[2] || exec('git br', {
77
var ret = exec('git rev-parse --abbrev-ref --symbolic-full-name ' + branch + '@{u}', {
88
silent: 1
99
});
10+
1011
if (ret.code) {
11-
echo('remote tracking branch NOT found');
12-
exit(1);
13-
} else {
12+
// use the same local branch name for remote.
13+
echo(exec('git origin', {silent: 1}).output.trim() + '/' + branch);
14+
}
15+
else {
1416
echo(ret.output);
15-
}
17+
}

0 commit comments

Comments
 (0)