Skip to content

x/review/git-codereview: change -n still writes the hooks without announcing #73314

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

Closed
abitrolly opened this issue Apr 10, 2025 · 4 comments
Closed
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@abitrolly
Copy link

According to usage, -n should not result in any changes to repository.

The -n flag prints commands that would make changes but does not run them.

But that's not the case for hooks.

➜ .git/hooks/pre-commit
➜ ls -la .git/hooks/pre-commit
ls: cannot access '.git/hooks/pre-commit': No such file or directory
➜ ~/go/bin/git-codereview change -n
git-codereview: warning: unstaged changes and no staged changes; use 'git add' or 'git change -a'
git commit -q --allow-empty
git-codereview: change updated.
➜ ls -la .git/hooks/pre-commit
-rwx------. 1 anatoli anatoli 58 Apr 10 18:00 .git/hooks/pre-commit

Then my repo becomes broken, because git-codereview does not exist in PATH.

I expect hook handler to report what they are doing and respect -n flag.

@gopherbot gopherbot added this to the Unreleased milestone Apr 10, 2025
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. help wanted labels Apr 10, 2025
@dmitshur dmitshur changed the title x/review: change -n still writes the hooks without announcing x/review/git-codereview: change -n still writes the hooks without announcing Apr 10, 2025
@dmitshur
Copy link
Contributor

Thanks for reporting.

This should be a matter of adding a check for *noRun inside installHook, before it starts to do os.Mkdir and os.WriteFile.

@abitrolly
Copy link
Author

@dmitshur it required a few more checks to be completely safe https://go-review.googlesource.com/c/review/+/664555

@dmitshur dmitshur added the FixPending Issues that have a fix which has not yet been reviewed or submitted. label Apr 10, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/664555 mentions this issue: git-codereview: do not write hooks if -n is given

@abitrolly
Copy link
Author

Added a proposal to support full issue URLs #73320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants