pi-note 0.33.2 → 0.33.3
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 -2
- package/package.json +1 -1
- package/remote/exit.ts +12 -1
package/README.md
CHANGED
|
@@ -96,8 +96,10 @@ Pi's working directory before exiting, so Kitty closes its dedicated tab (or the
|
|
|
96
96
|
standalone window's last tab). It never merges, rebases or stashes local changes.
|
|
97
97
|
If Git fails, times out (30 seconds), or the session/draft changes, Pi stays open;
|
|
98
98
|
the task remains completed and is not retried. Check Git manually, then `/quit`.
|
|
99
|
-
With pi-note 0.33.
|
|
100
|
-
|
|
99
|
+
With pi-note 0.33.3+, directories outside Git, repositories without remotes, and
|
|
100
|
+
branches without a configured upstream skip the pull and exit without a warning.
|
|
101
|
+
Broken Git configuration, detached HEAD in a remote-backed repository, and failures
|
|
102
|
+
to pull a configured upstream still keep Pi open.
|
|
101
103
|
`/quit` and Exit without completing do not pull.
|
|
102
104
|
This ownership survives `/reload`, but not `/new`, resume, fork, tree navigation
|
|
103
105
|
or process restart. Completing a different task or an externally completed task
|
package/package.json
CHANGED
package/remote/exit.ts
CHANGED
|
@@ -12,11 +12,22 @@ export async function pullBeforeExit(pi: ExtensionAPI, ctx: ExtensionContext, si
|
|
|
12
12
|
ctx.sessionManager.getSessionId() === sessionId && ctx.sessionManager.getLeafId() === branch && ctx.ui.getEditorText() === draft;
|
|
13
13
|
if (!unchanged()) return false;
|
|
14
14
|
try {
|
|
15
|
-
const
|
|
15
|
+
const git = (args: string[]) => spawnSync('git', args, {
|
|
16
16
|
cwd: ctx.cwd, encoding: 'utf8', timeout: 3000, env: { ...process.env, LC_ALL: 'C' },
|
|
17
17
|
});
|
|
18
|
+
const repository = git(['rev-parse', '--show-toplevel']);
|
|
18
19
|
if (!repository.error && repository.status === 128 && repository.stderr.startsWith('fatal: not a git repository (or any ')) return unchanged();
|
|
19
20
|
if (repository.error || repository.status !== 0 || !unchanged()) throw new Error('Git repository check failed');
|
|
21
|
+
const remotes = git(['remote']);
|
|
22
|
+
if (remotes.error || remotes.status !== 0) throw new Error('Git remote check failed');
|
|
23
|
+
if (!remotes.stdout.trim()) return unchanged();
|
|
24
|
+
const branch = git(['symbolic-ref', '--quiet', 'HEAD']);
|
|
25
|
+
if (branch.error || branch.status !== 0 || !branch.stdout.startsWith('refs/heads/')) throw new Error('Git branch check failed');
|
|
26
|
+
const branchName = branch.stdout.trim().slice('refs/heads/'.length);
|
|
27
|
+
const upstream = git(['config', '--get', `branch.${branchName}.merge`]);
|
|
28
|
+
if (upstream.error || (upstream.status !== 0 && upstream.status !== 1)) throw new Error('Git upstream check failed');
|
|
29
|
+
if (upstream.status === 1) return unchanged();
|
|
30
|
+
if (!upstream.stdout.trim() || !unchanged()) throw new Error('Git upstream or session changed');
|
|
20
31
|
ctx.ui.notify('Task completed. Running git pull --ff-only before closing Pi…', 'info');
|
|
21
32
|
const result = await pi.exec('git', ['pull', '--ff-only', '--no-rebase', '--no-autostash'], { cwd: ctx.cwd, signal, timeout: 30_000 });
|
|
22
33
|
if (result.code === 0 && !result.killed && unchanged()) return true;
|