diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-04-20 15:44:41 +0200 | 
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-04-20 15:44:41 +0200 | 
| commit | 50104cc32a498f7517a51c8dc93106c51c7a54b4 (patch) | |
| tree | 47af80be259cc7c45d0eaec7d42e61fa38c8e4fb /misc/dashboard/builder/hg.go | |
| parent | c072558b90f1bbedc2022b0f30c8b1ac4712538e (diff) | |
| download | golang-50104cc32a498f7517a51c8dc93106c51c7a54b4.tar.gz | |
Imported Upstream version 2011.03.07.1upstream/2011.03.07.1
Diffstat (limited to 'misc/dashboard/builder/hg.go')
| -rw-r--r-- | misc/dashboard/builder/hg.go | 34 | 
1 files changed, 33 insertions, 1 deletions
| diff --git a/misc/dashboard/builder/hg.go b/misc/dashboard/builder/hg.go index 5d2f63a17..d4310845d 100644 --- a/misc/dashboard/builder/hg.go +++ b/misc/dashboard/builder/hg.go @@ -1,8 +1,13 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +  package main  import (  	"fmt"  	"os" +	"regexp"  	"strconv"  	"strings"  ) @@ -46,9 +51,36 @@ func getCommit(rev string) (c Commit, err os.Error) {  func getCommitParts(rev string) (parts []string, err os.Error) {  	const format = "{rev}>{node}>{author|escape}>{date}>{desc}"  	s, _, err := runLog(nil, "", goroot, -		"hg", "log", "-r", rev, "-l", "1", "--template", format) +		"hg", "log", +		"--encoding", "utf-8", +		"--rev", rev, +		"--limit", "1", +		"--template", format, +	)  	if err != nil {  		return  	}  	return strings.Split(s, ">", 5), nil  } + +var revisionRe = regexp.MustCompile(`([0-9]+):[0-9a-f]+$`) + +// getTag fetches a Commit by finding the first hg tag that matches re. +func getTag(re *regexp.Regexp) (c Commit, tag string, err os.Error) { +	o, _, err := runLog(nil, "", goroot, "hg", "tags") +	for _, l := range strings.Split(o, "\n", -1) { +		tag = re.FindString(l) +		if tag == "" { +			continue +		} +		s := revisionRe.FindStringSubmatch(l) +		if s == nil { +			err = os.NewError("couldn't find revision number") +			return +		} +		c, err = getCommit(s[1]) +		return +	} +	err = os.NewError("no matching tag found") +	return +} | 
