diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-11-30 19:04:34 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-11-30 19:04:34 -0500 |
commit | d14b88c9b4d03674a1a8ba631fe1330ddd457d56 (patch) | |
tree | 4b8ccd213bee921d3fcb32cbc5fe18063ba61c0b | |
parent | 492a8aed301a83d48281c3d28246ed7d2c5fb195 (diff) |
fixo
-rw-r--r-- | filter.go | 3 | ||||
-rw-r--r-- | git.go | 11 | ||||
-rw-r--r-- | heuristics.go | 3 | ||||
-rw-r--r-- | main.go | 5 |
4 files changed, 13 insertions, 9 deletions
@@ -82,6 +82,9 @@ func (f *Filter) pkgbuild2srcinfo(pkgbuildId string) (string, error) { // Read the PKGBUILD sha1, data, err := f.backend.CatBlob(libfastimport.CmdCatBlob{DataRef: pkgbuildId}) + if err != nil { + return "", err + } if sha1 != pkgbuildId { return "", fmt.Errorf("PKGBUILD sha1 mismatch: %q != %q", pkgbuildId, sha1) } @@ -92,13 +92,14 @@ func gitRefs() (map[string]string, error) { if line == "" { continue } - fields := strings.SplitN(line, " ", 3) - if len(fields) != 3 { + sp := strings.IndexByte(line, ' ') + ht := strings.IndexByte(line, '\t') + if sp < 0 || ht < sp { return nil, fmt.Errorf("malformed git for-each-ref line: %q", line) } - refTarget := fields[0] - refType := fields[1] - refName := fields[2] + refTarget := line[:sp] + refType := line[sp+1 : ht] + refName := line[ht+1:] if refType != "commit" { continue } diff --git a/heuristics.go b/heuristics.go index 9fc44e5..4047e25 100644 --- a/heuristics.go +++ b/heuristics.go @@ -30,6 +30,7 @@ func filename2branchname(filename string) string { } // This blackliast assumes that no package named one of those // strings will ever exist. +loop: for { switch path.Base(branchname) { case "log", "src": // packages.git @@ -39,7 +40,7 @@ func filename2branchname(filename string) string { case "repos": return "" default: - break + break loop } } // A branch must contain a "/" @@ -15,7 +15,7 @@ func fmtDuration(d time.Duration) string { d -= m * time.Minute s := d / time.Second - return fmt.Sprintf("%02d:%02d:%02", h, m, s) + return fmt.Sprintf("%02d:%02d:%02d", h, m, s) } func usage(w io.Writer) { @@ -49,7 +49,7 @@ func main() { maxline := 0 status := func() { duration := time.Since(beg) - line := fmt.Sprintf("[%s] commits (%.2f commit/s)", + line := fmt.Sprintf("[%s] %d commits (%.2f commit/s)", fmtDuration(duration), commits, float64(commits)/duration.Seconds()) @@ -71,7 +71,6 @@ func main() { } err = filter.Run() - status() fmt.Fprintln(os.Stderr) if err != nil { fmt.Fprintln(os.Stderr, "Error:", err) |