From c3a52f7dd075f1f3cf7fb935b7489629760837ab Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 15 Apr 2014 20:01:20 -0400 Subject: [PATCH] Mirror bug fix on downloading zip --- README.md | 3 +++ README_ZH.md | 3 +++ models/git_diff.go | 13 +++++++++---- modules/avatar/avatar.go | 5 +++-- routers/repo/repo.go | 4 ++-- templates/base/navbar.tmpl | 4 ++-- templates/repo/commits.tmpl | 2 +- templates/repo/diff.tmpl | 8 ++++---- web.go | 2 ++ 9 files changed, 29 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b0b8c0b1d5..7871325363 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,9 @@ There are 3 ways to install Gogs: This project was launched by [Unknown](https://github.com/Unknwon) and [lunny](https://github.com/lunny); [fuxiaohei](https://github.com/fuxiaohei), [slene](https://github.com/slene) and [codeskyblue](https://github.com/codeskyblue) joined the team soon after. See [contributors page](https://github.com/gogits/gogs/graphs/contributors) for full list of contributors. +[![Clone in Koding](http://learn.koding.com/btn/clone_d.png)][koding] +[koding]: https://koding.com/Teamwork?import=https://github.com/gogits/gogs/archive/master.zip&c=git1 + ## License Gogs is under the MIT License. See the [LICENSE](https://github.com/gogits/gogs/blob/master/LICENSE) file for the full license text. diff --git a/README_ZH.md b/README_ZH.md index be191bc04e..ecfb7700a2 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -57,6 +57,9 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 本项目最初由 [Unknown](https://github.com/Unknwon) 和 [lunny](https://github.com/lunny) 发起,随后 [fuxiaohei](https://github.com/fuxiaohei)、[slene](https://github.com/slene) 以及 [codeskyblue](https://github.com/codeskyblue) 加入到开发团队。您可以通过查看 [贡献者页面](https://github.com/gogits/gogs/graphs/contributors) 获取完整的贡献者列表。 +[![Clone in Koding](http://learn.koding.com/btn/clone_d.png)][koding] +[koding]: https://koding.com/Teamwork?import=https://github.com/gogits/gogs/archive/master.zip&c=git1 + ## 授权许可 Gogs 采用 MIT 开源授权许可证,完整的授权说明已放置在 [LICENSE](https://github.com/gogits/gogs/blob/master/LICENSE) 文件中。 \ No newline at end of file diff --git a/models/git_diff.go b/models/git_diff.go index de9d1de7b1..cf93af6959 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -51,6 +51,7 @@ type DiffFile struct { Name string Addition, Deletion int Type int + IsBin bool Sections []*DiffSection } @@ -96,13 +97,15 @@ func ParsePatch(reader io.Reader) (*Diff, error) { if line == "" { continue } - if line[0] == ' ' { + + switch { + case line[0] == ' ': diffLine := &DiffLine{Type: DIFF_LINE_PLAIN, Content: line, LeftIdx: leftLine, RightIdx: rightLine} leftLine++ rightLine++ curSection.Lines = append(curSection.Lines, diffLine) continue - } else if line[0] == '@' { + case line[0] == '@': curSection = &DiffSection{} curFile.Sections = append(curFile.Sections, curSection) ss := strings.Split(line, "@@") @@ -114,14 +117,14 @@ func ParsePatch(reader io.Reader) (*Diff, error) { leftLine, _ = base.StrTo(strings.Split(ranges[0], ",")[0][1:]).Int() rightLine, _ = base.StrTo(strings.Split(ranges[1], ",")[0]).Int() continue - } else if line[0] == '+' { + case line[0] == '+': curFile.Addition++ diff.TotalAddition++ diffLine := &DiffLine{Type: DIFF_LINE_ADD, Content: line, RightIdx: rightLine} rightLine++ curSection.Lines = append(curSection.Lines, diffLine) continue - } else if line[0] == '-' { + case line[0] == '-': curFile.Deletion++ diff.TotalDeletion++ diffLine := &DiffLine{Type: DIFF_LINE_DEL, Content: line, LeftIdx: leftLine} @@ -129,6 +132,8 @@ func ParsePatch(reader io.Reader) (*Diff, error) { leftLine++ } curSection.Lines = append(curSection.Lines, diffLine) + case strings.HasPrefix(line, "Binary"): + curFile.IsBin = true continue } diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go index edeb256ffe..5ed5d16a62 100644 --- a/modules/avatar/avatar.go +++ b/modules/avatar/avatar.go @@ -157,9 +157,9 @@ func (this *service) ServeHTTP(w http.ResponseWriter, r *http.Request) { avatar := New(hash, this.cacheDir) avatar.AlterImage = this.altImage if avatar.Expired() { - err := avatar.UpdateTimeout(time.Millisecond * 500) - if err != nil { + if err := avatar.UpdateTimeout(time.Millisecond * 1000); err != nil { log.Trace("avatar update error: %v", err) + return } } if modtime, err := avatar.Modtime(); err == nil { @@ -250,6 +250,7 @@ func (this *thunderTask) Fetch() { var client = &http.Client{} func (this *thunderTask) fetch() error { + log.Debug("avatar.fetch(fetch new avatar): %s", this.Url) req, _ := http.NewRequest("GET", this.Url, nil) req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/jpeg,image/png,*/*;q=0.8") req.Header.Set("Accept-Encoding", "deflate,sdch") diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 14a3c7622c..6422f0a324 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -153,7 +153,7 @@ func Single(ctx *middleware.Context, params martini.Params) { } else { ctx.Data["FileSize"] = blob.Size() ctx.Data["IsFile"] = true - ctx.Data["FileName"] = blob.Name + ctx.Data["FileName"] = blob.Name() ext := path.Ext(blob.Name()) if len(ext) > 0 { ext = ext[1:] @@ -226,7 +226,7 @@ func Single(ctx *middleware.Context, params martini.Params) { ctx.Data["FileLink"] = rawLink + "/" + treename _, isTextFile := base.IsTextFile(data) ctx.Data["FileIsText"] = isTextFile - ctx.Data["FileName"] = readmeFile.Name + ctx.Data["FileName"] = readmeFile.Name() if isTextFile { ctx.Data["FileContent"] = string(base.RenderMarkdown(data, branchLink)) } diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index cd3f2b83a9..e5b22192f5 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -4,7 +4,7 @@ Dashboard Help{{if .IsSigned}} - {{if .HasAccess}}