From 76622760f034591c2a88cf900d664078099649c7 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Wed, 12 Jul 2017 21:39:45 -0600 Subject: [PATCH] cmd/go-contrib-init: match subdomain-less .gitcookies file My `.gitcookies` file starts with ".googlesource.com", which errored because it did not match "go.googlesource.com" or "go-review.googlesource.com". Fix this by optionally matching on "go.googlesource.com" or ".googlesource.com". Fixes golang/go#20992. Change-Id: I29d3c0b1e958382495a90502f280bdb52868c2c7 Reviewed-on: https://go-review.googlesource.com/48230 Reviewed-by: Brad Fitzpatrick --- cmd/go-contrib-init/contrib.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/go-contrib-init/contrib.go b/cmd/go-contrib-init/contrib.go index 112ecfe84f..cb96453b46 100644 --- a/cmd/go-contrib-init/contrib.go +++ b/cmd/go-contrib-init/contrib.go @@ -18,6 +18,7 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "runtime" "strings" ) @@ -62,13 +63,14 @@ func detectrepo() string { return "go" } +var googleSourceRx = regexp.MustCompile(`(?m)^(go|go-review)?\.googlesource.com\b`) + func checkCLA() { slurp, err := ioutil.ReadFile(cookiesFile()) if err != nil && !os.IsNotExist(err) { log.Fatal(err) } - if bytes.Contains(slurp, []byte("go.googlesource.com")) && - bytes.Contains(slurp, []byte("go-review.googlesource.com")) { + if googleSourceRx.Match(slurp) { // Probably good. return }