aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/mail_test.go
AgeCommit message (Collapse)Author
2023-06-22git-codereview: fix mail lookup for dmitshur short nameDmitri Shuralyov
CL 2111 introduced a simple algorithm for expanding short user names that works locally and generally doesn't need any extra configuration to do the right thing. It's been serving for almost a decade. Unfortunately I'm running into an edge where I see no good option but to add a special case. Gerrit inserts "Reviewed-by" footers both for Code-Review +2 and +1 votes without any way to distinguish between them, and my @google.com account unavoidably gets more hits since I use it for the go.dev/s/needs-review process, whenever I leave a normal +2, and on my own CLs. The simplest fix seems to be to exclude it from short matches and let the existing algorithm do the rest. Change-Id: I92da69f1cd87b4c89816547015cffbed3eaaeaf6 Reviewed-on: https://go-review.googlesource.com/c/review/+/494175 Reviewed-by: MKaslann1 <mkaslann1@outlook.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2021-12-03git-codereview: don't sign git tagsTobias Klauser
For users who set tag.gpgSign=true in their git configuration, git-codereview mail currently fails to create the .mailed git tag because a signed git tag always requires a message: fatal: no tag message? (running: git tag -f foobar.mailed cf87726ac456) /home/tklauser/go/bin/git-codereview: exit status 128 Fix this by overriding the tag.gpgSign configuration using git tag --no-sign. There is no point in having these tags signed as they should never leave the local system. Change-Id: I8b7ddf3aa7709e6ea06e4d5add6cd581e9ec2e37 Reviewed-on: https://go-review.googlesource.com/c/review/+/369194 Trust: Tobias Klauser <tobias.klauser@gmail.com> Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2021-01-27git-codereview: avoid race in loadGerritOriginIan Lance Taylor
Use a mutex in loadGerritOrigin to avoid race when called in parallel by "git coderevew pending". Add a new initialized field so that the code knows when auth has been initialized. Adjust tests accordingly. The test is simply "go test -race". Fixes golang/go#43670 Change-Id: Ifb060fca6ed463f1d11a2959d03fca5e14e238c6 Reviewed-on: https://go-review.googlesource.com/c/review/+/287012 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-01-07git-codereview: allow work on main branchesRuss Cox
The only reason not to allow work on branches named for the origin branches is to preserve them for "git change main; git change new" to make a new branch tracking main. But we can still do that and allow commits on main - we just have to use the branchpoint as the root of the new branch. Now people can work on "main" (or "dev.regabi") if that suits them. In particular, if you're doing merges, it's nice to be on "dev.regabi" and know for sure that's the branch you're working on. Change-Id: I8e9458793c30857a5c00e6bfd4f1cb41adbbe637 Reviewed-on: https://go-review.googlesource.com/c/review/+/279874 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Austin Clements <austin@google.com>
2021-01-07git-codereview: update tests for "main" branch defaultRuss Cox
"git init ." leaves me on "main" now, not "master". Update tests to expect that, and update the "tracking" message too (otherwise the tests fail). Because not all gits agree about the initial branch name, set it explicitly too in the test. Fixes #42926. Change-Id: If3adb3bb53beba9efcd75cad0f081f59fba85fe7 Reviewed-on: https://go-review.googlesource.com/c/review/+/279873 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Austin Clements <austin@google.com>
2020-05-15git-codereview: add -wip flag to mail commandPaul Jolly
Add a -wip flag to the mail command to set the status of a change to work-in-progress. Per: https://gerrit-review.googlesource.com/Documentation/intro-user.html#wip Fixes golang/go#20991 Change-Id: I227beccb55570949e9b0f487d5394855611a118a Reviewed-on: https://go-review.googlesource.com/c/review/+/233237 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-12-16git-codereview: write hooks with execute permission in testsBryan C. Mills
The 'write' helper function previously assumed file permission 0666. We don't actually need these files to be world-writable, but we do need specific ones — scripts executed as Git commit hooks — to be executable, at least on certain platforms. Also use t.Helper() to produce more useful log lines for failures. (That was added in order to diagnose TryBot failures.) Fixes golang/go#32836 Change-Id: I2d670563f42778ef8cf645445420756599c37ac6 Reviewed-on: https://go-review.googlesource.com/c/review/+/211477 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alexander Rakoczy <alex@golang.org>
2018-07-02git-codereview: add -hashtag flag to the mail commandJesús Espino
It is now possible to mail a CL with any number of hashtags. Fixes golang/go#26149 Change-Id: I231826f95ec357bd448de12a9a5aa30e581c3bb3 Reviewed-on: https://go-review.googlesource.com/121798 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-30git-codereview: forbid mailing editor temp filesYury Smolsky
"mail" command rejects *~, #*# and .#* filenames. Also it should reject commit messages with non-printable characters, because these are impossible to spot in the review. For golang/go#24139 Change-Id: I3544e3c34c5ac9f55a7808264de4535bc455bd0a Reviewed-on: https://go-review.googlesource.com/101755 Run-TryBot: Yury Smolsky <yury@smolsky.by> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2017-11-16git-codereview: add support for DΟ NΟT MAILRuss Cox
Also create a local DΟ NΟT SUBMIT check, although the Gerrit server is also taking care of that. While we're here, make fixup! and squash! commits non-mailable as well. (In the all caps text above the big Os are really Omicrons. Otherwise the CL would not be mailable or submittable.) Change-Id: Id1a9806b0d395d1a0bfc50ed7d7d22c64a48a2f1 Reviewed-on: https://go-review.googlesource.com/76877 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26git-codereview: reject empty commits in mailCaio Marcelo de Oliveira Filho
Fixes golang/go#10753. Change-Id: I224a411177b3d198576a06bc69da9894b7b67c34 Reviewed-on: https://go-review.googlesource.com/19799 Run-TryBot: Andrew Gerrand <adg@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-02-05git-codereview: accept any commit spelling for mail and submitAustin Clements
Currently the mail and submit subcommands only accept commit hashes. This makes them inconsistent with other git commands (git is hard enough without having to remember another convention) and makes working with multi-commit branches cumbersome. Change mail and submit to accept any standard commit spelling. In particular, this makes it possible to use HEAD-relative names: "git mail HEAD" sends the whole current branch. We still require that the named commit be pending on the current branch to avoid accidentally naming a completely unrelated commit. Change-Id: If84d315e0fc32118a5283adfbca7a3b56f3c098c Reviewed-on: https://go-review.googlesource.com/19271 Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-12git-codereview: fix test regressions in TestMail*Håvard Haugen
Commit 8ef20ce (set x.mailed tag to mailed commit instead of HEAD) broke TestMail, TestMailShort, and TestMailTopic. Possibly related to golang/go#9602. Change-Id: Iac5ea98d034ee4815b3b7ea2d5cc3f523944b953 Reviewed-on: https://go-review.googlesource.com/9312 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-20git-codereview: add mail -topic supportAustin Clements
This adds a "-topic" flag to the mail subcommand that sets the Gerrit topic for the pushed changes. Gerrit topics make it easier to group related changes such as in a multi-change review. Note that, like reviewers, the topic is sticky, so it is only necessary to use mail -topic once for a given change. Change-Id: I30cf9a88092cc9270b4643d432dec7e5f967b922 Reviewed-on: https://go-review.googlesource.com/5301 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-06git-codereview: allow short user names in git mailRuss Cox
In Mercurial, hg mail expanded Rietveld user names. There are no Gerrit user names. There are GitHub user names, but then I'd have to type randall77,griesemer,robpike,ianlancetaylor instead of khr,gri,r,iant. The algorithm for expanding short user names is as follows: Look at the git commit log for the current repository, extracting all the email addresses in Reviewed-By lines and sorting by how many times each address appears. For each short user name, walk the list, most common address first, and use the first address found that has the short user name on the left side of the @. This is a purely local operation, it adjusts automatically as new reviewers come on board, it avoids a separate database, it adjusts to repo-specific reviewer patterns, and it resolves potential ambiguity in favor of the most common reviewers. (For example, r@golang.org will beat any other r@mail.com in the main repo.) Change-Id: I53afea2a86ba4cfa8fd7f31d56b90a3e12cc2b48 Reviewed-on: https://go-review.googlesource.com/2111 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-30git-codereview: guard against ambiguous revision parametersAnthony Martin
Change-Id: I3afcf06e1eab28bfdb2c6ace7aaf774070084900 Reviewed-on: https://go-review.googlesource.com/1783 Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-18git-codereview: rename from 'git-review' to 'git-codereview'Andrew Gerrand
Mostly trivial search and replace, except for hooks.go which includes a special case to remove the old git-review hooks. Change-Id: Ic0792bb3e26607e5e0ead88958e46c3ac08288cd Reviewed-on: https://go-review.googlesource.com/1741 Reviewed-by: Russ Cox <rsc@golang.org>