aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/reword.go
diff options
context:
space:
mode:
authorDmitri Shuralyov <dmitshur@golang.org>2023-10-01 14:25:52 -0400
committerGopher Robot <gobot@golang.org>2023-10-02 13:50:15 +0000
commitf951e778cd57702302a4e97251e4fc67a98fd3ec (patch)
tree100eed87b0381c3ace8d395c2377d2760cb93a8c /git-codereview/reword.go
parentdbef367af75863876323ec31693d7cd0d65d5f9e (diff)
downloadgo-x-review-f951e778cd57702302a4e97251e4fc67a98fd3ec.tar.xz
git-codereview: use strings.Cutv1.7.0
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>
Diffstat (limited to 'git-codereview/reword.go')
-rw-r--r--git-codereview/reword.go12
1 files changed, 2 insertions, 10 deletions
diff --git a/git-codereview/reword.go b/git-codereview/reword.go
index 5948502..8f12405 100644
--- a/git-codereview/reword.go
+++ b/git-codereview/reword.go
@@ -142,11 +142,11 @@ func cmdReword(args []string) {
text = "# " + text // restore split separator
// Pull out # hash header line and body.
- hdr, body, _ := cut(text, "\n")
+ hdr, body, _ := strings.Cut(text, "\n")
// Cut blank lines at start and end of body but keep newline-terminated.
for body != "" {
- line, rest, _ := cut(body, "\n")
+ line, rest, _ := strings.Cut(body, "\n")
if line != "" {
break
}
@@ -221,14 +221,6 @@ func cmdReword(args []string) {
run("git", "reset", "--soft", newHash)
}
-func cut(s, sep string) (before, after string, ok bool) {
- i := strings.Index(s, sep)
- if i < 0 {
- return s, "", false
- }
- return s[:i], s[i+len(sep):], true
-}
-
var rewordProlog = `Rewording multiple commit messages.
The # lines separate the different commits and must be left unchanged.
`