#2697 fix panic when close issue via commit message
This commit is contained in:
parent
4438b7793b
commit
129638117f
|
@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
|
||||||
|
|
||||||
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
||||||
|
|
||||||
##### Current version: 0.8.44
|
##### Current version: 0.8.45
|
||||||
|
|
||||||
| Web | UI | Preview |
|
| Web | UI | Preview |
|
||||||
|:-------------:|:-------:|:-------:|
|
|:-------------:|:-------:|:-------:|
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.8.44.0225"
|
const APP_VER = "0.8.45.0225"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -368,7 +368,7 @@ func updateIssuesCommit(u *User, repo *Repository, repoUserName, repoName string
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = issue.ChangeStatus(u, true); err != nil {
|
if err = issue.ChangeStatus(u, repo, true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ func updateIssuesCommit(u *User, repo *Repository, repoUserName, repoName string
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = issue.ChangeStatus(u, false); err != nil {
|
if err = issue.ChangeStatus(u, repo, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ func (i *Issue) ReadBy(uid int64) error {
|
||||||
return UpdateIssueUserByRead(uid, i.ID)
|
return UpdateIssueUserByRead(uid, i.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Issue) changeStatus(e *xorm.Session, doer *User, isClosed bool) (err error) {
|
func (i *Issue) changeStatus(e *xorm.Session, doer *User, repo *Repository, isClosed bool) (err error) {
|
||||||
if i.IsClosed == isClosed {
|
if i.IsClosed == isClosed {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ func (i *Issue) changeStatus(e *xorm.Session, doer *User, isClosed bool) (err er
|
||||||
}
|
}
|
||||||
|
|
||||||
// New action comment.
|
// New action comment.
|
||||||
if _, err = createStatusComment(e, doer, i.Repo, i); err != nil {
|
if _, err = createStatusComment(e, doer, repo, i); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,14 +259,14 @@ func (i *Issue) changeStatus(e *xorm.Session, doer *User, isClosed bool) (err er
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeStatus changes issue status to open/closed.
|
// ChangeStatus changes issue status to open/closed.
|
||||||
func (i *Issue) ChangeStatus(doer *User, isClosed bool) (err error) {
|
func (i *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (err error) {
|
||||||
sess := x.NewSession()
|
sess := x.NewSession()
|
||||||
defer sessionRelease(sess)
|
defer sessionRelease(sess)
|
||||||
if err = sess.Begin(); err != nil {
|
if err = sess.Begin(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = i.changeStatus(sess, doer, isClosed); err != nil {
|
if err = i.changeStatus(sess, doer, repo, isClosed); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = pr.Issue.changeStatus(sess, doer, true); err != nil {
|
if err = pr.Issue.changeStatus(sess, doer, pr.Issue.Repo, true); err != nil {
|
||||||
return fmt.Errorf("Issue.changeStatus: %v", err)
|
return fmt.Errorf("Issue.changeStatus: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -914,8 +914,7 @@ func NewComment(ctx *middleware.Context, form auth.CreateCommentForm) {
|
||||||
if pr != nil {
|
if pr != nil {
|
||||||
ctx.Flash.Info(ctx.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index))
|
ctx.Flash.Info(ctx.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index))
|
||||||
} else {
|
} else {
|
||||||
issue.Repo = ctx.Repo.Repository
|
if err = issue.ChangeStatus(ctx.User, ctx.Repo.Repository, form.Status == "close"); err != nil {
|
||||||
if err = issue.ChangeStatus(ctx.User, form.Status == "close"); err != nil {
|
|
||||||
log.Error(4, "ChangeStatus: %v", err)
|
log.Error(4, "ChangeStatus: %v", err)
|
||||||
} else {
|
} else {
|
||||||
log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed)
|
log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.8.44.0225
|
0.8.45.0225
|
Loading…
Reference in a new issue