#1595 pushing new branch will rereference issues in previous branch
This commit is contained in:
parent
c3061c61a7
commit
c8d92fad30
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.6.9.0909 Beta"
|
const APP_VER = "0.6.9.0910 Beta"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -220,7 +220,7 @@ func updateIssuesCommit(u *User, repo *Repository, repoUserName, repoName string
|
||||||
|
|
||||||
url := fmt.Sprintf("%s/%s/%s/commit/%s", setting.AppSubUrl, repoUserName, repoName, c.Sha1)
|
url := fmt.Sprintf("%s/%s/%s/commit/%s", setting.AppSubUrl, repoUserName, repoName, c.Sha1)
|
||||||
message := fmt.Sprintf(`<a href="%s">%s</a>`, url, c.Message)
|
message := fmt.Sprintf(`<a href="%s">%s</a>`, url, c.Message)
|
||||||
if _, err = CreateComment(u, repo, issue, 0, 0, COMMENT_TYPE_COMMIT_REF, message, nil); err != nil {
|
if err = CreateRefComment(u, repo, issue, message, c.Sha1); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1685,6 +1685,9 @@ type Comment struct {
|
||||||
RenderedContent string `xorm:"-"`
|
RenderedContent string `xorm:"-"`
|
||||||
Created time.Time `xorm:"CREATED"`
|
Created time.Time `xorm:"CREATED"`
|
||||||
|
|
||||||
|
// Reference issue in commit message
|
||||||
|
CommitSHA string `xorm:"VARCHAR(40)"`
|
||||||
|
|
||||||
Attachments []*Attachment `xorm:"-"`
|
Attachments []*Attachment `xorm:"-"`
|
||||||
|
|
||||||
// For view issue page.
|
// For view issue page.
|
||||||
|
@ -1733,14 +1736,15 @@ func (c *Comment) EventTag() string {
|
||||||
return "event-" + com.ToStr(c.ID)
|
return "event-" + com.ToStr(c.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createComment(e *xorm.Session, u *User, repo *Repository, issue *Issue, commitID, line int64, cmtType CommentType, content string, uuids []string) (_ *Comment, err error) {
|
func createComment(e *xorm.Session, u *User, repo *Repository, issue *Issue, commitID, line int64, cmtType CommentType, content, commitSHA string, uuids []string) (_ *Comment, err error) {
|
||||||
comment := &Comment{
|
comment := &Comment{
|
||||||
PosterID: u.Id,
|
PosterID: u.Id,
|
||||||
Type: cmtType,
|
Type: cmtType,
|
||||||
IssueID: issue.ID,
|
IssueID: issue.ID,
|
||||||
CommitID: commitID,
|
CommitID: commitID,
|
||||||
Line: line,
|
Line: line,
|
||||||
Content: content,
|
Content: content,
|
||||||
|
CommitSHA: commitSHA,
|
||||||
}
|
}
|
||||||
if _, err = e.Insert(comment); err != nil {
|
if _, err = e.Insert(comment); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1819,18 +1823,18 @@ func createStatusComment(e *xorm.Session, doer *User, repo *Repository, issue *I
|
||||||
if !issue.IsClosed {
|
if !issue.IsClosed {
|
||||||
cmtType = COMMENT_TYPE_REOPEN
|
cmtType = COMMENT_TYPE_REOPEN
|
||||||
}
|
}
|
||||||
return createComment(e, doer, repo, issue, 0, 0, cmtType, "", nil)
|
return createComment(e, doer, repo, issue, 0, 0, cmtType, "", "", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateComment creates comment of issue or commit.
|
// CreateComment creates comment of issue or commit.
|
||||||
func CreateComment(doer *User, repo *Repository, issue *Issue, commitID, line int64, cmtType CommentType, content string, attachments []string) (comment *Comment, err error) {
|
func CreateComment(doer *User, repo *Repository, issue *Issue, commitID, line int64, cmtType CommentType, content, commitSHA string, attachments []string) (comment *Comment, 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 nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
comment, err = createComment(sess, doer, repo, issue, commitID, line, cmtType, content, attachments)
|
comment, err = createComment(sess, doer, repo, issue, commitID, line, cmtType, content, commitSHA, attachments)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1840,7 +1844,29 @@ func CreateComment(doer *User, repo *Repository, issue *Issue, commitID, line in
|
||||||
|
|
||||||
// CreateIssueComment creates a plain issue comment.
|
// CreateIssueComment creates a plain issue comment.
|
||||||
func CreateIssueComment(doer *User, repo *Repository, issue *Issue, content string, attachments []string) (*Comment, error) {
|
func CreateIssueComment(doer *User, repo *Repository, issue *Issue, content string, attachments []string) (*Comment, error) {
|
||||||
return CreateComment(doer, repo, issue, 0, 0, COMMENT_TYPE_COMMENT, content, attachments)
|
return CreateComment(doer, repo, issue, 0, 0, COMMENT_TYPE_COMMENT, content, "", attachments)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRefComment creates a commit reference comment to issue.
|
||||||
|
func CreateRefComment(doer *User, repo *Repository, issue *Issue, content, commitSHA string) error {
|
||||||
|
if len(commitSHA) == 0 {
|
||||||
|
return fmt.Errorf("cannot create reference with empty commit SHA")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if same reference from same commit has already existed.
|
||||||
|
has, err := x.Get(&Comment{
|
||||||
|
Type: COMMENT_TYPE_COMMIT_REF,
|
||||||
|
IssueID: issue.ID,
|
||||||
|
CommitSHA: commitSHA,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("check reference comment: %v", err)
|
||||||
|
} else if has {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = CreateComment(doer, repo, issue, 0, 0, COMMENT_TYPE_COMMIT_REF, content, commitSHA, nil)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCommentByID returns the comment by given ID.
|
// GetCommentByID returns the comment by given ID.
|
||||||
|
|
|
@ -29,7 +29,6 @@ import (
|
||||||
|
|
||||||
var Sanitizer = bluemonday.UGCPolicy().AllowAttrs("class").Matching(regexp.MustCompile(`[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&]*`)).OnElements("code")
|
var Sanitizer = bluemonday.UGCPolicy().AllowAttrs("class").Matching(regexp.MustCompile(`[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&]*`)).OnElements("code")
|
||||||
|
|
||||||
|
|
||||||
// Encode string to md5 hex value.
|
// Encode string to md5 hex value.
|
||||||
func EncodeMd5(str string) string {
|
func EncodeMd5(str string) string {
|
||||||
m := md5.New()
|
m := md5.New()
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.6.9.0909 Beta
|
0.6.9.0910 Beta
|
Loading…
Reference in New Issue