1 | ;
|
2 |
|
3 | const log = require("npmlog");
|
4 | const childProcess = require("@lerna/child-process");
|
5 |
|
6 | module.exports.remoteBranchExists = remoteBranchExists;
|
7 |
|
8 | /**
|
9 | * @param {string} gitRemote
|
10 | * @param {string} branch
|
11 | * @param {import("@lerna/child-process").ExecOpts} opts
|
12 | */
|
13 | function remoteBranchExists(gitRemote, branch, opts) {
|
14 | log.silly("remoteBranchExists");
|
15 |
|
16 | const remoteBranch = `${gitRemote}/${branch}`;
|
17 |
|
18 | try {
|
19 | childProcess.execSync("git", ["show-ref", "--verify", `refs/remotes/${remoteBranch}`], opts);
|
20 | return true;
|
21 | } catch (e) {
|
22 | return false;
|
23 | }
|
24 | }
|