add new status: checking

pull/197/head
Unknwon 9 years ago
parent 9825760817
commit 4dc6285715
  1. 2
      gogs.go
  2. 20
      models/issue.go
  3. 2
      routers/repo/pull.go
  4. 2
      templates/.VERSION

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.6.16.1017 Beta" const APP_VER = "0.6.16.1018 Beta"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

@ -904,10 +904,18 @@ func UpdateIssueUsersByMentions(uids []int64, iid int64) error {
type PullRequestType int type PullRequestType int
const ( const (
PULL_REQUEST_GOGS = iota PULL_REQUEST_GOGS PullRequestType = iota
PLLL_ERQUEST_GIT PLLL_ERQUEST_GIT
) )
type PullRequestStatus int
const (
PULL_REQUEST_STATUS_CONFLICT PullRequestStatus = iota
PULL_REQUEST_STATUS_CHECKING
PULL_REQUEST_STATUS_MERGEABLE
)
// PullRequest represents relation between pull request and repositories. // PullRequest represents relation between pull request and repositories.
type PullRequest struct { type PullRequest struct {
ID int64 `xorm:"pk autoincr"` ID int64 `xorm:"pk autoincr"`
@ -923,7 +931,7 @@ type PullRequest struct {
MergeBase string `xorm:"VARCHAR(40)"` MergeBase string `xorm:"VARCHAR(40)"`
MergedCommitID string `xorm:"VARCHAR(40)"` MergedCommitID string `xorm:"VARCHAR(40)"`
Type PullRequestType Type PullRequestType
CanAutoMerge bool Status PullRequestStatus
HasMerged bool HasMerged bool
Merged time.Time Merged time.Time
MergerID int64 MergerID int64
@ -963,6 +971,10 @@ func (pr *PullRequest) AfterSet(colName string, _ xorm.Cell) {
} }
} }
func (pr *PullRequest) CanAutoMerge() bool {
return pr.Status == PULL_REQUEST_STATUS_MERGEABLE
}
// Merge merges pull request to base repository. // Merge merges pull request to base repository.
func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error) { func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error) {
sess := x.NewSession() sess := x.NewSession()
@ -1076,13 +1088,13 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
return fmt.Errorf("save patch: %v", err) return fmt.Errorf("save patch: %v", err)
} }
pr.CanAutoMerge = true pr.Status = PULL_REQUEST_STATUS_MERGEABLE
_, stderr, err := process.ExecDir(-1, repo.LocalCopyPath(), _, stderr, err := process.ExecDir(-1, repo.LocalCopyPath(),
fmt.Sprintf("NewPullRequest(git apply --check): %d", repo.ID), fmt.Sprintf("NewPullRequest(git apply --check): %d", repo.ID),
"git", "apply", "--check", patchPath) "git", "apply", "--check", patchPath)
if err != nil { if err != nil {
if strings.Contains(stderr, "patch does not apply") { if strings.Contains(stderr, "patch does not apply") {
pr.CanAutoMerge = false pr.Status = PULL_REQUEST_STATUS_CONFLICT
} else { } else {
return fmt.Errorf("git apply --check: %v - %s", err, stderr) return fmt.Errorf("git apply --check: %v - %s", err, stderr)
} }

@ -374,7 +374,7 @@ func MergePullRequest(ctx *middleware.Context) {
return return
} }
if !pr.CanAutoMerge || pr.HasMerged { if !pr.CanAutoMerge() || pr.HasMerged {
ctx.Handle(404, "MergePullRequest", nil) ctx.Handle(404, "MergePullRequest", nil)
return return
} }

@ -1 +1 @@
0.6.16.1017 Beta 0.6.16.1018 Beta
Loading…
Cancel
Save