summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gitConfig.proto2
-rw-r--r--repo.Stats.go16
-rw-r--r--repo.proto1
-rw-r--r--stat.proto2
4 files changed, 13 insertions, 8 deletions
diff --git a/gitConfig.proto b/gitConfig.proto
index 094e204..740cfe1 100644
--- a/gitConfig.proto
+++ b/gitConfig.proto
@@ -2,6 +2,7 @@ syntax = "proto3";
package gitpb;
+import "stat.proto";
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
message GitRemote { // `autogenpb:nomutex`
@@ -14,6 +15,7 @@ message GitBranch { // `autogenpb:nomutex`
string name = 1; // the branch name from the config file
string remote = 2; // the name of the remote repo
string merge = 3; // the merge path from the config file
+ Stat stat = 4; // a git stat proto msg
}
message GitConfig { // `autogenpb:nomutex`
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)
diff --git a/repo.proto b/repo.proto
index be8088c..dbc0268 100644
--- a/repo.proto
+++ b/repo.proto
@@ -5,6 +5,7 @@ package gitpb;
// stores information about git repos
// If the project is in golang, also gets the go language dependacies
+import "stat.proto";
import "gitTag.proto";
import "goDep.proto";
import "gitConfig.proto";
diff --git a/stat.proto b/stat.proto
index 2adcf28..dbf9e46 100644
--- a/stat.proto
+++ b/stat.proto
@@ -14,7 +14,7 @@ message Stat {
TAG = 3;
}
string patchId = 1; // `autogenpb:unique` `autogenpb:sort`
- string hash = 2; // `autogenpb:unique` // git hash
+ string hash = 2; // `autogenpb:unique` `autogenpb:sort`
google.protobuf.Timestamp ctime = 3; // `autogenpb:unique` `autogenpb:sort`
string name = 4; //
string remote = 5; // blank unless REMOTE