Commit 1a4c984b authored by Andrew Gerrand's avatar Andrew Gerrand

misc/makerelease: check out core from git repo, use new oauth2 package

Change-Id: I072cf2b9149a05901cc19e7aeb0e9d0936a8dbe3
Reviewed-on: https://go-review.googlesource.com/2793Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 6482fe6c
...@@ -30,15 +30,16 @@ import ( ...@@ -30,15 +30,16 @@ import (
"runtime" "runtime"
"strings" "strings"
"code.google.com/p/goauth2/oauth"
storage "code.google.com/p/google-api-go-client/storage/v1" storage "code.google.com/p/google-api-go-client/storage/v1"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
) )
var ( var (
tag = flag.String("tag", "release", "mercurial tag to check out") tag = flag.String("tag", "", "git revision to check out")
toolTag = flag.String("tool", defaultToolTag, "go.tools tag 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") 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") verbose = flag.Bool("v", false, "verbose output")
upload = flag.Bool("upload", false, "upload resulting files to Google Code") upload = flag.Bool("upload", false, "upload resulting files to Google Code")
addLabel = flag.String("label", "", "additional label to apply to file when uploading") addLabel = flag.String("label", "", "additional label to apply to file when uploading")
...@@ -80,9 +81,9 @@ var preBuildCleanFiles = []string{ ...@@ -80,9 +81,9 @@ var preBuildCleanFiles = []string{
} }
var cleanFiles = []string{ var cleanFiles = []string{
".hg", ".git",
".hgtags", ".gitignore",
".hgignore", ".gitattributes",
"VERSION.cache", "VERSION.cache",
} }
...@@ -140,6 +141,10 @@ func main() { ...@@ -140,6 +141,10 @@ func main() {
os.Exit(2) os.Exit(2)
} }
flag.Parse() flag.Parse()
if *tag == "" {
fmt.Fprintln(os.Stderr, "you must specify a -tag")
os.Exit(2)
}
if flag.NArg() == 0 { if flag.NArg() == 0 {
flag.Usage() flag.Usage()
} }
...@@ -236,11 +241,11 @@ func (b *Build) Do() error { ...@@ -236,11 +241,11 @@ func (b *Build) Do() error {
b.gopath = work b.gopath = work
// Clone Go distribution and update to tag. // 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 { if err != nil {
return err return err
} }
_, err = b.hgCmd(b.root, "update", *tag) _, err = b.run(b.root, "git", "checkout", *tag)
if err != nil { if err != nil {
return err return err
} }
...@@ -620,10 +625,6 @@ func ext() string { ...@@ -620,10 +625,6 @@ func ext() string {
return "" 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) { func (b *Build) run(dir, name string, args ...string) ([]byte, error) {
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
absName, err := lookPath(name) absName, err := lookPath(name)
...@@ -749,33 +750,26 @@ type File struct { ...@@ -749,33 +750,26 @@ type File struct {
} }
func setupOAuthClient() error { func setupOAuthClient() error {
config := &oauth.Config{ config := &oauth2.Config{
ClientId: "999119582588-h7kpj5pcm6d9solh5lgrbusmvvk4m9dn.apps.googleusercontent.com", ClientID: "999119582588-h7kpj5pcm6d9solh5lgrbusmvvk4m9dn.apps.googleusercontent.com",
ClientSecret: "8YLFgOhXIELWbO-NtF3iqIQz", ClientSecret: "8YLFgOhXIELWbO-NtF3iqIQz",
Scope: storage.DevstorageRead_writeScope, Endpoint: google.Endpoint,
AuthURL: "https://accounts.google.com/o/oauth2/auth", Scopes: []string{storage.DevstorageRead_writeScope},
TokenURL: "https://accounts.google.com/o/oauth2/token", }
TokenCache: oauth.CacheFile(*tokenCache), url := config.AuthCodeURL("junk")
RedirectURL: "oob", fmt.Println("Visit the following URL, obtain an authentication" +
} "code, and enter it below.")
transport := &oauth.Transport{Config: config} fmt.Println(url)
if token, err := config.TokenCache.Token(); err != nil { fmt.Print("Enter authentication code: ")
url := transport.Config.AuthCodeURL("") code := ""
fmt.Println("Visit the following URL, obtain an authentication" + if _, err := fmt.Scan(&code); err != nil {
"code, and enter it below.") return err
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
} }
oauthClient = transport.Client() tok, err := config.Exchange(oauth2.NoContext, code)
if err != nil {
return err
}
oauthClient = config.Client(oauth2.NoContext, tok)
return nil return nil
} }
...@@ -1011,6 +1005,11 @@ var hgTool = tool{ ...@@ -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{ var gccTool = tool{
"Mingw gcc; http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/", "Mingw gcc; http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/",
[]string{`C:\Mingw\bin`}, []string{`C:\Mingw\bin`},
...@@ -1022,6 +1021,7 @@ var windowsDeps = map[string]tool{ ...@@ -1022,6 +1021,7 @@ var windowsDeps = map[string]tool{
"candle": wixTool, "candle": wixTool,
"light": wixTool, "light": wixTool,
"cmd": {"Windows cmd.exe", nil}, "cmd": {"Windows cmd.exe", nil},
"git": gitTool,
"hg": hgTool, "hg": hgTool,
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment