@callumvass/forgeflow-dev 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/index.js +12 -5
- package/package.json +1 -1
package/extensions/index.js
CHANGED
|
@@ -422,9 +422,15 @@ var JIRA_BRANCH_RE = /feat\/([A-Z]+-\d+)/;
|
|
|
422
422
|
async function ensureBranch(cwd, branch) {
|
|
423
423
|
const currentBranch = await exec("git branch --show-current", cwd);
|
|
424
424
|
if (currentBranch === branch) return;
|
|
425
|
-
const
|
|
426
|
-
if (
|
|
425
|
+
const localExists = await exec(`git rev-parse --verify ${branch} 2>/dev/null && echo yes || echo no`, cwd);
|
|
426
|
+
if (localExists === "yes") {
|
|
427
427
|
await exec(`git checkout ${branch}`, cwd);
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
await exec("git fetch origin", cwd);
|
|
431
|
+
const remoteExists = await exec(`git rev-parse --verify origin/${branch} 2>/dev/null && echo yes || echo no`, cwd);
|
|
432
|
+
if (remoteExists === "yes") {
|
|
433
|
+
await exec(`git checkout -b ${branch} origin/${branch}`, cwd);
|
|
428
434
|
} else {
|
|
429
435
|
await exec(`git checkout -b ${branch}`, cwd);
|
|
430
436
|
}
|
|
@@ -749,11 +755,12 @@ ${flags.customPrompt}` : "";
|
|
|
749
755
|
};
|
|
750
756
|
}
|
|
751
757
|
if (resolved.branch) {
|
|
752
|
-
const
|
|
753
|
-
|
|
758
|
+
const localExists = await exec(`git rev-parse --verify ${resolved.branch} 2>/dev/null && echo yes || echo no`, cwd);
|
|
759
|
+
const remoteExists = localExists === "yes" ? "no" : await exec(
|
|
760
|
+
`git fetch origin && git rev-parse --verify origin/${resolved.branch} 2>/dev/null && echo yes || echo no`,
|
|
754
761
|
cwd
|
|
755
762
|
);
|
|
756
|
-
if (
|
|
763
|
+
if (localExists === "yes" || remoteExists === "yes") {
|
|
757
764
|
await ensureBranch(cwd, resolved.branch);
|
|
758
765
|
const ahead = await exec(`git rev-list main..${resolved.branch} --count`, cwd);
|
|
759
766
|
if (parseInt(ahead, 10) > 0) {
|