mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-05 00:03:15 +01:00
fix(context-restore): name another branch as a cause when the saved commit is not in history
Cross-branch resume (Conductor handoff) is a supported restore path, and there the checkpoint's commit is usually not an ancestor of HEAD. The diverged line said only 'rebased, reset, or not fetched'. It now names 'saved on another branch' first; the new test case covers a save on a feature branch restored from main. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
d540b102ac
commit
0ddbc5b04d
3 files changed
+16
-4
No files matched your search
@@ -560,8 +560,8 @@ fi
|
||||
under **Verify first**: the saving session could not know about those commits,
|
||||
so any step may already be done.
|
||||
- `HEAD_DIVERGED` or `HEAD_UNKNOWN`: print `This checkpoint was saved at {first 7
|
||||
characters of head}, which is not in this checkout's history (rebased, reset, or
|
||||
not fetched).` and list every item under Verify first.
|
||||
characters of head}, which is not in this checkout's history (saved on another
|
||||
branch, rebased, reset, or not fetched).` and list every item under Verify first.
|
||||
- `HEAD_UNTRACKED`: print `This checkpoint predates commit tracking; restore cannot tell whether work landed after it.`
|
||||
and sort as usual.
|
||||
|
||||
|
||||
@@ -236,8 +236,8 @@ fi
|
||||
under **Verify first**: the saving session could not know about those commits,
|
||||
so any step may already be done.
|
||||
- `HEAD_DIVERGED` or `HEAD_UNKNOWN`: print `This checkpoint was saved at {first 7
|
||||
characters of head}, which is not in this checkout's history (rebased, reset, or
|
||||
not fetched).` and list every item under Verify first.
|
||||
characters of head}, which is not in this checkout's history (saved on another
|
||||
branch, rebased, reset, or not fetched).` and list every item under Verify first.
|
||||
- `HEAD_UNTRACKED`: print `This checkpoint predates commit tracking; restore cannot tell whether work landed after it.`
|
||||
and sort as usual.
|
||||
|
||||
|
||||
@@ -144,6 +144,18 @@ describe('context-restore compares the checkpoint with HEAD', () => {
|
||||
expect(headCheck(app, file)).toStartWith('HEAD_DIVERGED ');
|
||||
});
|
||||
|
||||
test('a checkpoint resumed from another branch is reported, and the prompt names that cause', () => {
|
||||
const app = repo();
|
||||
git(app, 'checkout', '-q', '-b', 'feature');
|
||||
commit(app, 'feature work');
|
||||
const file = save(app);
|
||||
git(app, 'checkout', '-q', 'main');
|
||||
commit(app, 'unrelated main work');
|
||||
expect(headCheck(app, file)).toStartWith('HEAD_DIVERGED ');
|
||||
const restore = fs.readFileSync(path.join(ROOT, 'context-restore/SKILL.md'), 'utf-8');
|
||||
expect(restore).toContain('(saved on another\n branch, rebased, reset, or not fetched)');
|
||||
});
|
||||
|
||||
test('checkpoints saved before head tracking, or with a malformed head, are never treated as current', () => {
|
||||
const app = repo();
|
||||
const legacy = path.join(tmp, 'legacy.md');
|
||||
|
||||
Reference in new issue
Block a user