summaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-10-18 17:18:45 -0400
committerUnknwon <u@gogs.io>2015-10-18 17:18:54 -0400
commit4dc6285715ccd1e90cb4e437a3c2b1d0b13d47cb (patch)
treef6ba3ef13ecf8763739944faf4708488e5dcc3fa /models/issue.go
parent9825760817eab55708c0248a6cbd94376b7c7fe4 (diff)
downloadgitea-4dc6285715ccd1e90cb4e437a3c2b1d0b13d47cb.tar.gz
gitea-4dc6285715ccd1e90cb4e437a3c2b1d0b13d47cb.zip
add new status: checking
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/models/issue.go b/models/issue.go
index 0dd0b66370..5357cbf7b9 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -904,10 +904,18 @@ func UpdateIssueUsersByMentions(uids []int64, iid int64) error {
type PullRequestType int
const (
- PULL_REQUEST_GOGS = iota
+ PULL_REQUEST_GOGS PullRequestType = iota
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.
type PullRequest struct {
ID int64 `xorm:"pk autoincr"`
@@ -923,7 +931,7 @@ type PullRequest struct {
MergeBase string `xorm:"VARCHAR(40)"`
MergedCommitID string `xorm:"VARCHAR(40)"`
Type PullRequestType
- CanAutoMerge bool
+ Status PullRequestStatus
HasMerged bool
Merged time.Time
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.
func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error) {
sess := x.NewSession()
@@ -1076,13 +1088,13 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
return fmt.Errorf("save patch: %v", err)
}
- pr.CanAutoMerge = true
+ pr.Status = PULL_REQUEST_STATUS_MERGEABLE
_, stderr, err := process.ExecDir(-1, repo.LocalCopyPath(),
fmt.Sprintf("NewPullRequest(git apply --check): %d", repo.ID),
"git", "apply", "--check", patchPath)
if err != nil {
if strings.Contains(stderr, "patch does not apply") {
- pr.CanAutoMerge = false
+ pr.Status = PULL_REQUEST_STATUS_CONFLICT
} else {
return fmt.Errorf("git apply --check: %v - %s", err, stderr)
}