aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/gofmt.go
AgeCommit message (Collapse)Author
5 daysgit-codereview: support remote other than "origin"HEADmainShulhan
For the git-codereview commands to works on any Go's repositories, the remote name for "origin" must be pointed to the Go original repository URL (in most cases the one with go.googlesource.com domain). The problem is when the "origin" is from the fork, all of the git-codereview commands then will not works. For example, in computer X, I clone the this repository from "https://go.googlesource.com/review" (the origin) and then push my changes on "git@git.sr.ht:~shulhan/go-x-review" (the fork). In another computer Y, I then clone from the fork to continue my works. The fork become origin. One of the solution is to rename the remote names manually each time we clone the fork. The only cons using this solution is every time new branch created we need to remember to pass "--set-upstream" during git push. This changes introduce "remote" configuration in codereview.cfg. When one first working on fork of Go repository, they set the "remote" key, commit it, and push it. When they cloned the fork, they did not needs to changes anything except adding new remote using the pre-defined name. Change-Id: I335d08fd8b7efe17ba07b3c0a3794f9ccf59b339
2023-10-02git-codereview: use strings.Cutv1.7.0Dmitri Shuralyov
Basic cut functionality is available in the standard library as of Go 1.18, so today's supported Go versions (1.21 & 1.20) can use it. Also simplify some slice and map code while here. Change-Id: Ie887fc2dad542cd9a830974cf9c8373baa81ad8b Reviewed-on: https://go-review.googlesource.com/c/review/+/531955 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2021-01-13git-codereview: clean up detached HEAD modeRuss Cox
Long ago I decided to return origin/HEAD from b.OriginBranch in detached HEAD mode, thinking it would cause obvious failures. But the joke was on me - origin/HEAD is a real thing in git, and HEAD tracking origin/HEAD is not the right answer on dev branches. Now that each branch's codereview.cfg typically has the branch info we need, we can use that in detached HEAD mode to be able to provide useful displays in commands like "git pending". And we can be careful not to do that when we don't know the actual branch. This commit cleans all that up. Change-Id: I0e59bcb6f9b61e0cdce7a27299b7f29fef8e7048 Reviewed-on: https://go-review.googlesource.com/c/review/+/282616 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-07git-codereview: add a few more testsRuss Cox
Change-Id: I17ad065e8b4c1eb00cdd2f17af82be76bae4fc09 Reviewed-on: https://go-review.googlesource.com/c/review/+/279717 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22git-codereview: clean up usage message, docsRuss Cox
Change-Id: I634a9d47401c1000bcb38e9dd7e84296a3de00e6 Reviewed-on: https://go-review.googlesource.com/c/review/+/254746 Trust: Russ Cox <rsc@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-04-22git-codereview: do not require gofmt for testdata filesRebecca Stambler
We use Go files as testdata for gopls, specifically as test cases for formatting and imports. Change-Id: Ie4ed6097960eb0eb3d5c1767b8b76bed147c81e0 Reviewed-on: https://go-review.googlesource.com/c/review/+/173339 Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-22git-codereview: do not check vendor folder with gofmtDaniel Theophanes
The go command already skips the vendor folder when running go fmt. The "go mod vendor" command updates all vendor packages at once, so this becomes more of an issue. Change-Id: I0b2d51d2f1f01998e9ca7a244af491bd18150e8a Reviewed-on: https://go-review.googlesource.com/c/158839 Run-TryBot: Daniel Theophanes <kardianos@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-29git-codereview: require test/run.go to be gofmt'dJosh Bleecher Snyder
See CL 9398 for an instance in which this matters. Change-Id: If590791e9080b89517536aa80a04cbf2f5fbc3e1 Reviewed-on: https://go-review.googlesource.com/9416 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-30git-codereview: use cmd prefix on command implementation funcsRuss Cox
The name space is getting a bit crowded. These words are too easy to use for other variables or functions. Change-Id: Iedbccb82f85627fe422a029a6b45ad39a2e18dd0 Reviewed-on: https://go-review.googlesource.com/3627 Reviewed-by: Rob Pike <r@golang.org>
2015-01-30git-codereview: revise pendingRuss Cox
- Use multiple commit output form always. We're going to start suggesting the use of multiple commits, and it is confusing to flip between the two displays based on the number of commits. - Document pending -c option (current branch only). - Add pending -s option (short form). While doing this, I got my client into a state where I had a tag and a branch with the same name. Make things work in that mode too. Change-Id: I4a3d73ce88be78b04d5bc4e56f1e3bed435cfde7 Reviewed-on: https://go-review.googlesource.com/3621 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2015-01-19git-codereview: work around git checkout-index bug in gofmtRuss Cox
If you run 'git gofmt' when files in the working directory differ from modified files in the index and you are running the command not from that working directory or a parent, then git checkout-index --temp (used by git gofmt) will print mangled path names, confusing git gofmt. The most common error this causes is: git-codereview: gofmt reported errors: stat : no such file or directory although there are other possible ways it can fail. I've reported the git bug, which will be fixed in Git 2.3.0. Work around the bug by always invoking git checkout-index in the repo root. Fixes #9476. Change-Id: Ifcbdfd4a966dd21518dd95ceacd81a1679048e3c Reviewed-on: https://go-review.googlesource.com/2907 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-19git-codereview: refactor getOutput/getLines into cmdOutput, trim, lines, ↵Russ Cox
nonBlankLines This CL separates the "run the command and gather output" from the "process output" operations. Doing so makes the desired processing clearer, makes the processing available for use on other text sources. Also, add cmdOutputDir, for running a command in a different directory. This is needed by the gofmt command to work around a bug in Git, and it's made much easier by the above separation. Change-Id: I2addd8b79dab2d4aa8a24c94a8d7b3a16a8e3484 Reviewed-on: https://go-review.googlesource.com/2906 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-14git-codereview: do not gofmt committed files during mergeRuss Cox
Change-Id: Ie772b8f46587ad0d56350b697e75601f45b4c393 Reviewed-on: https://go-review.googlesource.com/2785 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-14git-codereview: document short names in mail commandRuss Cox
While we're here, fix bug in git-codereview gofmt usage message. Change-Id: I547b8ae6fab01db1bc6b44b0e706d8faadbb60a9 Reviewed-on: https://go-review.googlesource.com/2781 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-06git-codereview: make tests pass on windowsAlex Brainman
- "git gofmt" uses "git checkout-index" command that is broken if used with many arguments - limit number of arguments passed to "git checkout-index"; - change / into \ on windows when matching git output on windows; - add .gitattributes to test repository to make it look more like all real Go repositories; - make sure no files left behind in /tmp on windows. Fixes golang/go#9433. Change-Id: Ifceacfffd1cd4b02190d7e941611d0d0f3c48cdd Reviewed-on: https://go-review.googlesource.com/2089 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-05git-codereview: print gofmt commands in verbose modeJosh Bleecher Snyder
Change-Id: I589b8daa3504b99374796079bace5a9f4aa0620d Reviewed-on: https://go-review.googlesource.com/2194 Reviewed-by: Russ Cox <rsc@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-23git-codereview: fix a few corner case failuresRuss Cox
- make it clearer what the random git command at the end of failures means - avoid some problems with detached HEAD mode in hooks run during git rebase - redirect all stdout/stderr into test buffers Change-Id: I102f22fc870f69c884728eaa46ecc95792d5b795 Reviewed-on: https://go-review.googlesource.com/2011 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Austin Clements <austin@google.com>
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>