next-issue 17.0.5 → 17.0.6
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/dist/shared/worktree.mjs +10 -0
- package/package.json +1 -1
package/dist/shared/worktree.mjs
CHANGED
|
@@ -20,6 +20,9 @@ export async function addWorktree(repo, issue, branch, base, remote, start) {
|
|
|
20
20
|
const existing = await findWorktree(repo, branch);
|
|
21
21
|
const path = existing ?? worktreePath(repo, issue);
|
|
22
22
|
const target = pushed ? upstream : remoteBase;
|
|
23
|
+
if (start) {
|
|
24
|
+
await keepUnmergedCommits(repo, branch, target);
|
|
25
|
+
}
|
|
23
26
|
if (existing === undefined) {
|
|
24
27
|
await keepDetachedEdits(path, branch);
|
|
25
28
|
await succeeds(repo.root, ['worktree', 'remove', '--force', path]);
|
|
@@ -42,6 +45,13 @@ async function keepDetachedEdits(path, branch) {
|
|
|
42
45
|
}
|
|
43
46
|
await git(path, ['branch', `${branch}-detached-${(await revision(path)).slice(0, 7)}`]);
|
|
44
47
|
}
|
|
48
|
+
async function keepUnmergedCommits(repo, branch, target) {
|
|
49
|
+
if (!(await hasBranch(repo, branch)) || (await isAncestor(repo.root, branch, target))) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const head = await git(repo.root, ['rev-parse', branch]);
|
|
53
|
+
await git(repo.root, ['branch', '--force', `${branch}-kept-${head.slice(0, 7)}`, branch]);
|
|
54
|
+
}
|
|
45
55
|
async function hasWork(repo, branch, pushed, base) {
|
|
46
56
|
if (!(await hasBranch(repo, branch))) {
|
|
47
57
|
return false;
|