summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-27 15:24:11 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-27 15:24:11 -0400
commitf76eb8a6662dd705f4c59fd59e583a315a1900d2 (patch)
tree24ec9b457cf5be1b018a72e65e68ee1bc82f5ca5
parent6b43067e1be051e8cd353d332d61613e18ad11f4 (diff)
downloadgitea-f76eb8a6662dd705f4c59fd59e583a315a1900d2.tar.gz
gitea-f76eb8a6662dd705f4c59fd59e583a315a1900d2.zip
IP: RC Code Review
-rw-r--r--README.md2
-rw-r--r--README_ZH.md2
-rw-r--r--conf/app.ini1
-rw-r--r--gogs.go2
-rw-r--r--models/issue.go27
-rw-r--r--models/repo.go35
-rw-r--r--templates/issue/list.tmpl5
-rw-r--r--templates/issue/user.tmpl39
8 files changed, 42 insertions, 71 deletions
diff --git a/README.md b/README.md
index 9d1d7ef569..7d688506d6 100644
--- a/README.md
+++ b/README.md
@@ -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)
-##### Current version: 0.1.8 Alpha
+##### Current version: 0.1.9 Alpha
#### Other language version
diff --git a/README_ZH.md b/README_ZH.md
index 9698ce4faa..8e187c7364 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个由 Go 语言编写的自助 Git 托管服务。
![Demo](http://gowalker.org/public/gogs_demo.gif)
-##### 当前版本:0.1.8 Alpha
+##### 当前版本:0.1.9 Alpha
## 开发目的
diff --git a/conf/app.ini b/conf/app.ini
index 1a96ebeab6..d988b4acbc 100644
--- a/conf/app.ini
+++ b/conf/app.ini
@@ -32,6 +32,7 @@ PATH = data/gogs.db
[admin]
[security]
+INSTALL_LOCK = false
; Use HTTPS to clone repository, otherwise use HTTP.
ENABLE_HTTPS_CLONE = false
; !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!!
diff --git a/gogs.go b/gogs.go
index 57d9d62c67..f2f408cccb 100644
--- a/gogs.go
+++ b/gogs.go
@@ -19,7 +19,7 @@ import (
// Test that go1.2 tag above is included in builds. main.go refers to this definition.
const go12tag = true
-const APP_VER = "0.1.8.0327 Alpha"
+const APP_VER = "0.1.9.0327 Alpha"
func init() {
base.AppVer = APP_VER
diff --git a/models/issue.go b/models/issue.go
index 6b657b7b90..b05667c3a8 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -37,12 +37,7 @@ type Issue struct {
}
// CreateIssue creates new issue for repository.
-func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int, name, labels, content string, isPull bool) (*Issue, error) {
- count, err := GetIssueCount(repoId)
- if err != nil {
- return nil, err
- }
-
+func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int, name, labels, content string, isPull bool) (issue *Issue, err error) {
// TODO: find out mentions
mentions := ""
@@ -50,8 +45,8 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int,
defer sess.Close()
sess.Begin()
- issue := &Issue{
- Index: count + 1,
+ issue = &Issue{
+ Index: int64(issueCount) + 1,
Name: name,
RepoId: repoId,
PosterId: userId,
@@ -81,11 +76,6 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int,
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.
func GetIssueByIndex(repoId, index int64) (*Issue, error) {
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.
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
}
-func CloseIssue() {
-}
-
-func ReopenIssue() {
-}
-
// Label represents a list of labels of repository for issues.
type Label struct {
Id int64
@@ -197,8 +181,7 @@ func CreateComment(userId, issueId, commitId, line int64, content string) error
sess.Begin()
if _, err := orm.Insert(&Comment{PosterId: userId, IssueId: issueId,
- CommitId: commitId, Line: line, Content: content,
- }); err != nil {
+ CommitId: commitId, Line: line, Content: content}); err != nil {
sess.Rollback()
return err
}
diff --git a/models/repo.go b/models/repo.go
index c8ffc851f9..e6d4639b02 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -96,12 +96,11 @@ func IsRepositoryExist(user *User, repoName string) (bool, error) {
has, err := orm.Where("lower_name = ?", strings.ToLower(repoName)).Get(&repo)
if err != nil {
return has, err
+ } else if !has {
+ return false, nil
}
- s, err := os.Stat(RepoPath(user.Name, repoName))
- if err != nil {
- return false, nil // Error simply means does not exist, but we don't want to show up.
- }
- return s.IsDir(), nil
+
+ return com.IsDir(RepoPath(user.Name, repoName)), nil
}
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 {
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),
"-m", "Init commit"); err != nil {
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 {
return err
}
- log.Trace("stderr(3): %s", stderr)
+ if len(stderr) > 0 {
+ log.Trace("stderr(3): %s", stderr)
+ }
return nil
}
@@ -243,10 +250,9 @@ func createHookUpdate(hookPath, content string) error {
return err
}
defer pu.Close()
- if _, err = pu.WriteString(content); err != nil {
- return err
- }
- return nil
+
+ _, err = pu.WriteString(content)
+ return err
}
// 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.
- if err := initRepoCommit(tmpDir, user.NewGitSig()); err != nil {
- return err
- }
- return nil
+ return initRepoCommit(tmpDir, user.NewGitSig())
}
// UserRepo reporesents a repository with user name.
diff --git a/templates/issue/list.tmpl b/templates/issue/list.tmpl
index 401a53a3ed..b8947d9fc5 100644
--- a/templates/issue/list.tmpl
+++ b/templates/issue/list.tmpl
@@ -7,8 +7,9 @@
<div class="col-md-3 filter-list">
<ul class="list-unstyled">
<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="#">Mentioned</a></li> -->
+ <!-- <li><a href="#">Assigned to you</a></li> -->
+ <li><a href="#">Created by you</a></li>
+ <!-- <li><a href="#">Mentioned</a></li> -->
</ul>
</div>
<div class="col-md-9">
diff --git a/templates/issue/user.tmpl b/templates/issue/user.tmpl
index 2cf9571306..cf5e365dcf 100644
--- a/templates/issue/user.tmpl
+++ b/templates/issue/user.tmpl
@@ -17,8 +17,9 @@
<div class="col-md-3 filter-list">
<ul class="list-unstyled">
<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="#">Assigned to you</a></li>
+ <!-- <li><a href="#">Assigned to you</a></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/session <strong class="pull-right">8</strong></a></li>
@@ -33,36 +34,18 @@
</div>
</div>
<div class="issues list-group">
- <div class="list-group-item unread issue-item" id="issue-id">
- <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>
+ {{range .Issues}}
+ <div class="list-group-item issue-item" id="issue-{{.Id}}">
+ <span class="number pull-right">#{{.Index}}</span>
+ <h5 class="title"><a href="/{{$.RepositoryLink}}/issues/{{.Index}}">{{.Name}}</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-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>
+ <span class="author"><img class="avatar" src="{{.Poster.AvatarLink}}" alt="" width="20"/>
+ <a href="/user/{{.Poster.Name}}">{{.Poster.Name}}</a></span>
+ <span class="time">{{TimeSince .Created}}</span>
+ <span class="comment"><i class="fa fa-comments"></i> {{.NumComments}}</span>
</p>
</div>
+ {{end}}
</div>
</div>
</div>