diff options
| author | Russ Cox <rsc@golang.org> | 2016-01-29 13:47:13 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2016-02-18 17:48:13 +0000 |
| commit | 28658025cb75e5eb09b6c1033244e012dfcec37a (patch) | |
| tree | cace627ceb92b8c702831db2447c2ec19a490168 /git-codereview/review.go | |
| parent | bc25bc4639951eac5129d7c82603c14c52ca4c8b (diff) | |
| download | go-x-review-28658025cb75e5eb09b6c1033244e012dfcec37a.tar.xz | |
git-codereview: disable Gerrit-specific hook behavior if Gerrit is not in use
Every time I accidentally type 'git pending' in a non-Gerrit repository,
that command installs hooks, and then I have to zero the hook files
to keep working.
First, don't install the hooks if this looks like a non-Gerrit git repo.
That seems like it will play well with others.
But, people might also want to use the non-Gerrit parts of the tool,
so if people do say 'git codereview hooks', let that install them.
And then if the hooks are invoked in a non-Gerrit repo, selectively
disable the Gerrit-specific parts. For example, if it's not a Gerrit repo
we might still want to check and fix 'Fixes #N' lines if directed by the
config, but we don't want to add Change-Id lines.
Now that things are a bit better behaved, also leave the hooks on
in detached head mode. I've found that it's quite frustrating not
to have the hooks on when working midway through git rebase -i.
If we find reasons that the hooks were off we can try to figure out
how to split the difference.
Fixes golang/go#12170.
Change-Id: I69fa156ce4fd11c0c84416088cd972957ce1ce6d
Reviewed-on: https://go-review.googlesource.com/19560
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'git-codereview/review.go')
| -rw-r--r-- | git-codereview/review.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/git-codereview/review.go b/git-codereview/review.go index 15766ef..779b77c 100644 --- a/git-codereview/review.go +++ b/git-codereview/review.go @@ -125,7 +125,10 @@ func main() { return } - installHook() + // Install hooks automatically, but only if this is a Gerrit repo. + if haveGerrit() { + installHook() + } switch command { case "branchpoint": @@ -137,7 +140,7 @@ func main() { case "hook-invoke": cmdHookInvoke(args) case "hooks": - // done - installHook already ran + installHook() // in case above was bypassed case "mail", "m": cmdMail(args) case "pending": |
