-
Notifications
You must be signed in to change notification settings - Fork 2
feat(go-format): disclose goimports rewrites on the user channel #2473
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -224,6 +224,10 @@ fi | |
| GOIMPORTS_ARGS=(-w -l) | ||
| [[ -n "$LOCAL_PREFIX" ]] && GOIMPORTS_ARGS+=(-local "$LOCAL_PREFIX") | ||
|
|
||
| _go_before="" | ||
| if _go_before=$(mktemp 2>/dev/null); then | ||
| cp "$FILE" "$_go_before" 2>/dev/null || _go_before="" | ||
| fi | ||
| # -w writes the fix in place; -l (combined with -w) lists the changed | ||
| # filename on stdout, which this hook doesn't need (a successful autofix | ||
| # carries no advisory noise, same posture as a successful ruff/typos fix | ||
|
|
@@ -240,6 +244,12 @@ STDERR=$("$GOIMPORTS_BIN" "${GOIMPORTS_ARGS[@]}" -- "$FILE" 2>&1 >/dev/null) | |
| RC=$? | ||
|
|
||
| if [[ $RC -eq 0 ]]; then | ||
| if [[ -n "$_go_before" ]]; then | ||
| if ! cmp -s "$_go_before" "$FILE" 2>/dev/null; then | ||
| hook::emit_system_message "go-format: reformatted $(basename "$FILE") via goimports (imports and layout only)." | ||
| fi | ||
| rm -f "$_go_before" | ||
|
Comment on lines
227
to
+251
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion — error-handling: The snapshot is only removed inside the For comparison, the sibling Here in (Independently flagged by Codex and the security-review lane on this PR as a hygiene issue; reporting here as well since unbounded temp-file accumulation on an error path is squarely an error-handling/correctness concern for this lane.) |
||
| fi | ||
| # Clean, or fixed silently (formatting/import changes carry no advisory | ||
| # noise — same posture as a successful ruff/typos autofix pass). | ||
| emit_tel "ok" '[]' | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.