From 0d9c41be7d7d4ae1d2a28931be5565c8f6d3f792 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 16 Sep 2014 10:10:33 -0400 Subject: Work on #476 --- modules/git/repo_commit.go | 8 ++++++ modules/git/version.go | 70 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 67 insertions(+), 11 deletions(-) (limited to 'modules/git') diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index eebe3dd0..c9258927 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 683e859b..653503c0 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 +} -- cgit v1.2.3 From 62f21ff3ed1b85a1d3a1eab73da354e4f6e8794a Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 16 Sep 2014 11:29:53 -0400 Subject: Work on #476 --- models/repo.go | 2 +- modules/git/repo_commit.go | 2 +- modules/git/version.go | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'modules/git') diff --git a/models/repo.go b/models/repo.go index a8e53dbc..2e162704 100644 --- a/models/repo.go +++ b/models/repo.go @@ -100,7 +100,7 @@ func NewRepoContext() { if err != nil { log.Fatal(4, "Fail to parse required Git version: %v", err) } - if ver.Compare(reqVer) == -1 { + if ver.LessThan(reqVer) { log.Fatal(4, "Gogs requires Git version greater or equal to 1.7.1") } diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index c9258927..cd0181c4 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -137,7 +137,7 @@ func (repo *Repository) GetCommit(commitId string) (*Commit, error) { } func (repo *Repository) commitsCount(id sha1) (int, error) { - if gitVer.Compare(MustParseVersion("1.8.0")) == -1 { + if gitVer.LessThan(MustParseVersion("1.8.0")) { stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", "--pretty=format:''", id.String()) if err != nil { return 0, errors.New(string(stderr)) diff --git a/modules/git/version.go b/modules/git/version.go index 653503c0..546397aa 100644 --- a/modules/git/version.go +++ b/modules/git/version.go @@ -47,7 +47,7 @@ func MustParseVersion(verStr string) *Version { } // Compare compares two versions, -// it returns 1 if original is greater, 1 if original is smaller, 0 if equal. +// 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 @@ -70,6 +70,10 @@ func (v *Version) Compare(that *Version) int { return 0 } +func (v *Version) LessThan(that *Version) bool { + return v.Compare(that) < 0 +} + // GetVersion returns current Git version installed. func GetVersion() (*Version, error) { if gitVer != nil { -- cgit v1.2.3 From ae3639868ee2d720dc50fc81be712072445ab6ed Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 16 Sep 2014 20:58:06 -0400 Subject: Quick fix on #476 --- modules/git/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/git') diff --git a/modules/git/version.go b/modules/git/version.go index 546397aa..9908d11e 100644 --- a/modules/git/version.go +++ b/modules/git/version.go @@ -35,7 +35,7 @@ func ParseVersion(verStr string) (*Version, error) { case 1: v.Minor, _ = com.StrTo(s).Int() case 2: - v.Patch, _ = com.StrTo(s).Int() + v.Patch, _ = com.StrTo(strings.TrimSpace(s)).Int() } } return v, nil -- cgit v1.2.3 From 150eef93b2340f665c070158ade1863339829e05 Mon Sep 17 00:00:00 2001 From: lunnyxiao Date: Mon, 22 Sep 2014 10:43:16 +0800 Subject: add submodule basic support & buf fixed #478 --- modules/git/commit.go | 50 ++++++++++++++++++++++++++++++++++++++++++- modules/git/submodule.go | 6 ++++++ modules/git/tree.go | 2 ++ modules/git/tree_entry.go | 4 ++++ routers/repo/http.go | 5 +++++ routers/repo/view.go | 40 ++++++++++++++++++++++++++++------ templates/repo/view_list.tmpl | 17 +++++++++++++-- 7 files changed, 115 insertions(+), 9 deletions(-) create mode 100644 modules/git/submodule.go (limited to 'modules/git') diff --git a/modules/git/commit.go b/modules/git/commit.go index 52348fef..d2d373da 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -5,6 +5,7 @@ package git import ( + "bufio" "container/list" "strings" ) @@ -17,7 +18,8 @@ type Commit struct { Committer *Signature CommitMessage string - parents []sha1 // sha1 strings + parents []sha1 // sha1 strings + submodules map[string]*SubModule } // Return the commit message. Same as retrieving CommitMessage directly. @@ -84,3 +86,49 @@ func (c *Commit) CommitsByRange(page int) (*list.List, error) { func (c *Commit) GetCommitOfRelPath(relPath string) (*Commit, error) { return c.repo.getCommitOfRelPath(c.Id, relPath) } + +func (c *Commit) GetSubModule(entryname string) (*SubModule, error) { + moduels, err := c.GetSubModules() + if err != nil { + return nil, err + } + return moduels[entryname], nil +} + +func (c *Commit) GetSubModules() (map[string]*SubModule, error) { + if c.submodules != nil { + return c.submodules, nil + } + + entry, err := c.GetTreeEntryByPath(".gitmodules") + if err != nil { + return nil, err + } + rd, err := entry.Blob().Data() + if err != nil { + return nil, err + } + + scanner := bufio.NewScanner(rd) + c.submodules = make(map[string]*SubModule) + var ismodule bool + var path string + for scanner.Scan() { + if strings.HasPrefix(scanner.Text(), "[submodule") { + ismodule = true + continue + } + if ismodule { + fields := strings.Split(scanner.Text(), "=") + k := strings.TrimSpace(fields[0]) + if k == "path" { + path = strings.TrimSpace(fields[1]) + } else if k == "url" { + c.submodules[path] = &SubModule{path, strings.TrimSpace(fields[1])} + ismodule = false + } + } + } + + return c.submodules, nil +} diff --git a/modules/git/submodule.go b/modules/git/submodule.go new file mode 100644 index 00000000..28b5b9f3 --- /dev/null +++ b/modules/git/submodule.go @@ -0,0 +1,6 @@ +package git + +type SubModule struct { + Name string + Url string +} diff --git a/modules/git/tree.go b/modules/git/tree.go index 03152c34..a3012443 100644 --- a/modules/git/tree.go +++ b/modules/git/tree.go @@ -51,6 +51,8 @@ func parseTreeData(tree *Tree, data []byte) ([]*TreeEntry, error) { case "160000": entry.mode = ModeCommit entry.Type = COMMIT + + step = 8 case "040000": entry.mode = ModeTree entry.Type = TREE diff --git a/modules/git/tree_entry.go b/modules/git/tree_entry.go index e842f233..f65f3326 100644 --- a/modules/git/tree_entry.go +++ b/modules/git/tree_entry.go @@ -61,6 +61,10 @@ func (te *TreeEntry) Size() int64 { return te.size } +func (te *TreeEntry) IsSubModule() bool { + return te.mode == ModeCommit +} + func (te *TreeEntry) IsDir() bool { return te.mode == ModeTree } diff --git a/routers/repo/http.go b/routers/repo/http.go index 56c85bf5..a98478c9 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -103,6 +103,7 @@ func Http(ctx *middleware.Context) { // check access if askAuth { baHead := ctx.Req.Header.Get("Authorization") + fmt.Println("auth:", baHead) if baHead == "" { authRequired(ctx) return @@ -121,6 +122,8 @@ func Http(ctx *middleware.Context) { return } + fmt.Println("auth2:", authUsername, passwd) + authUser, err = models.GetUserByName(authUsername) if err != nil { ctx.Handle(401, "no basic auth and digit auth", nil) @@ -134,6 +137,8 @@ func Http(ctx *middleware.Context) { return } + fmt.Println("passwd is right") + if !isPublicPull { var tp = models.WRITABLE if isPull { diff --git a/routers/repo/view.go b/routers/repo/view.go index e42894ae..41fdaba0 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -10,6 +10,7 @@ import ( "path" "path/filepath" "strings" + "time" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/git" @@ -21,6 +22,15 @@ const ( HOME base.TplName = "repo/home" ) +type fakeCommit struct { + Id string + Summary string + Url string + Committer struct { + When time.Time + } +} + func Home(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Repo.Repository.Name @@ -127,13 +137,31 @@ func Home(ctx *middleware.Context) { files := make([][]interface{}, 0, len(entries)) for _, te := range entries { - c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name())) - if err != nil { - ctx.Handle(404, "GetCommitOfRelPath", err) - return - } + if te.Type != git.COMMIT { + c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name())) + if err != nil { + ctx.Handle(404, "GetCommitOfRelPath", err) + return + } + files = append(files, []interface{}{te, c}) + } else { + sm, err := ctx.Repo.Commit.GetSubModule(path.Join(treename, te.Name())) + if err != nil { + ctx.Handle(404, "GetSubModule", err) + return + } - files = append(files, []interface{}{te, c}) + commit := git.Commit{ + Tree: *tree, + Id: te.Id, + Committer: &git.Signature{ + When: time.Now(), + }, + CommitMessage: sm.Url, + } + + files = append(files, []interface{}{te, &commit}) + } } ctx.Data["Files"] = files diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index ce46cfb2..e8628306 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -27,8 +27,20 @@ {{$entry := index $item 0}} {{$commit := index $item 1}} - - + {{if $entry.IsSubModule}} + + + + + {{$entry.Name}} @ {{ShortSha $commit.Id.String}} + + + {{$commit.Summary}} + + {{TimeSince $commit.Committer.When $.i18n.Lang}} + {{else}} + + {{$entry.Name}} @@ -37,6 +49,7 @@ {{$commit.Summary}} {{TimeSince $commit.Committer.When $.i18n.Lang}} + {{end}} {{end}} -- cgit v1.2.3 From 7df60af60ed6d9606c5894c6512522dc91d0c247 Mon Sep 17 00:00:00 2001 From: lunnyxiao Date: Mon, 22 Sep 2014 14:23:36 +0800 Subject: submodule support and closed #478 --- modules/git/tree_entry.go | 2 +- routers/repo/view.go | 28 ++++++++++++++-------------- templates/repo/view_list.tmpl | 8 ++------ 3 files changed, 17 insertions(+), 21 deletions(-) (limited to 'modules/git') diff --git a/modules/git/tree_entry.go b/modules/git/tree_entry.go index f65f3326..e403e93e 100644 --- a/modules/git/tree_entry.go +++ b/modules/git/tree_entry.go @@ -84,7 +84,7 @@ type Entries []*TreeEntry var sorter = []func(t1, t2 *TreeEntry) bool{ func(t1, t2 *TreeEntry) bool { - return t1.IsDir() && !t2.IsDir() + return (t1.IsDir() || t1.IsSubModule()) && !t2.IsDir() && !t2.IsSubModule() }, func(t1, t2 *TreeEntry) bool { return t1.name < t2.name diff --git a/routers/repo/view.go b/routers/repo/view.go index 41fdaba0..77f17e7a 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -10,7 +10,6 @@ import ( "path" "path/filepath" "strings" - "time" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/git" @@ -23,12 +22,10 @@ const ( ) type fakeCommit struct { - Id string - Summary string - Url string - Committer struct { - When time.Time - } + *git.Commit + + RefUrl string + RefId string } func Home(ctx *middleware.Context) { @@ -151,13 +148,16 @@ func Home(ctx *middleware.Context) { return } - commit := git.Commit{ - Tree: *tree, - Id: te.Id, - Committer: &git.Signature{ - When: time.Now(), - }, - CommitMessage: sm.Url, + c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name())) + if err != nil { + ctx.Handle(404, "GetCommitOfRelPath", err) + return + } + + commit := fakeCommit{ + Commit: c, + RefUrl: strings.TrimRight(sm.Url, ".git"), + RefId: te.Id.String(), } files = append(files, []interface{}{te, &commit}) diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index e8628306..41f7daf2 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -32,12 +32,8 @@ - {{$entry.Name}} @ {{ShortSha $commit.Id.String}} + {{$entry.Name}} @ {{ShortSha $commit.RefId}} - - {{$commit.Summary}} - - {{TimeSince $commit.Committer.When $.i18n.Lang}} {{else}} @@ -45,11 +41,11 @@ {{$entry.Name}} + {{end}} {{$commit.Summary}} {{TimeSince $commit.Committer.When $.i18n.Lang}} - {{end}} {{end}} -- cgit v1.2.3 From 3f707b3f3265c4b3e64e47ee172cc878f3325248 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 22 Sep 2014 17:01:19 -0400 Subject: Add basic submodule support --- README.md | 2 +- README_ZH.md | 2 +- gogs.go | 2 +- modules/git/submodule.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ routers/repo/view.go | 16 +-------------- templates/.VERSION | 2 +- 6 files changed, 57 insertions(+), 19 deletions(-) (limited to 'modules/git') diff --git a/README.md b/README.md index 232aa92a..a2aed3af 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.3 Beta +##### Current version: 0.5.4 Beta ### NOTICES diff --git a/README_ZH.md b/README_ZH.md index fcc8b496..817110b3 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.3 Beta +##### 当前版本:0.5.4 Beta ## 开发目的 diff --git a/gogs.go b/gogs.go index b1b9fe60..d565d7bb 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.3.0922 Beta" +const APP_VER = "0.5.4.0922 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/modules/git/submodule.go b/modules/git/submodule.go index 28b5b9f3..6927f8cb 100644 --- a/modules/git/submodule.go +++ b/modules/git/submodule.go @@ -1,6 +1,58 @@ +// Copyright 2014 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + package git +import ( + "strings" +) + type SubModule struct { Name string Url string } + +// SubModuleFile represents a file with submodule type. +type SubModuleFile struct { + *Commit + + refUrl string + refId string +} + +func NewSubModuleFile(c *Commit, refUrl, refId string) *SubModuleFile { + return &SubModuleFile{ + Commit: c, + refUrl: refUrl, + refId: refId, + } +} + +// RefUrl guesses and returns reference URL. +func (sf *SubModuleFile) RefUrl() string { + url := strings.TrimSuffix(sf.refUrl, ".git") + + // git://xxx/user/repo + if strings.HasPrefix(url, "git://") { + return "http://" + strings.TrimPrefix(url, "git://") + } + + // http[s]://xxx/user/repo + if strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") { + return url + } + + // sysuser@xxx:user/repo + i := strings.Index(url, "@") + j := strings.LastIndex(url, ":") + if i > -1 && j > -1 { + return "http://" + url[i+1:j] + "/" + url[j+1:] + } + return url +} + +// RefId returns reference ID. +func (sf *SubModuleFile) RefId() string { + return sf.refId +} diff --git a/routers/repo/view.go b/routers/repo/view.go index 77f17e7a..4e4a7b18 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -21,13 +21,6 @@ const ( HOME base.TplName = "repo/home" ) -type fakeCommit struct { - *git.Commit - - RefUrl string - RefId string -} - func Home(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Repo.Repository.Name @@ -153,14 +146,7 @@ func Home(ctx *middleware.Context) { ctx.Handle(404, "GetCommitOfRelPath", err) return } - - commit := fakeCommit{ - Commit: c, - RefUrl: strings.TrimRight(sm.Url, ".git"), - RefId: te.Id.String(), - } - - files = append(files, []interface{}{te, &commit}) + files = append(files, []interface{}{te, git.NewSubModuleFile(c, sm.Url, te.Id.String())}) } } diff --git a/templates/.VERSION b/templates/.VERSION index 19d8171e..8a713df0 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.3.0922 Beta \ No newline at end of file +0.5.4.0922 Beta \ No newline at end of file -- cgit v1.2.3 From ebb05475ed15fffc37145799ce7c72b65ccdbfc5 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 23 Sep 2014 13:06:25 -0400 Subject: Fix #495 and cannot view repository by tag --- cmd/web.go | 2 +- gogs.go | 2 +- modules/git/repo_tag.go | 1 + modules/middleware/repo.go | 8 ++++++-- public/ng/css/ui.css | 3 ++- public/ng/less/ui/reset.less | 6 ++---- templates/.VERSION | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) (limited to 'modules/git') diff --git a/cmd/web.go b/cmd/web.go index a5ebf259..e2c929c1 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -355,7 +355,7 @@ func runWeb(*cli.Context) { r.Get("/commit/:branchname", repo.Diff) r.Get("/commit/:branchname/*", repo.Diff) r.Get("/releases", repo.Releases) - r.Get("/archive/*.*", repo.Download) + r.Get("/archive/:branchname/*.*", repo.Download) r.Get("/compare/:before([a-z0-9]+)...:after([a-z0-9]+)", repo.CompareDiff) }, ignSignIn, middleware.RepoAssignment(true, true)) diff --git a/gogs.go b/gogs.go index 84733042..0821dbc2 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.4.0922 Beta" +const APP_VER = "0.5.4.0923 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/modules/git/repo_tag.go b/modules/git/repo_tag.go index 21818f3e..dd31e441 100644 --- a/modules/git/repo_tag.go +++ b/modules/git/repo_tag.go @@ -77,6 +77,7 @@ func (repo *Repository) getTag(id sha1) (*Tag, error) { } tag.Id = id + tag.Object = id tag.repo = repo repo.tagCache[id] = tag diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index f17018dd..7227e05d 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -213,7 +213,11 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "RepoAssignment invalid tag", nil) return } - ctx.Repo.Commit, _ = ctx.Repo.Tag.Commit() + ctx.Repo.Commit, err = ctx.Repo.Tag.Commit() + if err != nil { + ctx.Handle(500, "RepoAssignment", fmt.Errorf("fail to get tag commit(%s): %v", refName, err)) + return + } ctx.Repo.CommitId = ctx.Repo.Commit.Id.String() } else if len(refName) == 40 { ctx.Repo.IsCommit = true @@ -226,7 +230,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { return } } else { - ctx.Handle(404, "RepoAssignment invalid repo", errors.New("branch or tag not exist")) + ctx.Handle(404, "RepoAssignment invalid repo", fmt.Errorf("branch or tag not exist: %s", refName)) return } diff --git a/public/ng/css/ui.css b/public/ng/css/ui.css index f3f6eded..5dc3cc04 100644 --- a/public/ng/css/ui.css +++ b/public/ng/css/ui.css @@ -151,7 +151,8 @@ code, kbd, pre, samp { - font: 14px Consolas, "Liberation Mono", Menlo, Courier, monospace; + font-family: monospace, monospace; + font-size: 1em; } .text-left { text-align: left; diff --git a/public/ng/less/ui/reset.less b/public/ng/less/ui/reset.less index 8ff45d69..0e7a50e4 100644 --- a/public/ng/less/ui/reset.less +++ b/public/ng/less/ui/reset.less @@ -193,21 +193,19 @@ code, kbd, pre, samp { - font: 14px Consolas, "Liberation Mono", Menlo, Courier, monospace; + font-family: monospace, monospace; + font-size: 1em; } .text-left { text-align: left; } - .text-right { text-align: right; } - .text-center { text-align: center; } - .list-no-style { list-style: none; } diff --git a/templates/.VERSION b/templates/.VERSION index 8a713df0..23f5f0fe 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.4.0922 Beta \ No newline at end of file +0.5.4.0923 Beta \ No newline at end of file -- cgit v1.2.3 From 2a031c13658458df9f8f56ce295a8ba72bf35dff Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 30 Sep 2014 04:39:53 -0400 Subject: Fix #515 --- gogs.go | 2 +- modules/git/repo_commit.go | 4 ++-- modules/git/repo_tag.go | 2 +- modules/git/tree.go | 5 ++++- modules/middleware/repo.go | 5 ++--- public/ng/css/gogs.css | 1 - public/ng/less/gogs/dashboard.less | 1 - routers/repo/view.go | 1 + templates/.VERSION | 2 +- 9 files changed, 12 insertions(+), 11 deletions(-) (limited to 'modules/git') diff --git a/gogs.go b/gogs.go index e7615c9b..0ea64d26 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.4.0929 Beta" +const APP_VER = "0.5.4.0930 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index cd0181c4..7c47b53d 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -40,11 +40,11 @@ func (repo *Repository) GetCommitIdOfTag(tagName string) (string, error) { } func (repo *Repository) GetCommitOfTag(tagName string) (*Commit, error) { - commitId, err := repo.GetCommitIdOfTag(tagName) + tag, err := repo.GetTag(tagName) if err != nil { return nil, err } - return repo.GetCommit(commitId) + return tag.Commit() } // Parse commit information from the (uncompressed) raw diff --git a/modules/git/repo_tag.go b/modules/git/repo_tag.go index dd31e441..77ae3db0 100644 --- a/modules/git/repo_tag.go +++ b/modules/git/repo_tag.go @@ -52,6 +52,7 @@ func (repo *Repository) getTag(id sha1) (*Tag, error) { if err != nil { return nil, errors.New(stderr) } + tp = strings.TrimSpace(tp) // Tag is a commit. if ObjectType(tp) == COMMIT { @@ -77,7 +78,6 @@ func (repo *Repository) getTag(id sha1) (*Tag, error) { } tag.Id = id - tag.Object = id tag.repo = repo repo.tagCache[id] = tag diff --git a/modules/git/tree.go b/modules/git/tree.go index a3012443..be77bfce 100644 --- a/modules/git/tree.go +++ b/modules/git/tree.go @@ -109,9 +109,12 @@ func (t *Tree) ListEntries(relpath string) (Entries, error) { } t.entriesParsed = true - stdout, _, err := com.ExecCmdDirBytes(t.repo.Path, + stdout, stderr, err := com.ExecCmdDirBytes(t.repo.Path, "git", "ls-tree", t.Id.String()) if err != nil { + if strings.Contains(err.Error(), "exit status 128") { + return nil, errors.New(strings.TrimSpace(string(stderr))) + } return nil, err } t.entries, err = parseTreeData(t, stdout) diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index c0290b2e..c6250f6d 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -208,10 +208,9 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { } else if gitRepo.IsTagExist(refName) { ctx.Repo.IsTag = true ctx.Repo.BranchName = refName - - ctx.Repo.Commit, err = gitRepo.GetCommitOfTag(refName) + ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetCommitOfTag(refName) if err != nil { - ctx.Handle(500, "RepoAssignment invalid tag", err) + ctx.Handle(500, "Fail to get tag commit", err) return } ctx.Repo.CommitId = ctx.Repo.Commit.Id.String() diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index 6d38ac9b..feb21c97 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -833,7 +833,6 @@ ol.linenums { } #dashboard-my-repo .repo-count { margin-left: 4px; - font-size: .8em; } #dashboard-my-org, #dashboard-my-mirror { diff --git a/public/ng/less/gogs/dashboard.less b/public/ng/less/gogs/dashboard.less index e7a1e90c..a40debe5 100644 --- a/public/ng/less/gogs/dashboard.less +++ b/public/ng/less/gogs/dashboard.less @@ -139,7 +139,6 @@ } .repo-count { margin-left: 4px; - font-size: .8em; } } #dashboard-my-org, diff --git a/routers/repo/view.go b/routers/repo/view.go index 82f34600..ba76a6ad 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -118,6 +118,7 @@ func Home(ctx *middleware.Context) { ctx.Handle(404, "SubTree", err) return } + entries, err := tree.ListEntries(treename) if err != nil { ctx.Handle(500, "ListEntries", err) diff --git a/templates/.VERSION b/templates/.VERSION index 2d0d24c2..c734a8f0 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.4.0929 Beta \ No newline at end of file +0.5.4.0930 Beta \ No newline at end of file -- cgit v1.2.3