Repository navigation
fix(server): a failed worktree hook shows its output and retry recovers #34288
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
Open
aFlamee
wants to merge
9
commits into
pingdotgg:main
Choose a base branch
from
aFlamee:t3/worktree-hook-rollback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+144
−18
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4b381e7
fix(server): a failed worktree hook shows its output and retry recovers
aFlamee ca81569
fix(server): redact hook URLs fully and roll back relative worktree p…
aFlamee 35211e1
docs: list the worktree hook output exception for Macroscope
aFlamee df8d5ee
fix(server): redact adjacent hook URLs and roll back only owned workt…
aFlamee f826b86
Merge branch 'main' into t3/worktree-hook-rollback
aFlamee 90e001b
Merge remote-tracking branch 'origin/main' into t3/worktree-hook-roll…
aFlamee 62ae160
fix(server): merge main and preserve owned hook rollback
maria-rcks 8e344e2
test(server): account for failed worktree ownership lookup
maria-rcks ebb933e
test(server): preserve worktrees when ownership metadata is unreadable
maria-rcks 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Git's own lines stay out: they are classified into a reason and can name private refs or paths. | ||
| const GIT_OWN_LINE = /^(?:fatal|error|warning|hint):|^Preparing worktree |^Updating files:/; | ||
| // Userinfo runs through the authority's last `@`; query strings can carry tokens or signatures. | ||
| // Quotes and brackets end a URL, so adjacent ones redact separately. Only start a scheme at its boundary so scanning stays linear. | ||
| const URL_PATTERN = | ||
| /(?<![a-z0-9+.-])([a-z][a-z0-9+.-]*:\/\/)([^\s/?#"'<>]*@)?([^\s?#"'<>]*)(\?[^\s#"'<>]*)?/gi; | ||
| const MAX_LINES = 20; | ||
| const MAX_CHARS = 1_000; | ||
|
|
||
| const redactUrls = (text: string) => | ||
| text.replace( | ||
| URL_PATTERN, | ||
| (_, scheme: string, userinfo?: string, rest?: string, query?: string) => | ||
| `${scheme}${userinfo ? "<redacted>@" : ""}${rest ?? ""}${query ? "?<redacted>" : ""}`, | ||
| ); | ||
|
|
||
| /** Appends what a hook or filter printed, which often names the fix for a failed checkout. */ | ||
| export function withHookOutput(detail: string, stderr: string): string { | ||
| const lines = stderr | ||
| .split(/\r\n|\r|\n/) | ||
| .map((line) => line.trim()) | ||
| .filter((line) => line.length > 0 && !GIT_OWN_LINE.test(line)) | ||
| .slice(-MAX_LINES); | ||
| if (lines.length === 0) return detail; | ||
| const output = redactUrls(lines.join("\n")); | ||
|
aFlamee marked this conversation as resolved.
Resolved
|
||
| return `${detail}: ${output.length > MAX_CHARS ? `…${output.slice(-MAX_CHARS)}` : output}`; | ||
| } | ||
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.
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.