Repository navigation
fix(box): worktrees with submodules can be removed when nothing would be lost #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
40a0bab
fix(box): worktrees with submodules can be removed when nothing would…
pumfleet 37d7cfc
fix(box): removing a worktree with submodules keeps untracked files a…
pumfleet 1e80b29
fix(box): removing a worktree with submodules keeps tagged commits an…
pumfleet 646df7f
fix(box): removing a worktree with submodules keeps commits in a subm…
pumfleet 46b44ff
fix(box): say exactly what removing a worktree with submodules keeps
pumfleet 7f810d3
fix(app): a worktree the box couldn't check for unsaved work still of…
pumfleet 0415ae9
fix(box): removing a worktree checks deinitialized submodules inside …
pumfleet 6dec976
fix(box): removing a worktree sees a nested submodule moved behind an…
pumfleet d56e6e0
fix(app): only a real refusal over unsaved work offers remove anyway
pumfleet ed54f4c
Merge remote-tracking branch 'origin/main' into most-of-my-worktree
pumfleet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // node --experimental-strip-types --test src/lib/kept-reason.test.ts (pnpm test) | ||
| import assert from "node:assert/strict"; | ||
| import { test } from "node:test"; | ||
|
|
||
| import { keptReason } from "./kept-reason.ts"; | ||
|
|
||
| const box = (why: string) => `git worktree remove: '/home/acme/code/shop-fix' ${why}, use --force to delete it`; | ||
|
|
||
| test("work git or the box would lose keeps the worktree, and says what it is", () => { | ||
| assert.match(keptReason(box("contains modified or untracked files"))!, /uncommitted changes/); | ||
| assert.match(keptReason(box("contains modified or untracked files in a submodule"))!, /uncommitted changes/); | ||
| assert.match(keptReason(box("contains submodule commits or stashes that no remote has"))!, /commits or stashes no remote has/); | ||
| }); | ||
|
|
||
| test("a check that couldn't run still offers Remove anyway, without calling it uncommitted changes", () => { | ||
| for (const why of ["could not be checked for changes", "has submodules that could not be checked for unpushed work"]) { | ||
| const said = keptReason(box(why)); | ||
| assert.ok(said, why); | ||
| assert.doesNotMatch(said!, /uncommitted/); | ||
| } | ||
| }); | ||
|
|
||
| test("other failures aren't a reason to force", () => { | ||
| assert.equal(keptReason("git worktree remove: fatal: 'shop-fix' is not a working tree"), null); | ||
| assert.equal(keptReason("not connected"), null); | ||
| // Words that only sound like unsaved work. | ||
| assert.equal(keptReason("git worktree remove: fatal: '/home/acme/code/shop-fix' contains a .git file that is not a gitlink"), null); | ||
| assert.equal(keptReason("git worktree remove: error: unable to unlink old 'src/modified.ts': Permission denied"), null); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // keptReason reads a box's refusal to remove a worktree unforced: why it | ||
| // was kept, in words for the "Kept" toast that offers Remove anyway, or | ||
| // null when the error is something else that forcing wouldn't fix. | ||
| export function keptReason(msg: string): string | null { | ||
| if (/submodule commits/i.test(msg)) return "A submodule in it has commits or stashes no remote has, so it was left as it is."; | ||
| if (/could not be checked/i.test(msg)) return "Shipyard couldn't check it for work that removing it would lose, so it was left as it is."; | ||
| // git's own words for work it would lose, which the box's refusals use too. | ||
| if (/modified or untracked files/i.test(msg)) return "It has uncommitted changes, so git left it as it is."; | ||
| return null; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.