weird. NewestAge() took _seconds_ to run in some cases
This commit is contained in:
parent
328fbe9fdd
commit
40830d3f38
|
@ -31,10 +31,13 @@ func (a GitTagAge) Less(i, j int) bool {
|
||||||
func (a GitTagAge) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
func (a GitTagAge) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||||
|
|
||||||
func (repo *Repo) NewestAge() time.Duration {
|
func (repo *Repo) NewestAge() time.Duration {
|
||||||
all := repo.Tags.SortByAge()
|
return time.Since(repo.Times.NewestCommit.AsTime())
|
||||||
for all.Scan() {
|
/*
|
||||||
r := all.Next()
|
all := repo.Tags.SortByAge()
|
||||||
return time.Since(r.GetAuthordate().AsTime())
|
for all.Scan() {
|
||||||
}
|
r := all.Next()
|
||||||
return time.Since(time.Now())
|
return time.Since(r.GetAuthordate().AsTime())
|
||||||
|
}
|
||||||
|
return time.Since(time.Now())
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,18 @@ func (repo *Repo) reloadGitTags() error {
|
||||||
|
|
||||||
repo.Tags.Append(&newr)
|
repo.Tags.Append(&newr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// also set the repo.NewestCommit
|
||||||
|
cmd = []string{"git", "log", "-1", "--format=%cd"}
|
||||||
|
result = shell.PathRunQuiet(repo.FullPath, cmd)
|
||||||
|
if result.Error != nil {
|
||||||
|
log.Warn("git for-each-ref error:", result.Error)
|
||||||
|
return result.Error
|
||||||
|
}
|
||||||
|
newest := strings.Join(result.Stdout, "\n")
|
||||||
|
newest = strings.TrimSpace(newest)
|
||||||
|
tmp := getGitDateStamp(newest)
|
||||||
|
repo.Times.NewestCommit = timestamppb.New(tmp)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ message GitTimes {
|
||||||
google.protobuf.Timestamp mtimeIndex = 6; // mtime for ./git/HEAD // probably always in sync with HEAD
|
google.protobuf.Timestamp mtimeIndex = 6; // mtime for ./git/HEAD // probably always in sync with HEAD
|
||||||
google.protobuf.Timestamp mtimeFetch = 7; // mtime for ./git/FETCH_HEAD // last time 'git fetch' or 'git pull' was run on current branch?
|
google.protobuf.Timestamp mtimeFetch = 7; // mtime for ./git/FETCH_HEAD // last time 'git fetch' or 'git pull' was run on current branch?
|
||||||
google.protobuf.Timestamp lastGoDep = 8; // mtime for last go.sum scan
|
google.protobuf.Timestamp lastGoDep = 8; // mtime for last go.sum scan
|
||||||
|
google.protobuf.Timestamp newestCommit = 9; // when the newest commit was
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is probably better. think about moving to this instead
|
// this is probably better. think about moving to this instead
|
||||||
|
|
Loading…
Reference in New Issue