aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/gogits
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-04-06 20:58:57 -0400
committerUnknwon <u@gogs.io>2017-04-06 20:58:57 -0400
commit8d0417497b39aa196400d39c99bbd79cfb364f9f (patch)
treee09028f02c5732ab8c3f9140dfcba488d41809df /vendor/github.com/gogits
parent90b9f7e08ca2e027cc587199537aa653ddd94d91 (diff)
modes/mirror: make Updated unchanged if no new commits fetched (#4341)
After sync mirror, get latest commit date and compare to current repository updated time, only update it if the commit date is newer.
Diffstat (limited to 'vendor/github.com/gogits')
-rw-r--r--vendor/github.com/gogits/git-module/git.go2
-rw-r--r--vendor/github.com/gogits/git-module/repo.go15
2 files changed, 16 insertions, 1 deletions
diff --git a/vendor/github.com/gogits/git-module/git.go b/vendor/github.com/gogits/git-module/git.go
index 538e66d7..f56d054e 100644
--- a/vendor/github.com/gogits/git-module/git.go
+++ b/vendor/github.com/gogits/git-module/git.go
@@ -10,7 +10,7 @@ import (
"time"
)
-const _VERSION = "0.6.0"
+const _VERSION = "0.6.1"
func Version() string {
return _VERSION
diff --git a/vendor/github.com/gogits/git-module/repo.go b/vendor/github.com/gogits/git-module/repo.go
index aef9f385..ca4805f5 100644
--- a/vendor/github.com/gogits/git-module/repo.go
+++ b/vendor/github.com/gogits/git-module/repo.go
@@ -278,3 +278,18 @@ func GetRepoSize(repoPath string) (*CountObject, error) {
return countObject, nil
}
+
+// GetLatestCommitDate returns the date of latest commit of repository.
+// If branch is empty, it returns the latest commit across all branches.
+func GetLatestCommitDate(repoPath, branch string) (time.Time, error) {
+ cmd := NewCommand("for-each-ref", "--count=1", "--sort=-committerdate", "--format=%(committerdate:iso8601)")
+ if len(branch) > 0 {
+ cmd.AddArguments("refs/heads/" + branch)
+ }
+ stdout, err := cmd.RunInDir(repoPath)
+ if err != nil {
+ return time.Time{}, err
+ }
+
+ return time.Parse("2006-01-02 15:04:05 -0700", strings.TrimSpace(stdout))
+}