From 632b1b694dc7eb598b552476bb5f76e90c13b25a Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 15 Sep 2014 09:56:12 -0400 Subject: Fix #465 --- templates/.VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/.VERSION b/templates/.VERSION index 8d423d667c..6db2a3e6c9 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.0.0913 Beta \ No newline at end of file +0.5.1.0915 Beta \ No newline at end of file -- cgit v1.2.3 From cff3ca23a57230c21e685ab02aab85f07bd25fe2 Mon Sep 17 00:00:00 2001 From: Benjamin Peng Date: Tue, 16 Sep 2014 15:55:41 +0800 Subject: Fix TimeSince arguments error. --- templates/repo/release/list.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index 0f02508fb9..b9f462588d 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -29,7 +29,7 @@

   {{.Publisher.Name}} - {{if .Created}}{{TimeSince .Created}}{{end}} + {{if .Created}}{{TimeSince .Created $.Lang}}{{end}} {{.NumCommitsBehind}} commits to {{.Target}} since this release

-- cgit v1.2.3 From c1ceec45da8c600dea2b932127519c04484258d8 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 16 Sep 2014 08:32:13 -0400 Subject: Fix mirror UI style and work on #475 --- gogs.go | 2 +- models/publickey.go | 13 +++++++++---- public/ng/css/gogs.css | 2 +- public/ng/less/gogs/dashboard.less | 4 +--- templates/.VERSION | 2 +- templates/user/dashboard/dashboard.tmpl | 4 ++-- 6 files changed, 15 insertions(+), 12 deletions(-) (limited to 'templates') diff --git a/gogs.go b/gogs.go index f492b2f7f7..f0aebf0367 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.1.0915 Beta" +const APP_VER = "0.5.1.0916 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/publickey.go b/models/publickey.go index 1246cffc58..dccb89362b 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -14,6 +14,7 @@ import ( "os/exec" "path" "path/filepath" + "runtime" "strings" "sync" "time" @@ -160,10 +161,14 @@ func saveAuthorizedKeyFile(key *PublicKey) error { if err != nil { return err } - if finfo.Mode().Perm() > 0600 { - log.Error(4, "authorized_keys file has unusual permission flags: %s - setting to -rw-------", finfo.Mode().Perm().String()) - if err = f.Chmod(0600); err != nil { - return err + + // FIXME: following command does not support in Windows. + if runtime.GOOS != "windows" { + if finfo.Mode().Perm() > 0600 { + log.Error(4, "authorized_keys file has unusual permission flags: %s - setting to -rw-------", finfo.Mode().Perm().String()) + if err = f.Chmod(0600); err != nil { + return err + } } } diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index 8f82e0af3a..db4aad2283 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -686,7 +686,7 @@ ol.linenums { width: auto; } /* -The dashboard page style + The dashboard page style */ #dashboard-header { border-bottom: 1px solid #d6d6d6; diff --git a/public/ng/less/gogs/dashboard.less b/public/ng/less/gogs/dashboard.less index afef60cfab..60aa807269 100644 --- a/public/ng/less/gogs/dashboard.less +++ b/public/ng/less/gogs/dashboard.less @@ -1,9 +1,7 @@ @import "../ui/var"; - /* -The dashboard page style + The dashboard page style */ - @dashboardHeaderBorderColor: #D6D6D6; @dashboardHeaderLinkColor: #444; @dashboardHeaderLinkHoverColor: #D9453D; diff --git a/templates/.VERSION b/templates/.VERSION index 6db2a3e6c9..261667dbe1 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.1.0915 Beta \ No newline at end of file +0.5.1.0916 Beta \ No newline at end of file diff --git a/templates/user/dashboard/dashboard.tmpl b/templates/user/dashboard/dashboard.tmpl index bf0aba097b..2f9bbc4ed4 100644 --- a/templates/user/dashboard/dashboard.tmpl +++ b/templates/user/dashboard/dashboard.tmpl @@ -9,7 +9,7 @@
-
+

{{.GetActUserName}} {{if eq .GetOpType 1}} @@ -30,7 +30,7 @@ {{ $push := ActionContent2Commits .}} {{ $repoLink := .GetRepoLink}} {{range $push.Commits}} -

  • {{ShortSha .Sha1}} {{.Message}}
  • +
  • {{ShortSha .Sha1}} {{.Message}}
  • {{end}}
    -- cgit v1.2.3 From 0d9c41be7d7d4ae1d2a28931be5565c8f6d3f792 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 16 Sep 2014 10:10:33 -0400 Subject: Work on #476 --- README.md | 2 +- README_ZH.md | 2 +- gogs.go | 2 +- models/repo.go | 9 ++++-- modules/git/repo_commit.go | 8 ++++++ modules/git/version.go | 70 ++++++++++++++++++++++++++++++++++++++-------- templates/.VERSION | 2 +- 7 files changed, 78 insertions(+), 17 deletions(-) (limited to 'templates') diff --git a/README.md b/README.md index 3c319896af..43d75c264b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Gogs(Go Git Service) is a painless self-hosted Git Service written in Go. ![Demo](https://gowalker.org/public/gogs_demo.gif) -##### Current version: 0.5.0 Beta +##### Current version: 0.5.2 Beta ### NOTICES diff --git a/README_ZH.md b/README_ZH.md index 7faeee2bea..bf6c1d03a1 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个基于 Go 语言的自助 Git 服务。 ![Demo](https://gowalker.org/public/gogs_demo.gif) -##### 当前版本:0.5.1 Beta +##### 当前版本:0.5.2 Beta ## 开发目的 diff --git a/gogs.go b/gogs.go index f0aebf0367..8ae7449e2b 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.1.0916 Beta" +const APP_VER = "0.5.2.0916 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/repo.go b/models/repo.go index 25876872eb..a8e53dbcd7 100644 --- a/models/repo.go +++ b/models/repo.go @@ -95,8 +95,13 @@ func NewRepoContext() { if err != nil { log.Fatal(4, "Fail to get Git version: %v", err) } - if ver.Major < 2 && ver.Minor < 8 { - log.Fatal(4, "Gogs requires Git version greater or equal to 1.8.0") + + reqVer, err := git.ParseVersion("1.7.1") + if err != nil { + log.Fatal(4, "Fail to parse required Git version: %v", err) + } + if ver.Compare(reqVer) == -1 { + log.Fatal(4, "Gogs requires Git version greater or equal to 1.7.1") } // Check if server has basic git setting and set if not. diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index eebe3dd0e0..c9258927bb 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -137,6 +137,14 @@ func (repo *Repository) GetCommit(commitId string) (*Commit, error) { } func (repo *Repository) commitsCount(id sha1) (int, error) { + if gitVer.Compare(MustParseVersion("1.8.0")) == -1 { + stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", "--pretty=format:''", id.String()) + if err != nil { + return 0, errors.New(string(stderr)) + } + return len(bytes.Split(stdout, []byte("\n"))), nil + } + stdout, stderr, err := com.ExecCmdDir(repo.Path, "git", "rev-list", "--count", id.String()) if err != nil { return 0, errors.New(stderr) diff --git a/modules/git/version.go b/modules/git/version.go index 683e859b47..653503c03c 100644 --- a/modules/git/version.go +++ b/modules/git/version.go @@ -11,25 +11,24 @@ import ( "github.com/Unknwon/com" ) +var ( + // Cached Git version. + gitVer *Version +) + // Version represents version of Git. type Version struct { Major, Minor, Patch int } -// GetVersion returns current Git version installed. -func GetVersion() (Version, error) { - stdout, stderr, err := com.ExecCmd("git", "version") - if err != nil { - return Version{}, errors.New(stderr) - } - - infos := strings.Split(stdout, " ") +func ParseVersion(verStr string) (*Version, error) { + infos := strings.Split(verStr, ".") if len(infos) < 3 { - return Version{}, errors.New("not enough output") + return nil, errors.New("incorrect version input") } - v := Version{} - for i, s := range strings.Split(strings.TrimSpace(infos[2]), ".") { + v := &Version{} + for i, s := range infos { switch i { case 0: v.Major, _ = com.StrTo(s).Int() @@ -41,3 +40,52 @@ func GetVersion() (Version, error) { } return v, nil } + +func MustParseVersion(verStr string) *Version { + v, _ := ParseVersion(verStr) + return v +} + +// Compare compares two versions, +// it returns 1 if original is greater, 1 if original is smaller, 0 if equal. +func (v *Version) Compare(that *Version) int { + if v.Major > that.Major { + return 1 + } else if v.Major < that.Major { + return -1 + } + + if v.Minor > that.Minor { + return 1 + } else if v.Minor < that.Minor { + return -1 + } + + if v.Patch > that.Patch { + return 1 + } else if v.Patch < that.Patch { + return -1 + } + + return 0 +} + +// GetVersion returns current Git version installed. +func GetVersion() (*Version, error) { + if gitVer != nil { + return gitVer, nil + } + + stdout, stderr, err := com.ExecCmd("git", "version") + if err != nil { + return nil, errors.New(stderr) + } + + infos := strings.Split(stdout, " ") + if len(infos) < 3 { + return nil, errors.New("not enough output") + } + + gitVer, err = ParseVersion(infos[2]) + return gitVer, err +} diff --git a/templates/.VERSION b/templates/.VERSION index 261667dbe1..aada89d11a 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.1.0916 Beta \ No newline at end of file +0.5.2.0916 Beta \ No newline at end of file -- cgit v1.2.3