"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")
}
var cleanFiles = []string{
- ".hg",
- ".hgtags",
- ".hgignore",
+ ".git",
+ ".gitignore",
+ ".gitattributes",
"VERSION.cache",
}
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()
}
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
}
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)
}
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
}
},
}
+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`},
"candle": wixTool,
"light": wixTool,
"cmd": {"Windows cmd.exe", nil},
+ "git": gitTool,
"hg": hgTool,
}