next-issue 8.2.3 → 8.2.5
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/README.md +4 -1
- package/dist/worktree.mjs +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,7 +70,10 @@ the run handles one issue. For each issue:
|
|
|
70
70
|
no commits of its own starts again from the remote base. An issue with no
|
|
71
71
|
saved state does not reuse a local `<n>` branch: it resets that branch,
|
|
72
72
|
and any worktree that holds it, to the remote branch, or to the remote
|
|
73
|
-
base when there is none.
|
|
73
|
+
base when there is none. A worktree at `.worktrees/<n>` left on a
|
|
74
|
+
detached HEAD, for example by a crash, is removed, but its uncommitted
|
|
75
|
+
files are first committed on a `<n>-detached-<sha>` branch, so they are
|
|
76
|
+
kept. The main worktree of the repository is never
|
|
74
77
|
used, reset or cleaned: when it has the branch of the issue checked out,
|
|
75
78
|
the issue fails and is handed over, and the reason asks you to check out
|
|
76
79
|
another branch there. A fast-forward of the base that is not safe
|
package/dist/worktree.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
1
2
|
import { realpath } from 'node:fs/promises';
|
|
2
3
|
import { join } from 'node:path';
|
|
3
|
-
import { currentBranch, discardChanges, git, gitFetch, isAncestor, oneFetchAtATime, remoteRef, succeeds, } from './git.mjs';
|
|
4
|
+
import { currentBranch, discardChanges, git, gitFetch, isAncestor, oneFetchAtATime, remoteRef, revision, saveEdits, succeeds, } from './git.mjs';
|
|
4
5
|
export const WORKTREE_DIR = '.worktrees';
|
|
5
6
|
export function huntPath(repo) {
|
|
6
7
|
return join(repo.root, WORKTREE_DIR, 'hunt');
|
|
@@ -20,6 +21,7 @@ export async function addWorktree(repo, issue, branch, base, remote, start) {
|
|
|
20
21
|
const path = existing ?? worktreePath(repo, issue);
|
|
21
22
|
const target = pushed ? upstream : remoteBase;
|
|
22
23
|
if (existing === undefined) {
|
|
24
|
+
await keepDetachedEdits(path, branch);
|
|
23
25
|
await succeeds(repo.root, ['worktree', 'remove', '--force', path]);
|
|
24
26
|
const args = !start && (await hasWork(repo, branch, pushed, remoteBase))
|
|
25
27
|
? ['worktree', 'add', path, branch]
|
|
@@ -34,6 +36,14 @@ export async function addWorktree(repo, issue, branch, base, remote, start) {
|
|
|
34
36
|
}
|
|
35
37
|
return { path, baseUpdated };
|
|
36
38
|
}
|
|
39
|
+
async function keepDetachedEdits(path, branch) {
|
|
40
|
+
if (!existsSync(join(path, '.git')) ||
|
|
41
|
+
(await currentBranch(path)) !== undefined ||
|
|
42
|
+
!(await saveEdits(path, 'chore: edits left on a detached HEAD'))) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
await git(path, ['branch', `${branch}-detached-${(await revision(path)).slice(0, 7)}`]);
|
|
46
|
+
}
|
|
37
47
|
async function hasWork(repo, branch, pushed, base) {
|
|
38
48
|
if (!(await hasBranch(repo, branch))) {
|
|
39
49
|
return false;
|