summaryrefslogtreecommitdiff
path: root/repo.Stats.go
diff options
context:
space:
mode:
Diffstat (limited to 'repo.Stats.go')
-rw-r--r--repo.Stats.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/repo.Stats.go b/repo.Stats.go
index 03e10d8..d71bf60 100644
--- a/repo.Stats.go
+++ b/repo.Stats.go
@@ -20,13 +20,15 @@ func initStats() {
}
}
-func (r *Repo) LoadStats() (*Stats, error) {
- filename := filepath.Join(r.FullPath, ".git/", "stats.pb")
- if fileExists(filename) {
- newfilename := filepath.Join(r.FullPath, ".git/origin.pb")
- os.Rename(filename, newfilename)
+func (r *Repo) LoadStats(remote string) (*Stats, error) {
+ fullname := filepath.Join(r.FullPath, ".git/", remote+".pb")
+ if !fileExists(fullname) {
+ return nil, os.ErrNotExist
}
- return r.Stats(), nil
+ stats := NewStats()
+ stats.Filename = fullname
+ err := config.ReLoad(stats)
+ return stats, err
}
func (r *Repo) Stats() *Stats {
@@ -55,7 +57,7 @@ func (r *Repo) Stats() *Stats {
return origin
}
-// todo: move this somewhere
+// todo: move this somewhere. where should it go?
// fileExists checks if a file exists and is not a directory.
func fileExists(filename string) bool {
info, err := os.Stat(filename)