1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:24:41 -07:00

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 <bradfitz@golang.org>
This commit is contained in:
Kevin Burke 2017-07-12 21:39:45 -06:00
parent bce9606b3f
commit 76622760f0

View File

@ -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
}