IP: RC Code Review

tokarchuk/v1.17
Unknown 11 years ago
parent 6b43067e1b
commit f76eb8a666
  1. 2
      README.md
  2. 2
      README_ZH.md
  3. 1
      conf/app.ini
  4. 2
      gogs.go
  5. 27
      models/issue.go
  6. 35
      models/repo.go
  7. 5
      templates/issue/list.tmpl
  8. 39
      templates/issue/user.tmpl

@ -5,7 +5,7 @@ Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language
![Demo](http://gowalker.org/public/gogs_demo.gif) ![Demo](http://gowalker.org/public/gogs_demo.gif)
##### Current version: 0.1.8 Alpha ##### Current version: 0.1.9 Alpha
#### Other language version #### Other language version

@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个由 Go 语言编写的自助 Git 托管服务。
![Demo](http://gowalker.org/public/gogs_demo.gif) ![Demo](http://gowalker.org/public/gogs_demo.gif)
##### 当前版本:0.1.8 Alpha ##### 当前版本:0.1.9 Alpha
## 开发目的 ## 开发目的

@ -32,6 +32,7 @@ PATH = data/gogs.db
[admin] [admin]
[security] [security]
INSTALL_LOCK = false
; Use HTTPS to clone repository, otherwise use HTTP. ; Use HTTPS to clone repository, otherwise use HTTP.
ENABLE_HTTPS_CLONE = false ENABLE_HTTPS_CLONE = false
; !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!! ; !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!!

@ -19,7 +19,7 @@ import (
// Test that go1.2 tag above is included in builds. main.go refers to this definition. // Test that go1.2 tag above is included in builds. main.go refers to this definition.
const go12tag = true const go12tag = true
const APP_VER = "0.1.8.0327 Alpha" const APP_VER = "0.1.9.0327 Alpha"
func init() { func init() {
base.AppVer = APP_VER base.AppVer = APP_VER

@ -37,12 +37,7 @@ type Issue struct {
} }
// CreateIssue creates new issue for repository. // CreateIssue creates new issue for repository.
func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int, name, labels, content string, isPull bool) (*Issue, error) { func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int, name, labels, content string, isPull bool) (issue *Issue, err error) {
count, err := GetIssueCount(repoId)
if err != nil {
return nil, err
}
// TODO: find out mentions // TODO: find out mentions
mentions := "" mentions := ""
@ -50,8 +45,8 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int,
defer sess.Close() defer sess.Close()
sess.Begin() sess.Begin()
issue := &Issue{ issue = &Issue{
Index: count + 1, Index: int64(issueCount) + 1,
Name: name, Name: name,
RepoId: repoId, RepoId: repoId,
PosterId: userId, PosterId: userId,
@ -81,11 +76,6 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int,
return issue, nil return issue, nil
} }
// GetIssueCount returns count of issues in the repository.
func GetIssueCount(repoId int64) (int64, error) {
return orm.Count(&Issue{RepoId: repoId})
}
// GetIssueById returns issue object by given id. // GetIssueById returns issue object by given id.
func GetIssueByIndex(repoId, index int64) (*Issue, error) { func GetIssueByIndex(repoId, index int64) (*Issue, error) {
issue := &Issue{RepoId: repoId, Index: index} issue := &Issue{RepoId: repoId, Index: index}
@ -148,16 +138,10 @@ func GetIssues(userId, repoId, posterId, milestoneId int64, page int, isClosed,
// UpdateIssue updates information of issue. // UpdateIssue updates information of issue.
func UpdateIssue(issue *Issue) error { func UpdateIssue(issue *Issue) error {
_, err := orm.Update(issue, &Issue{RepoId: issue.RepoId, Index: issue.Index}) _, err := orm.Id(issue.Id).AllCols().Update(issue)
return err return err
} }
func CloseIssue() {
}
func ReopenIssue() {
}
// Label represents a list of labels of repository for issues. // Label represents a list of labels of repository for issues.
type Label struct { type Label struct {
Id int64 Id int64
@ -197,8 +181,7 @@ func CreateComment(userId, issueId, commitId, line int64, content string) error
sess.Begin() sess.Begin()
if _, err := orm.Insert(&Comment{PosterId: userId, IssueId: issueId, if _, err := orm.Insert(&Comment{PosterId: userId, IssueId: issueId,
CommitId: commitId, Line: line, Content: content, CommitId: commitId, Line: line, Content: content}); err != nil {
}); err != nil {
sess.Rollback() sess.Rollback()
return err return err
} }

@ -96,12 +96,11 @@ func IsRepositoryExist(user *User, repoName string) (bool, error) {
has, err := orm.Where("lower_name = ?", strings.ToLower(repoName)).Get(&repo) has, err := orm.Where("lower_name = ?", strings.ToLower(repoName)).Get(&repo)
if err != nil { if err != nil {
return has, err return has, err
} else if !has {
return false, nil
} }
s, err := os.Stat(RepoPath(user.Name, repoName))
if err != nil { return com.IsDir(RepoPath(user.Name, repoName)), nil
return false, nil // Error simply means does not exist, but we don't want to show up.
}
return s.IsDir(), nil
} }
var ( var (
@ -224,16 +223,24 @@ func initRepoCommit(tmpPath string, sig *git.Signature) (err error) {
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "add", "--all"); err != nil { if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "add", "--all"); err != nil {
return err return err
} }
log.Trace("stderr(1): %s", stderr) if len(stderr) > 0 {
log.Trace("stderr(1): %s", stderr)
}
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email), if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email),
"-m", "Init commit"); err != nil { "-m", "Init commit"); err != nil {
return err return err
} }
log.Trace("stderr(2): %s", stderr) if len(stderr) > 0 {
log.Trace("stderr(2): %s", stderr)
}
if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "push", "origin", "master"); err != nil { if _, stderr, err = com.ExecCmdDir(tmpPath, "git", "push", "origin", "master"); err != nil {
return err return err
} }
log.Trace("stderr(3): %s", stderr) if len(stderr) > 0 {
log.Trace("stderr(3): %s", stderr)
}
return nil return nil
} }
@ -243,10 +250,9 @@ func createHookUpdate(hookPath, content string) error {
return err return err
} }
defer pu.Close() defer pu.Close()
if _, err = pu.WriteString(content); err != nil {
return err _, err = pu.WriteString(content)
} return err
return nil
} }
// InitRepository initializes README and .gitignore if needed. // InitRepository initializes README and .gitignore if needed.
@ -322,10 +328,7 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
} }
// Apply changes and commit. // Apply changes and commit.
if err := initRepoCommit(tmpDir, user.NewGitSig()); err != nil { return initRepoCommit(tmpDir, user.NewGitSig())
return err
}
return nil
} }
// UserRepo reporesents a repository with user name. // UserRepo reporesents a repository with user name.

@ -7,8 +7,9 @@
<div class="col-md-3 filter-list"> <div class="col-md-3 filter-list">
<ul class="list-unstyled"> <ul class="list-unstyled">
<li><a href="#" class="active">All Issues <strong class="pull-right">{{.IssueCount}}</strong></a></li> <li><a href="#" class="active">All Issues <strong class="pull-right">{{.IssueCount}}</strong></a></li>
<!-- <li><a href="#">My Issues</a></li> <!-- <li><a href="#">Assigned to you</a></li> -->
<li><a href="#">Mentioned</a></li> --> <li><a href="#">Created by you</a></li>
<!-- <li><a href="#">Mentioned</a></li> -->
</ul> </ul>
</div> </div>
<div class="col-md-9"> <div class="col-md-9">

@ -17,8 +17,9 @@
<div class="col-md-3 filter-list"> <div class="col-md-3 filter-list">
<ul class="list-unstyled"> <ul class="list-unstyled">
<li><a href="#" class="active">In your repositories <strong class="pull-right">10</strong></a></li> <li><a href="#" class="active">In your repositories <strong class="pull-right">10</strong></a></li>
<!-- <li><a href="#">Assigned to you</a></li> -->
<li><a href="#">Created by you</a></li> <li><a href="#">Created by you</a></li>
<li><a href="#">Assigned to you</a></li> <!-- <li><a href="#">Assigned to you</a></li> -->
<li><hr/></li> <li><hr/></li>
<li><a href="" class="sm">gogits/gogs <strong class="pull-right">12</strong></a></li> <li><a href="" class="sm">gogits/gogs <strong class="pull-right">12</strong></a></li>
<li><a href="" class="sm">gogits/session <strong class="pull-right">8</strong></a></li> <li><a href="" class="sm">gogits/session <strong class="pull-right">8</strong></a></li>
@ -33,36 +34,18 @@
</div> </div>
</div> </div>
<div class="issues list-group"> <div class="issues list-group">
<div class="list-group-item unread issue-item" id="issue-id"> {{range .Issues}}
<span class="number pull-right">#123</span> <div class="list-group-item issue-item" id="issue-{{.Id}}">
<h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5> <span class="number pull-right">#{{.Index}}</span>
<h5 class="title"><a href="/{{$.RepositoryLink}}/issues/{{.Index}}">{{.Name}}</a></h5>
<p class="info"> <p class="info">
<span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/> <span class="author"><img class="avatar" src="{{.Poster.AvatarLink}}" alt="" width="20"/>
<a href="#">Obama</a></span> <a href="/user/{{.Poster.Name}}">{{.Poster.Name}}</a></span>
<span class="time">3 days ago</span> <span class="time">{{TimeSince .Created}}</span>
<span class="comment"><i class="fa fa-comments"></i> 3</span> <span class="comment"><i class="fa fa-comments"></i> {{.NumComments}}</span>
</p>
</div>
<div class="list-group-item issue-item" id="issue-id2">
<span class="number pull-right">#123</span>
<h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5>
<p class="info">
<span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/>
<a href="#">Obama</a></span>
<span class="time">3 days ago</span>
<span class="comment"><i class="fa fa-comments"></i> 3</span>
</p>
</div>
<div class="list-group-item issue-item" id="issue-id3">
<span class="number pull-right">#123</span>
<h5 class="title"><a href="#">Bug: When running tests after generating a beego app, templates do not load.</a></h5>
<p class="info">
<span class="author"><img class="avatar" src="http://tp2.sinaimg.cn/5068084885/50/40050297589/1" alt="" width="20"/>
<a href="#">Obama</a></span>
<span class="time">3 days ago</span>
<span class="comment"><i class="fa fa-comments"></i> 3</span>
</p> </p>
</div> </div>
{{end}}
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save