diff --git a/dashboard/dashboard.go b/dashboard/dashboard.go index 3eae2cc3e..2e69036f4 100644 --- a/dashboard/dashboard.go +++ b/dashboard/dashboard.go @@ -142,7 +142,12 @@ func saveCache(path string, cache map[string]statusLine) { } } -func fetchCommits(repoPath string) map[string]int { +type commitInfo struct { + Hash string + Title string +} + +func fetchCommits(repoPath string) ([]commitInfo, map[string]int) { if _, err := os.Stat(filepath.Join(repoPath, "HEAD")); err == nil { cmd := exec.Command("git", "--git-dir="+repoPath, "fetch", "-u", "--no-tags", "--filter=tree:0", "origin", "+main:main") if out, err := cmd.CombinedOutput(); err != nil { @@ -153,25 +158,36 @@ func fetchCommits(repoPath string) map[string]int { cmd := exec.Command("git", "clone", "--bare", "--no-tags", "--filter=tree:0", "--depth=10000", "--single-branch", "-b", "main", "https://github.com/llvm/llvm-project.git", repoPath) if out, err := cmd.CombinedOutput(); err != nil { fmt.Fprintf(os.Stderr, "git clone failed: %v: %s\n", err, out) - return nil + return nil, nil } } - out, err := exec.Command("git", "--git-dir="+repoPath, "rev-list", "-n", "10000", "main").Output() + out, err := exec.Command("git", "--git-dir="+repoPath, "log", "-n", "10000", "--format=%H\t%s", "main").Output() if err != nil { - fmt.Fprintf(os.Stderr, "git rev-list failed: %v\n", err) - return nil + fmt.Fprintf(os.Stderr, "git log failed: %v\n", err) + return nil, nil + } + lines := strings.Split(strings.TrimSpace(string(out)), "\n") + var list []commitInfo + commits := make(map[string]int, len(lines)) + for _, line := range lines { + if line == "" { + continue + } + parts := strings.SplitN(line, "\t", 2) + h := parts[0] + title := "" + if len(parts) > 1 { + title = parts[1] + } + commits[h] = len(list) + list = append(list, commitInfo{Hash: h, Title: title}) } - hashes := strings.Fields(string(out)) topCommit := "" - if len(hashes) > 0 { - topCommit = hashes[0] - } - fmt.Fprintf(os.Stderr, "Loaded %d commits from %s (top: %s)\n", len(hashes), repoPath, topCommit) - commits := make(map[string]int, len(hashes)) - for i, h := range hashes { - commits[h] = i + if len(list) > 0 { + topCommit = list[0].Hash } - return commits + fmt.Fprintf(os.Stderr, "Loaded %d commits from %s (top: %s)\n", len(list), repoPath, topCommit) + return list, commits } func mergeStatusLine(fresh, cached statusLine) statusLine { @@ -481,7 +497,9 @@ func main() {