From 1a4c984baea846a06e95440b2192eec1bc29917a Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Wed, 14 Jan 2015 21:39:18 +1100 Subject: [PATCH] misc/makerelease: check out core from git repo, use new oauth2 package Change-Id: I072cf2b9149a05901cc19e7aeb0e9d0936a8dbe3 Reviewed-on: https://go-review.googlesource.com/2793 Reviewed-by: Brad Fitzpatrick --- misc/makerelease/makerelease.go | 76 ++++++++++++++++----------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/misc/makerelease/makerelease.go b/misc/makerelease/makerelease.go index 43b1f3d115..f1b643cca9 100644 --- a/misc/makerelease/makerelease.go +++ b/misc/makerelease/makerelease.go @@ -30,15 +30,16 @@ import ( "runtime" "strings" - "code.google.com/p/goauth2/oauth" storage "code.google.com/p/google-api-go-client/storage/v1" + "golang.org/x/oauth2" + "golang.org/x/oauth2/google" ) var ( - tag = flag.String("tag", "release", "mercurial tag to check out") - toolTag = flag.String("tool", defaultToolTag, "go.tools tag to check out") + tag = flag.String("tag", "", "git revision to check out") + toolTag = flag.String("tool", defaultToolTag, "go.tools revision to check out") tourTag = flag.String("tour", defaultTourTag, "go-tour tag to check out") - repo = flag.String("repo", "https://code.google.com/p/go", "repo URL") + repo = flag.String("repo", "https://go.googlesource.com/go", "repo URL") verbose = flag.Bool("v", false, "verbose output") upload = flag.Bool("upload", false, "upload resulting files to Google Code") addLabel = flag.String("label", "", "additional label to apply to file when uploading") @@ -80,9 +81,9 @@ var preBuildCleanFiles = []string{ } var cleanFiles = []string{ - ".hg", - ".hgtags", - ".hgignore", + ".git", + ".gitignore", + ".gitattributes", "VERSION.cache", } @@ -140,6 +141,10 @@ func main() { os.Exit(2) } flag.Parse() + if *tag == "" { + fmt.Fprintln(os.Stderr, "you must specify a -tag") + os.Exit(2) + } if flag.NArg() == 0 { flag.Usage() } @@ -236,11 +241,11 @@ func (b *Build) Do() error { b.gopath = work // Clone Go distribution and update to tag. - _, err = b.hgCmd(work, "clone", *repo, b.root) + _, err = b.run(work, "git", "clone", *repo, b.root) if err != nil { return err } - _, err = b.hgCmd(b.root, "update", *tag) + _, err = b.run(b.root, "git", "checkout", *tag) if err != nil { return err } @@ -620,10 +625,6 @@ func ext() string { return "" } -func (b *Build) hgCmd(dir string, args ...string) ([]byte, error) { - return b.run(dir, "hg", append([]string{"--config", "extensions.codereview=!"}, args...)...) -} - func (b *Build) run(dir, name string, args ...string) ([]byte, error) { buf := new(bytes.Buffer) absName, err := lookPath(name) @@ -749,33 +750,26 @@ type File struct { } func setupOAuthClient() error { - config := &oauth.Config{ - ClientId: "999119582588-h7kpj5pcm6d9solh5lgrbusmvvk4m9dn.apps.googleusercontent.com", + config := &oauth2.Config{ + ClientID: "999119582588-h7kpj5pcm6d9solh5lgrbusmvvk4m9dn.apps.googleusercontent.com", ClientSecret: "8YLFgOhXIELWbO-NtF3iqIQz", - Scope: storage.DevstorageRead_writeScope, - AuthURL: "https://accounts.google.com/o/oauth2/auth", - TokenURL: "https://accounts.google.com/o/oauth2/token", - TokenCache: oauth.CacheFile(*tokenCache), - RedirectURL: "oob", - } - transport := &oauth.Transport{Config: config} - if token, err := config.TokenCache.Token(); err != nil { - url := transport.Config.AuthCodeURL("") - fmt.Println("Visit the following URL, obtain an authentication" + - "code, and enter it below.") - fmt.Println(url) - fmt.Print("Enter authentication code: ") - code := "" - if _, err := fmt.Scan(&code); err != nil { - return err - } - if _, err := transport.Exchange(code); err != nil { - return err - } - } else { - transport.Token = token + Endpoint: google.Endpoint, + Scopes: []string{storage.DevstorageRead_writeScope}, + } + url := config.AuthCodeURL("junk") + fmt.Println("Visit the following URL, obtain an authentication" + + "code, and enter it below.") + fmt.Println(url) + fmt.Print("Enter authentication code: ") + code := "" + if _, err := fmt.Scan(&code); err != nil { + return err } - oauthClient = transport.Client() + tok, err := config.Exchange(oauth2.NoContext, code) + if err != nil { + return err + } + oauthClient = config.Client(oauth2.NoContext, tok) return nil } @@ -1011,6 +1005,11 @@ var hgTool = tool{ }, } +var gitTool = tool{ + "http://git-scm.com/download/win", + []string{`C:\Program Files\Git`, `C:\Program Files (x86)\Git`}, +} + var gccTool = tool{ "Mingw gcc; http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/", []string{`C:\Mingw\bin`}, @@ -1022,6 +1021,7 @@ var windowsDeps = map[string]tool{ "candle": wixTool, "light": wixTool, "cmd": {"Windows cmd.exe", nil}, + "git": gitTool, "hg": hgTool, } -- 2.50.0