func dashStatus(meth, cmd string, args param) os.Error {
var resp struct {
Status string
- Error string
+ Error string
}
err := dash(meth, cmd, &resp, args)
if err != nil {
if resp.Status != "OK" {
return os.NewError("/build: " + resp.Error)
}
- return nil
+ return nil
}
-
+
// todo returns the next hash to build.
func (b *Builder) todo() (rev string, err os.Error) {
- var resp []struct{
+ var resp []struct {
Hash string
}
if err = dash("GET", "todo", &resp, param{"builder": b.name}); err != nil {
// postCommit informs the dashboard of a new commit
func postCommit(key string, l *HgLog) os.Error {
return dashStatus("POST", "commit", param{
- "key": key,
- "node": l.Hash,
- "date": l.Date,
- "user": l.Author,
+ "key": key,
+ "node": l.Hash,
+ "date": l.Date,
+ "user": l.Author,
"parent": l.Parent,
- "desc": l.Desc,
+ "desc": l.Desc,
})
}
var (
buildroot = flag.String("buildroot", path.Join(os.TempDir(), "gobuilder"), "Directory under which to build")
- commitFlag = flag.Bool("commit", false, "upload information about new commits")
+ commitFlag = flag.Bool("commit", false, "upload information about new commits")
dashboard = flag.String("dashboard", "godashboard.appspot.com", "Go Dashboard Host")
buildRelease = flag.Bool("release", false, "Build and upload binary release archives")
buildRevision = flag.String("rev", "", "Build specified revision and exit")
if err := run(nil, *buildroot, "hg", "clone", hgUrl, goroot); err != nil {
log.Fatal("Error cloning repository:", err)
}
-
+
if *commitFlag {
if len(flag.Args()) == 0 {
commitWatcher()
return false
}
// Look for hash locally before running hg pull.
-
+
if _, err := fullHash(hash[:12]); err != nil {
// Don't have hash, so run hg pull.
if err := run(nil, goroot, "hg", "pull"); err != nil {
// HgLog represents a single Mercurial revision.
type HgLog struct {
- Hash string
+ Hash string
Author string
- Date string
- Desc string
+ Date string
+ Desc string
Parent string
-
+
// Internal metadata
added bool
}
log.Printf("hg pull: %v", err)
return
}
-
- const N = 20 // how many revisions to grab
+
+ const N = 20 // how many revisions to grab
data, _, err := runLog(nil, "", goroot, "hg", "log",
"--encoding=utf-8",
- "--limit=" + strconv.Itoa(N),
- "--template=" + xmlLogTemplate,
+ "--limit="+strconv.Itoa(N),
+ "--template="+xmlLogTemplate,
)
if err != nil {
log.Printf("hg log: %v", err)
return
}
-
+
var logStruct struct {
Log []HgLog
}
- err = xml.Unmarshal(strings.NewReader("<top>" + data + "</top>"), &logStruct)
+ err = xml.Unmarshal(strings.NewReader("<top>"+data+"</top>"), &logStruct)
if err != nil {
log.Printf("unmarshal hg log: %v", err)
return
// Can't create node without parent.
continue
}
-
+
if logByHash[l.Hash] == nil {
// Make copy to avoid pinning entire slice when only one entry is new.
t := *l
if l.added {
return true
}
-
+
// Check for already added, perhaps in an earlier run.
if dashboardCommit(hash) {
log.Printf("%s already on dashboard\n", hash)
}
if i > 0 {
- if mode&commaSep != 0 {
+ switch {
+ case mode&commaSep != 0:
p.print(token.COMMA)
- }
- if mode&periodSep != 0 {
+ case mode&periodSep != 0:
p.print(token.PERIOD)
}
+ needsBlank := mode&periodSep == 0 // period-separated list elements don't need a blank
if prevLine < line && prevLine > 0 && line > 0 {
// lines are broken using newlines so comments remain aligned
// unless forceFF is set or there are multiple expressions on
ws = ignore
*multiLine = true
prevBreak = i
+ needsBlank = false // we got a line break instead
}
- } else if mode&periodSep == 0 {
+ }
+ if needsBlank {
p.print(blank)
}
- // period-separated list elements don't need a blank
}
if isPair && size > 0 && len(list) > 1 {