forked from forgejo/forgejo
Move issues related files into models/issues (#19931)
* Move access and repo permission to models/perm/access * fix test * fix git test * Move functions sequence * Some improvements per @KN4CK3R and @delvh * Move issues related code to models/issues * Move some issues related sub package * Merge * Fix test * Fix test * Fix test * Fix test * Rename some files
This commit is contained in:
parent
3708ca8e28
commit
1a9821f57a
180 changed files with 3667 additions and 3677 deletions
|
@ -15,6 +15,7 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
access_model "code.gitea.io/gitea/models/perm/access"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
|
@ -44,9 +45,9 @@ var (
|
|||
)
|
||||
|
||||
// AddToTaskQueue adds itself to pull request test task queue.
|
||||
func AddToTaskQueue(pr *models.PullRequest) {
|
||||
func AddToTaskQueue(pr *issues_model.PullRequest) {
|
||||
err := prPatchCheckerQueue.PushFunc(strconv.FormatInt(pr.ID, 10), func() error {
|
||||
pr.Status = models.PullRequestStatusChecking
|
||||
pr.Status = issues_model.PullRequestStatusChecking
|
||||
err := pr.UpdateColsIfNotMerged("status")
|
||||
if err != nil {
|
||||
log.Error("AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err)
|
||||
|
@ -61,7 +62,7 @@ func AddToTaskQueue(pr *models.PullRequest) {
|
|||
}
|
||||
|
||||
// CheckPullMergable check if the pull mergable based on all conditions (branch protection, merge options, ...)
|
||||
func CheckPullMergable(stdCtx context.Context, doer *user_model.User, perm *access_model.Permission, pr *models.PullRequest, manuallMerge, force bool) error {
|
||||
func CheckPullMergable(stdCtx context.Context, doer *user_model.User, perm *access_model.Permission, pr *issues_model.PullRequest, manuallMerge, force bool) error {
|
||||
return db.WithTx(func(ctx context.Context) error {
|
||||
if pr.HasMerged {
|
||||
return ErrHasMerged
|
||||
|
@ -114,7 +115,7 @@ func CheckPullMergable(stdCtx context.Context, doer *user_model.User, perm *acce
|
|||
return err
|
||||
}
|
||||
|
||||
if noDeps, err := models.IssueNoDependenciesLeft(ctx, pr.Issue); err != nil {
|
||||
if noDeps, err := issues_model.IssueNoDependenciesLeft(ctx, pr.Issue); err != nil {
|
||||
return err
|
||||
} else if !noDeps {
|
||||
return ErrDependenciesLeft
|
||||
|
@ -125,7 +126,7 @@ func CheckPullMergable(stdCtx context.Context, doer *user_model.User, perm *acce
|
|||
}
|
||||
|
||||
// isSignedIfRequired check if merge will be signed if required
|
||||
func isSignedIfRequired(ctx context.Context, pr *models.PullRequest, doer *user_model.User) (bool, error) {
|
||||
func isSignedIfRequired(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User) (bool, error) {
|
||||
if err := pr.LoadProtectedBranchCtx(ctx); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -141,10 +142,10 @@ func isSignedIfRequired(ctx context.Context, pr *models.PullRequest, doer *user_
|
|||
|
||||
// checkAndUpdateStatus checks if pull request is possible to leaving checking status,
|
||||
// and set to be either conflict or mergeable.
|
||||
func checkAndUpdateStatus(pr *models.PullRequest) {
|
||||
func checkAndUpdateStatus(pr *issues_model.PullRequest) {
|
||||
// Status is not changed to conflict means mergeable.
|
||||
if pr.Status == models.PullRequestStatusChecking {
|
||||
pr.Status = models.PullRequestStatusMergeable
|
||||
if pr.Status == issues_model.PullRequestStatusChecking {
|
||||
pr.Status = issues_model.PullRequestStatusMergeable
|
||||
}
|
||||
|
||||
// Make sure there is no waiting test to process before leaving the checking status.
|
||||
|
@ -162,7 +163,7 @@ func checkAndUpdateStatus(pr *models.PullRequest) {
|
|||
|
||||
// getMergeCommit checks if a pull request got merged
|
||||
// Returns the git.Commit of the pull request if merged
|
||||
func getMergeCommit(ctx context.Context, pr *models.PullRequest) (*git.Commit, error) {
|
||||
func getMergeCommit(ctx context.Context, pr *issues_model.PullRequest) (*git.Commit, error) {
|
||||
if pr.BaseRepo == nil {
|
||||
var err error
|
||||
pr.BaseRepo, err = repo_model.GetRepositoryByID(pr.BaseRepoID)
|
||||
|
@ -230,7 +231,7 @@ func getMergeCommit(ctx context.Context, pr *models.PullRequest) (*git.Commit, e
|
|||
|
||||
// manuallyMerged checks if a pull request got manually merged
|
||||
// When a pull request got manually merged mark the pull request as merged
|
||||
func manuallyMerged(ctx context.Context, pr *models.PullRequest) bool {
|
||||
func manuallyMerged(ctx context.Context, pr *issues_model.PullRequest) bool {
|
||||
if err := pr.LoadBaseRepoCtx(ctx); err != nil {
|
||||
log.Error("PullRequest[%d].LoadBaseRepo: %v", pr.ID, err)
|
||||
return false
|
||||
|
@ -254,7 +255,7 @@ func manuallyMerged(ctx context.Context, pr *models.PullRequest) bool {
|
|||
if commit != nil {
|
||||
pr.MergedCommitID = commit.ID.String()
|
||||
pr.MergedUnix = timeutil.TimeStamp(commit.Author.When.Unix())
|
||||
pr.Status = models.PullRequestStatusManuallyMerged
|
||||
pr.Status = issues_model.PullRequestStatusManuallyMerged
|
||||
merger, _ := user_model.GetUserByEmail(commit.Author.Email)
|
||||
|
||||
// When the commit author is unknown set the BaseRepo owner as merger
|
||||
|
@ -287,7 +288,7 @@ func manuallyMerged(ctx context.Context, pr *models.PullRequest) bool {
|
|||
|
||||
// InitializePullRequests checks and tests untested patches of pull requests.
|
||||
func InitializePullRequests(ctx context.Context) {
|
||||
prs, err := models.GetPullRequestIDsByCheckStatus(models.PullRequestStatusChecking)
|
||||
prs, err := issues_model.GetPullRequestIDsByCheckStatus(issues_model.PullRequestStatusChecking)
|
||||
if err != nil {
|
||||
log.Error("Find Checking PRs: %v", err)
|
||||
return
|
||||
|
@ -323,7 +324,7 @@ func testPR(id int64) {
|
|||
ctx, _, finished := process.GetManager().AddContext(graceful.GetManager().HammerContext(), fmt.Sprintf("Test PR[%d] from patch checking queue", id))
|
||||
defer finished()
|
||||
|
||||
pr, err := models.GetPullRequestByID(ctx, id)
|
||||
pr, err := issues_model.GetPullRequestByID(ctx, id)
|
||||
if err != nil {
|
||||
log.Error("GetPullRequestByID[%d]: %v", id, err)
|
||||
return
|
||||
|
@ -339,7 +340,7 @@ func testPR(id int64) {
|
|||
|
||||
if err := TestPatch(pr); err != nil {
|
||||
log.Error("testPatch[%d]: %v", pr.ID, err)
|
||||
pr.Status = models.PullRequestStatusError
|
||||
pr.Status = issues_model.PullRequestStatusError
|
||||
if err := pr.UpdateCols("status"); err != nil {
|
||||
log.Error("update pr [%d] status to PullRequestStatusError failed: %v", pr.ID, err)
|
||||
}
|
||||
|
@ -350,7 +351,7 @@ func testPR(id int64) {
|
|||
|
||||
// CheckPrsForBaseBranch check all pulls with bseBrannch
|
||||
func CheckPrsForBaseBranch(baseRepo *repo_model.Repository, baseBranchName string) error {
|
||||
prs, err := models.GetUnmergedPullRequestsByBaseInfo(baseRepo.ID, baseBranchName)
|
||||
prs, err := issues_model.GetUnmergedPullRequestsByBaseInfo(baseRepo.ID, baseBranchName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/queue"
|
||||
|
||||
|
@ -43,12 +43,12 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) {
|
|||
|
||||
prPatchCheckerQueue = q.(queue.UniqueQueue)
|
||||
|
||||
pr := unittest.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
|
||||
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2}).(*issues_model.PullRequest)
|
||||
AddToTaskQueue(pr)
|
||||
|
||||
assert.Eventually(t, func() bool {
|
||||
pr = unittest.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
|
||||
return pr.Status == models.PullRequestStatusChecking
|
||||
pr = unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2}).(*issues_model.PullRequest)
|
||||
return pr.Status == issues_model.PullRequestStatusChecking
|
||||
}, 1*time.Second, 100*time.Millisecond)
|
||||
|
||||
has, err := prPatchCheckerQueue.Has(strconv.FormatInt(pr.ID, 10))
|
||||
|
@ -72,8 +72,8 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) {
|
|||
assert.False(t, has)
|
||||
assert.NoError(t, err)
|
||||
|
||||
pr = unittest.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
|
||||
assert.Equal(t, models.PullRequestStatusChecking, pr.Status)
|
||||
pr = unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2}).(*issues_model.PullRequest)
|
||||
assert.Equal(t, issues_model.PullRequestStatusChecking, pr.Status)
|
||||
|
||||
for _, callback := range queueShutdown {
|
||||
callback()
|
||||
|
|
|
@ -8,9 +8,9 @@ package pull
|
|||
import (
|
||||
"context"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
|
||||
|
@ -83,7 +83,7 @@ func IsCommitStatusContextSuccess(commitStatuses []*git_model.CommitStatus, requ
|
|||
}
|
||||
|
||||
// IsPullCommitStatusPass returns if all required status checks PASS
|
||||
func IsPullCommitStatusPass(ctx context.Context, pr *models.PullRequest) (bool, error) {
|
||||
func IsPullCommitStatusPass(ctx context.Context, pr *issues_model.PullRequest) (bool, error) {
|
||||
if err := pr.LoadProtectedBranchCtx(ctx); err != nil {
|
||||
return false, errors.Wrap(err, "GetLatestCommitStatus")
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ func IsPullCommitStatusPass(ctx context.Context, pr *models.PullRequest) (bool,
|
|||
}
|
||||
|
||||
// GetPullRequestCommitStatusState returns pull request merged commit status state
|
||||
func GetPullRequestCommitStatusState(ctx context.Context, pr *models.PullRequest) (structs.CommitStatusState, error) {
|
||||
func GetPullRequestCommitStatusState(ctx context.Context, pr *issues_model.PullRequest) (structs.CommitStatusState, error) {
|
||||
// Ensure HeadRepo is loaded
|
||||
if err := pr.LoadHeadRepoCtx(ctx); err != nil {
|
||||
return "", errors.Wrap(err, "LoadHeadRepo")
|
||||
|
@ -112,15 +112,15 @@ func GetPullRequestCommitStatusState(ctx context.Context, pr *models.PullRequest
|
|||
}
|
||||
defer closer.Close()
|
||||
|
||||
if pr.Flow == models.PullRequestFlowGithub && !headGitRepo.IsBranchExist(pr.HeadBranch) {
|
||||
if pr.Flow == issues_model.PullRequestFlowGithub && !headGitRepo.IsBranchExist(pr.HeadBranch) {
|
||||
return "", errors.New("Head branch does not exist, can not merge")
|
||||
}
|
||||
if pr.Flow == models.PullRequestFlowAGit && !git.IsReferenceExist(ctx, headGitRepo.Path, pr.GetGitRefName()) {
|
||||
if pr.Flow == issues_model.PullRequestFlowAGit && !git.IsReferenceExist(ctx, headGitRepo.Path, pr.GetGitRefName()) {
|
||||
return "", errors.New("Head branch does not exist, can not merge")
|
||||
}
|
||||
|
||||
var sha string
|
||||
if pr.Flow == models.PullRequestFlowGithub {
|
||||
if pr.Flow == issues_model.PullRequestFlowGithub {
|
||||
sha, err = headGitRepo.GetBranchCommitID(pr.HeadBranch)
|
||||
} else {
|
||||
sha, err = headGitRepo.GetRefCommitID(pr.GetGitRefName())
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
access_model "code.gitea.io/gitea/models/perm/access"
|
||||
unit_model "code.gitea.io/gitea/models/unit"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
|
@ -18,7 +18,7 @@ import (
|
|||
var ErrUserHasNoPermissionForAction = errors.New("user not allowed to do this action")
|
||||
|
||||
// SetAllowEdits allow edits from maintainers to PRs
|
||||
func SetAllowEdits(ctx context.Context, doer *user_model.User, pr *models.PullRequest, allow bool) error {
|
||||
func SetAllowEdits(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest, allow bool) error {
|
||||
if doer == nil || !pr.Issue.IsPoster(doer.ID) {
|
||||
return ErrUserHasNoPermissionForAction
|
||||
}
|
||||
|
@ -37,5 +37,5 @@ func SetAllowEdits(ctx context.Context, doer *user_model.User, pr *models.PullRe
|
|||
}
|
||||
|
||||
pr.AllowMaintainerEdit = allow
|
||||
return models.UpdateAllowEdits(ctx, pr)
|
||||
return issues_model.UpdateAllowEdits(ctx, pr)
|
||||
}
|
||||
|
|
|
@ -12,15 +12,15 @@ import (
|
|||
"strconv"
|
||||
"sync"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/modules/git/pipeline"
|
||||
"code.gitea.io/gitea/modules/lfs"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
)
|
||||
|
||||
// LFSPush pushes lfs objects referred to in new commits in the head repository from the base repository
|
||||
func LFSPush(ctx context.Context, tmpBasePath, mergeHeadSHA, mergeBaseSHA string, pr *models.PullRequest) error {
|
||||
func LFSPush(ctx context.Context, tmpBasePath, mergeHeadSHA, mergeBaseSHA string, pr *issues_model.PullRequest) error {
|
||||
// Now we have to implement git lfs push
|
||||
// git rev-list --objects --filter=blob:limit=1k HEAD --not base
|
||||
// pass blob shas in to git cat-file --batch-check (possibly unnecessary)
|
||||
|
@ -68,7 +68,7 @@ func LFSPush(ctx context.Context, tmpBasePath, mergeHeadSHA, mergeBaseSHA string
|
|||
return nil
|
||||
}
|
||||
|
||||
func createLFSMetaObjectsFromCatFileBatch(catFileBatchReader *io.PipeReader, wg *sync.WaitGroup, pr *models.PullRequest) {
|
||||
func createLFSMetaObjectsFromCatFileBatch(catFileBatchReader *io.PipeReader, wg *sync.WaitGroup, pr *issues_model.PullRequest) {
|
||||
defer wg.Done()
|
||||
defer catFileBatchReader.Close()
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
access_model "code.gitea.io/gitea/models/perm/access"
|
||||
pull_model "code.gitea.io/gitea/models/pull"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
|
@ -38,7 +39,7 @@ import (
|
|||
)
|
||||
|
||||
// GetDefaultMergeMessage returns default message used when merging pull request
|
||||
func GetDefaultMergeMessage(baseGitRepo *git.Repository, pr *models.PullRequest, mergeStyle repo_model.MergeStyle) (string, error) {
|
||||
func GetDefaultMergeMessage(baseGitRepo *git.Repository, pr *issues_model.PullRequest, mergeStyle repo_model.MergeStyle) (string, error) {
|
||||
if err := pr.LoadHeadRepo(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -131,7 +132,7 @@ func GetDefaultMergeMessage(baseGitRepo *git.Repository, pr *models.PullRequest,
|
|||
|
||||
// Merge merges pull request to base repository.
|
||||
// Caller should check PR is ready to be merged (review and status checks)
|
||||
func Merge(ctx context.Context, pr *models.PullRequest, doer *user_model.User, baseGitRepo *git.Repository, mergeStyle repo_model.MergeStyle, expectedHeadCommitID, message string) error {
|
||||
func Merge(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User, baseGitRepo *git.Repository, mergeStyle repo_model.MergeStyle, expectedHeadCommitID, message string) error {
|
||||
if err := pr.LoadHeadRepo(); err != nil {
|
||||
log.Error("LoadHeadRepo: %v", err)
|
||||
return fmt.Errorf("LoadHeadRepo: %v", err)
|
||||
|
@ -213,7 +214,7 @@ func Merge(ctx context.Context, pr *models.PullRequest, doer *user_model.User, b
|
|||
if close != ref.Issue.IsClosed {
|
||||
if err = issue_service.ChangeStatus(ref.Issue, doer, close); err != nil {
|
||||
// Allow ErrDependenciesLeft
|
||||
if !models.IsErrDependenciesLeft(err) {
|
||||
if !issues_model.IsErrDependenciesLeft(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +224,7 @@ func Merge(ctx context.Context, pr *models.PullRequest, doer *user_model.User, b
|
|||
}
|
||||
|
||||
// rawMerge perform the merge operation without changing any pull information in database
|
||||
func rawMerge(ctx context.Context, pr *models.PullRequest, doer *user_model.User, mergeStyle repo_model.MergeStyle, expectedHeadCommitID, message string) (string, error) {
|
||||
func rawMerge(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User, mergeStyle repo_model.MergeStyle, expectedHeadCommitID, message string) (string, error) {
|
||||
// Clone base repo.
|
||||
tmpBasePath, err := createTemporaryRepo(ctx, pr)
|
||||
if err != nil {
|
||||
|
@ -635,7 +636,7 @@ func rawMerge(ctx context.Context, pr *models.PullRequest, doer *user_model.User
|
|||
return mergeCommitID, nil
|
||||
}
|
||||
|
||||
func commitAndSignNoAuthor(ctx context.Context, pr *models.PullRequest, message, signArg, tmpBasePath string, env []string) error {
|
||||
func commitAndSignNoAuthor(ctx context.Context, pr *issues_model.PullRequest, message, signArg, tmpBasePath string, env []string) error {
|
||||
var outbuf, errbuf strings.Builder
|
||||
if signArg == "" {
|
||||
if err := git.NewCommand(ctx, "commit", "-m", message).
|
||||
|
@ -663,7 +664,7 @@ func commitAndSignNoAuthor(ctx context.Context, pr *models.PullRequest, message,
|
|||
return nil
|
||||
}
|
||||
|
||||
func runMergeCommand(pr *models.PullRequest, mergeStyle repo_model.MergeStyle, cmd *git.Command, tmpBasePath string) error {
|
||||
func runMergeCommand(pr *issues_model.PullRequest, mergeStyle repo_model.MergeStyle, cmd *git.Command, tmpBasePath string) error {
|
||||
var outbuf, errbuf strings.Builder
|
||||
if err := cmd.Run(&git.RunOpts{
|
||||
Dir: tmpBasePath,
|
||||
|
@ -747,7 +748,7 @@ func getDiffTree(ctx context.Context, repoPath, baseBranch, headBranch string) (
|
|||
}
|
||||
|
||||
// IsUserAllowedToMerge check if user is allowed to merge PR with given permissions and branch protections
|
||||
func IsUserAllowedToMerge(ctx context.Context, pr *models.PullRequest, p access_model.Permission, user *user_model.User) (bool, error) {
|
||||
func IsUserAllowedToMerge(ctx context.Context, pr *issues_model.PullRequest, p access_model.Permission, user *user_model.User) (bool, error) {
|
||||
if user == nil {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -765,7 +766,7 @@ func IsUserAllowedToMerge(ctx context.Context, pr *models.PullRequest, p access_
|
|||
}
|
||||
|
||||
// CheckPullBranchProtections checks whether the PR is ready to be merged (reviews and status checks)
|
||||
func CheckPullBranchProtections(ctx context.Context, pr *models.PullRequest, skipProtectedFilesCheck bool) (err error) {
|
||||
func CheckPullBranchProtections(ctx context.Context, pr *issues_model.PullRequest, skipProtectedFilesCheck bool) (err error) {
|
||||
if err = pr.LoadBaseRepoCtx(ctx); err != nil {
|
||||
return fmt.Errorf("LoadBaseRepo: %v", err)
|
||||
}
|
||||
|
@ -787,23 +788,23 @@ func CheckPullBranchProtections(ctx context.Context, pr *models.PullRequest, ski
|
|||
}
|
||||
}
|
||||
|
||||
if !models.HasEnoughApprovals(ctx, pr.ProtectedBranch, pr) {
|
||||
if !issues_model.HasEnoughApprovals(ctx, pr.ProtectedBranch, pr) {
|
||||
return models.ErrDisallowedToMerge{
|
||||
Reason: "Does not have enough approvals",
|
||||
}
|
||||
}
|
||||
if models.MergeBlockedByRejectedReview(ctx, pr.ProtectedBranch, pr) {
|
||||
if issues_model.MergeBlockedByRejectedReview(ctx, pr.ProtectedBranch, pr) {
|
||||
return models.ErrDisallowedToMerge{
|
||||
Reason: "There are requested changes",
|
||||
}
|
||||
}
|
||||
if models.MergeBlockedByOfficialReviewRequests(ctx, pr.ProtectedBranch, pr) {
|
||||
if issues_model.MergeBlockedByOfficialReviewRequests(ctx, pr.ProtectedBranch, pr) {
|
||||
return models.ErrDisallowedToMerge{
|
||||
Reason: "There are official review requests",
|
||||
}
|
||||
}
|
||||
|
||||
if models.MergeBlockedByOutdatedBranch(pr.ProtectedBranch, pr) {
|
||||
if issues_model.MergeBlockedByOutdatedBranch(pr.ProtectedBranch, pr) {
|
||||
return models.ErrDisallowedToMerge{
|
||||
Reason: "The head branch is behind the base branch",
|
||||
}
|
||||
|
@ -823,7 +824,7 @@ func CheckPullBranchProtections(ctx context.Context, pr *models.PullRequest, ski
|
|||
}
|
||||
|
||||
// MergedManually mark pr as merged manually
|
||||
func MergedManually(pr *models.PullRequest, doer *user_model.User, baseGitRepo *git.Repository, commitID string) error {
|
||||
func MergedManually(pr *issues_model.PullRequest, doer *user_model.User, baseGitRepo *git.Repository, commitID string) error {
|
||||
pullWorkingPool.CheckIn(fmt.Sprint(pr.ID))
|
||||
defer pullWorkingPool.CheckOut(fmt.Sprint(pr.ID))
|
||||
|
||||
|
@ -862,7 +863,7 @@ func MergedManually(pr *models.PullRequest, doer *user_model.User, baseGitRepo *
|
|||
|
||||
pr.MergedCommitID = commitID
|
||||
pr.MergedUnix = timeutil.TimeStamp(commit.Author.When.Unix())
|
||||
pr.Status = models.PullRequestStatusManuallyMerged
|
||||
pr.Status = issues_model.PullRequestStatusManuallyMerged
|
||||
pr.Merger = doer
|
||||
pr.MergerID = doer.ID
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
|
@ -27,7 +28,7 @@ import (
|
|||
)
|
||||
|
||||
// DownloadDiffOrPatch will write the patch for the pr to the writer
|
||||
func DownloadDiffOrPatch(ctx context.Context, pr *models.PullRequest, w io.Writer, patch, binary bool) error {
|
||||
func DownloadDiffOrPatch(ctx context.Context, pr *issues_model.PullRequest, w io.Writer, patch, binary bool) error {
|
||||
if err := pr.LoadBaseRepoCtx(ctx); err != nil {
|
||||
log.Error("Unable to load base repository ID %d for pr #%d [%d]", pr.BaseRepoID, pr.Index, pr.ID)
|
||||
return err
|
||||
|
@ -54,7 +55,7 @@ var patchErrorSuffices = []string{
|
|||
}
|
||||
|
||||
// TestPatch will test whether a simple patch will apply
|
||||
func TestPatch(pr *models.PullRequest) error {
|
||||
func TestPatch(pr *issues_model.PullRequest) error {
|
||||
ctx, _, finished := process.GetManager().AddContext(graceful.GetManager().HammerContext(), fmt.Sprintf("TestPatch: Repo[%d]#%d", pr.BaseRepoID, pr.Index))
|
||||
defer finished()
|
||||
|
||||
|
@ -88,7 +89,7 @@ func TestPatch(pr *models.PullRequest) error {
|
|||
pr.MergeBase = strings.TrimSpace(pr.MergeBase)
|
||||
|
||||
// 2. Check for conflicts
|
||||
if conflicts, err := checkConflicts(ctx, pr, gitRepo, tmpBasePath); err != nil || conflicts || pr.Status == models.PullRequestStatusEmpty {
|
||||
if conflicts, err := checkConflicts(ctx, pr, gitRepo, tmpBasePath); err != nil || conflicts || pr.Status == issues_model.PullRequestStatusEmpty {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -101,7 +102,7 @@ func TestPatch(pr *models.PullRequest) error {
|
|||
log.Trace("Found %d protected files changed", len(pr.ChangedProtectedFiles))
|
||||
}
|
||||
|
||||
pr.Status = models.PullRequestStatusMergeable
|
||||
pr.Status = issues_model.PullRequestStatusMergeable
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -270,7 +271,7 @@ func AttemptThreeWayMerge(ctx context.Context, gitPath string, gitRepo *git.Repo
|
|||
return conflict, conflictedFiles, nil
|
||||
}
|
||||
|
||||
func checkConflicts(ctx context.Context, pr *models.PullRequest, gitRepo *git.Repository, tmpBasePath string) (bool, error) {
|
||||
func checkConflicts(ctx context.Context, pr *issues_model.PullRequest, gitRepo *git.Repository, tmpBasePath string) (bool, error) {
|
||||
// 1. checkConflicts resets the conflict status - therefore - reset the conflict status
|
||||
pr.ConflictedFiles = nil
|
||||
|
||||
|
@ -295,7 +296,7 @@ func checkConflicts(ctx context.Context, pr *models.PullRequest, gitRepo *git.Re
|
|||
}
|
||||
if treeHash == baseTree.ID.String() {
|
||||
log.Debug("PullRequest[%d]: Patch is empty - ignoring", pr.ID)
|
||||
pr.Status = models.PullRequestStatusEmpty
|
||||
pr.Status = issues_model.PullRequestStatusEmpty
|
||||
}
|
||||
|
||||
return false, nil
|
||||
|
@ -329,7 +330,7 @@ func checkConflicts(ctx context.Context, pr *models.PullRequest, gitRepo *git.Re
|
|||
// 3b. if the size of that patch is 0 - there can be no conflicts!
|
||||
if stat.Size() == 0 {
|
||||
log.Debug("PullRequest[%d]: Patch is empty - ignoring", pr.ID)
|
||||
pr.Status = models.PullRequestStatusEmpty
|
||||
pr.Status = issues_model.PullRequestStatusEmpty
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
@ -449,7 +450,7 @@ func checkConflicts(ctx context.Context, pr *models.PullRequest, gitRepo *git.Re
|
|||
// Note: `"err" could be non-nil` is due that if enable 3-way merge, it doesn't return any error on found conflicts.
|
||||
if len(pr.ConflictedFiles) > 0 {
|
||||
if conflict {
|
||||
pr.Status = models.PullRequestStatusConflict
|
||||
pr.Status = issues_model.PullRequestStatusConflict
|
||||
log.Trace("Found %d files conflicted: %v", len(pr.ConflictedFiles), pr.ConflictedFiles)
|
||||
|
||||
return true, nil
|
||||
|
@ -516,8 +517,8 @@ func CheckUnprotectedFiles(repo *git.Repository, oldCommitID, newCommitID string
|
|||
}
|
||||
|
||||
// checkPullFilesProtection check if pr changed protected files and save results
|
||||
func checkPullFilesProtection(pr *models.PullRequest, gitRepo *git.Repository) error {
|
||||
if pr.Status == models.PullRequestStatusEmpty {
|
||||
func checkPullFilesProtection(pr *issues_model.PullRequest, gitRepo *git.Repository) error {
|
||||
if pr.Status == issues_model.PullRequestStatusEmpty {
|
||||
pr.ChangedProtectedFiles = nil
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
|
@ -35,7 +36,7 @@ import (
|
|||
var pullWorkingPool = sync.NewExclusivePool()
|
||||
|
||||
// NewPullRequest creates new pull request with labels for repository.
|
||||
func NewPullRequest(ctx context.Context, repo *repo_model.Repository, pull *models.Issue, labelIDs []int64, uuids []string, pr *models.PullRequest, assigneeIDs []int64) error {
|
||||
func NewPullRequest(ctx context.Context, repo *repo_model.Repository, pull *issues_model.Issue, labelIDs []int64, uuids []string, pr *issues_model.PullRequest, assigneeIDs []int64) error {
|
||||
if err := TestPatch(pr); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, pull *mode
|
|||
pr.CommitsAhead = divergence.Ahead
|
||||
pr.CommitsBehind = divergence.Behind
|
||||
|
||||
if err := models.NewPullRequest(ctx, repo, pull, labelIDs, uuids, pr); err != nil {
|
||||
if err := issues_model.NewPullRequest(ctx, repo, pull, labelIDs, uuids, pr); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -66,7 +67,7 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, pull *mode
|
|||
prCtx, _, finished := process.GetManager().AddContext(graceful.GetManager().HammerContext(), fmt.Sprintf("NewPullRequest: %s:%d", repo.FullName(), pr.Index))
|
||||
defer finished()
|
||||
|
||||
if pr.Flow == models.PullRequestFlowGithub {
|
||||
if pr.Flow == issues_model.PullRequestFlowGithub {
|
||||
err = PushToBaseRepo(prCtx, pr)
|
||||
} else {
|
||||
err = UpdateRef(prCtx, pr)
|
||||
|
@ -75,7 +76,7 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, pull *mode
|
|||
return err
|
||||
}
|
||||
|
||||
mentions, err := models.FindAndUpdateIssueMentions(ctx, pull, pull.Poster, pull.Content)
|
||||
mentions, err := issues_model.FindAndUpdateIssueMentions(ctx, pull, pull.Poster, pull.Content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -102,7 +103,7 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, pull *mode
|
|||
}
|
||||
|
||||
if len(compareInfo.Commits) > 0 {
|
||||
data := models.PushActionContent{IsForcePush: false}
|
||||
data := issues_model.PushActionContent{IsForcePush: false}
|
||||
data.CommitIDs = make([]string, 0, len(compareInfo.Commits))
|
||||
for i := len(compareInfo.Commits) - 1; i >= 0; i-- {
|
||||
data.CommitIDs = append(data.CommitIDs, compareInfo.Commits[i].ID.String())
|
||||
|
@ -113,8 +114,8 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, pull *mode
|
|||
return err
|
||||
}
|
||||
|
||||
ops := &models.CreateCommentOptions{
|
||||
Type: models.CommentTypePullRequestPush,
|
||||
ops := &issues_model.CreateCommentOptions{
|
||||
Type: issues_model.CommentTypePullRequestPush,
|
||||
Doer: pull.Poster,
|
||||
Repo: repo,
|
||||
Issue: pr.Issue,
|
||||
|
@ -122,14 +123,14 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, pull *mode
|
|||
Content: string(dataJSON),
|
||||
}
|
||||
|
||||
_, _ = models.CreateComment(ops)
|
||||
_, _ = issues_model.CreateComment(ops)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ChangeTargetBranch changes the target branch of this pull request, as the given user.
|
||||
func ChangeTargetBranch(ctx context.Context, pr *models.PullRequest, doer *user_model.User, targetBranch string) (err error) {
|
||||
func ChangeTargetBranch(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User, targetBranch string) (err error) {
|
||||
pullWorkingPool.CheckIn(fmt.Sprint(pr.ID))
|
||||
defer pullWorkingPool.CheckOut(fmt.Sprint(pr.ID))
|
||||
|
||||
|
@ -139,7 +140,7 @@ func ChangeTargetBranch(ctx context.Context, pr *models.PullRequest, doer *user_
|
|||
}
|
||||
|
||||
if pr.Issue.IsClosed {
|
||||
return models.ErrIssueIsClosed{
|
||||
return issues_model.ErrIssueIsClosed{
|
||||
ID: pr.Issue.ID,
|
||||
RepoID: pr.Issue.RepoID,
|
||||
Index: pr.Issue.Index,
|
||||
|
@ -170,9 +171,9 @@ func ChangeTargetBranch(ctx context.Context, pr *models.PullRequest, doer *user_
|
|||
}
|
||||
|
||||
// Check if pull request for the new target branch already exists
|
||||
existingPr, err := models.GetUnmergedPullRequest(pr.HeadRepoID, pr.BaseRepoID, pr.HeadBranch, targetBranch, models.PullRequestFlowGithub)
|
||||
existingPr, err := issues_model.GetUnmergedPullRequest(pr.HeadRepoID, pr.BaseRepoID, pr.HeadBranch, targetBranch, issues_model.PullRequestFlowGithub)
|
||||
if existingPr != nil {
|
||||
return models.ErrPullRequestAlreadyExists{
|
||||
return issues_model.ErrPullRequestAlreadyExists{
|
||||
ID: existingPr.ID,
|
||||
IssueID: existingPr.Index,
|
||||
HeadRepoID: existingPr.HeadRepoID,
|
||||
|
@ -181,7 +182,7 @@ func ChangeTargetBranch(ctx context.Context, pr *models.PullRequest, doer *user_
|
|||
BaseBranch: existingPr.BaseBranch,
|
||||
}
|
||||
}
|
||||
if err != nil && !models.IsErrPullRequestNotExist(err) {
|
||||
if err != nil && !issues_model.IsErrPullRequestNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -196,8 +197,8 @@ func ChangeTargetBranch(ctx context.Context, pr *models.PullRequest, doer *user_
|
|||
|
||||
// Update target branch, PR diff and status
|
||||
// This is the same as checkAndUpdateStatus in check service, but also updates base_branch
|
||||
if pr.Status == models.PullRequestStatusChecking {
|
||||
pr.Status = models.PullRequestStatusMergeable
|
||||
if pr.Status == issues_model.PullRequestStatusChecking {
|
||||
pr.Status = issues_model.PullRequestStatusMergeable
|
||||
}
|
||||
|
||||
// Update Commit Divergence
|
||||
|
@ -213,22 +214,22 @@ func ChangeTargetBranch(ctx context.Context, pr *models.PullRequest, doer *user_
|
|||
}
|
||||
|
||||
// Create comment
|
||||
options := &models.CreateCommentOptions{
|
||||
Type: models.CommentTypeChangeTargetBranch,
|
||||
options := &issues_model.CreateCommentOptions{
|
||||
Type: issues_model.CommentTypeChangeTargetBranch,
|
||||
Doer: doer,
|
||||
Repo: pr.Issue.Repo,
|
||||
Issue: pr.Issue,
|
||||
OldRef: oldBranch,
|
||||
NewRef: targetBranch,
|
||||
}
|
||||
if _, err = models.CreateComment(options); err != nil {
|
||||
if _, err = issues_model.CreateComment(options); err != nil {
|
||||
return fmt.Errorf("CreateChangeTargetBranchComment: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkForInvalidation(ctx context.Context, requests models.PullRequestList, repoID int64, doer *user_model.User, branch string) error {
|
||||
func checkForInvalidation(ctx context.Context, requests issues_model.PullRequestList, repoID int64, doer *user_model.User, branch string) error {
|
||||
repo, err := repo_model.GetRepositoryByID(repoID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetRepositoryByID: %v", err)
|
||||
|
@ -257,14 +258,14 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
|
|||
// If you don't let it run all the way then you will lose data
|
||||
// TODO: graceful: AddTestPullRequestTask needs to become a queue!
|
||||
|
||||
prs, err := models.GetUnmergedPullRequestsByHeadInfo(repoID, branch)
|
||||
prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(repoID, branch)
|
||||
if err != nil {
|
||||
log.Error("Find pull requests [head_repo_id: %d, head_branch: %s]: %v", repoID, branch, err)
|
||||
return
|
||||
}
|
||||
|
||||
if isSync {
|
||||
requests := models.PullRequestList(prs)
|
||||
requests := issues_model.PullRequestList(prs)
|
||||
if err = requests.LoadAttributes(); err != nil {
|
||||
log.Error("PullRequestList.LoadAttributes: %v", err)
|
||||
}
|
||||
|
@ -280,11 +281,11 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
|
|||
}
|
||||
if changed {
|
||||
// Mark old reviews as stale if diff to mergebase has changed
|
||||
if err := models.MarkReviewsAsStale(pr.IssueID); err != nil {
|
||||
if err := issues_model.MarkReviewsAsStale(pr.IssueID); err != nil {
|
||||
log.Error("MarkReviewsAsStale: %v", err)
|
||||
}
|
||||
}
|
||||
if err := models.MarkReviewsAsNotStale(pr.IssueID, newCommitID); err != nil {
|
||||
if err := issues_model.MarkReviewsAsNotStale(pr.IssueID, newCommitID); err != nil {
|
||||
log.Error("MarkReviewsAsNotStale: %v", err)
|
||||
}
|
||||
divergence, err := GetDiverging(ctx, pr)
|
||||
|
@ -306,7 +307,7 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
|
|||
|
||||
for _, pr := range prs {
|
||||
log.Trace("Updating PR[%d]: composing new test task", pr.ID)
|
||||
if pr.Flow == models.PullRequestFlowGithub {
|
||||
if pr.Flow == issues_model.PullRequestFlowGithub {
|
||||
if err := PushToBaseRepo(ctx, pr); err != nil {
|
||||
log.Error("PushToBaseRepo: %v", err)
|
||||
continue
|
||||
|
@ -316,14 +317,14 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
|
|||
}
|
||||
|
||||
AddToTaskQueue(pr)
|
||||
comment, err := models.CreatePushPullComment(ctx, doer, pr, oldCommitID, newCommitID)
|
||||
comment, err := issues_model.CreatePushPullComment(ctx, doer, pr, oldCommitID, newCommitID)
|
||||
if err == nil && comment != nil {
|
||||
notification.NotifyPullRequestPushCommits(doer, pr, comment)
|
||||
}
|
||||
}
|
||||
|
||||
log.Trace("AddTestPullRequestTask [base_repo_id: %d, base_branch: %s]: finding pull requests", repoID, branch)
|
||||
prs, err = models.GetUnmergedPullRequestsByBaseInfo(repoID, branch)
|
||||
prs, err = issues_model.GetUnmergedPullRequestsByBaseInfo(repoID, branch)
|
||||
if err != nil {
|
||||
log.Error("Find pull requests [base_repo_id: %d, base_branch: %s]: %v", repoID, branch, err)
|
||||
return
|
||||
|
@ -349,7 +350,7 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
|
|||
|
||||
// checkIfPRContentChanged checks if diff to target branch has changed by push
|
||||
// A commit can be considered to leave the PR untouched if the patch/diff with its merge base is unchanged
|
||||
func checkIfPRContentChanged(ctx context.Context, pr *models.PullRequest, oldCommitID, newCommitID string) (hasChanged bool, err error) {
|
||||
func checkIfPRContentChanged(ctx context.Context, pr *issues_model.PullRequest, oldCommitID, newCommitID string) (hasChanged bool, err error) {
|
||||
if err = pr.LoadHeadRepoCtx(ctx); err != nil {
|
||||
return false, fmt.Errorf("LoadHeadRepo: %v", err)
|
||||
} else if pr.HeadRepo == nil {
|
||||
|
@ -421,11 +422,11 @@ func checkIfPRContentChanged(ctx context.Context, pr *models.PullRequest, oldCom
|
|||
// PushToBaseRepo pushes commits from branches of head repository to
|
||||
// corresponding branches of base repository.
|
||||
// FIXME: Only push branches that are actually updates?
|
||||
func PushToBaseRepo(ctx context.Context, pr *models.PullRequest) (err error) {
|
||||
func PushToBaseRepo(ctx context.Context, pr *issues_model.PullRequest) (err error) {
|
||||
return pushToBaseRepoHelper(ctx, pr, "")
|
||||
}
|
||||
|
||||
func pushToBaseRepoHelper(ctx context.Context, pr *models.PullRequest, prefixHeadBranch string) (err error) {
|
||||
func pushToBaseRepoHelper(ctx context.Context, pr *issues_model.PullRequest, prefixHeadBranch string) (err error) {
|
||||
log.Trace("PushToBaseRepo[%d]: pushing commits to base repo '%s'", pr.BaseRepoID, pr.GetGitRefName())
|
||||
|
||||
if err := pr.LoadHeadRepoCtx(ctx); err != nil {
|
||||
|
@ -481,7 +482,7 @@ func pushToBaseRepoHelper(ctx context.Context, pr *models.PullRequest, prefixHea
|
|||
}
|
||||
|
||||
// UpdateRef update refs/pull/id/head directly for agit flow pull request
|
||||
func UpdateRef(ctx context.Context, pr *models.PullRequest) (err error) {
|
||||
func UpdateRef(ctx context.Context, pr *issues_model.PullRequest) (err error) {
|
||||
log.Trace("UpdateRef[%d]: upgate pull request ref in base repo '%s'", pr.ID, pr.GetGitRefName())
|
||||
if err := pr.LoadBaseRepoCtx(ctx); err != nil {
|
||||
log.Error("Unable to load base repository for PR[%d] Error: %v", pr.ID, err)
|
||||
|
@ -514,24 +515,24 @@ func (errs errlist) Error() string {
|
|||
|
||||
// CloseBranchPulls close all the pull requests who's head branch is the branch
|
||||
func CloseBranchPulls(doer *user_model.User, repoID int64, branch string) error {
|
||||
prs, err := models.GetUnmergedPullRequestsByHeadInfo(repoID, branch)
|
||||
prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(repoID, branch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
prs2, err := models.GetUnmergedPullRequestsByBaseInfo(repoID, branch)
|
||||
prs2, err := issues_model.GetUnmergedPullRequestsByBaseInfo(repoID, branch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
prs = append(prs, prs2...)
|
||||
if err := models.PullRequestList(prs).LoadAttributes(); err != nil {
|
||||
if err := issues_model.PullRequestList(prs).LoadAttributes(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var errs errlist
|
||||
for _, pr := range prs {
|
||||
if err = issue_service.ChangeStatus(pr.Issue, doer, true); err != nil && !models.IsErrPullWasClosed(err) && !models.IsErrDependenciesLeft(err) {
|
||||
if err = issue_service.ChangeStatus(pr.Issue, doer, true); err != nil && !issues_model.IsErrPullWasClosed(err) && !issues_model.IsErrDependenciesLeft(err) {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
@ -550,12 +551,12 @@ func CloseRepoBranchesPulls(ctx context.Context, doer *user_model.User, repo *re
|
|||
|
||||
var errs errlist
|
||||
for _, branch := range branches {
|
||||
prs, err := models.GetUnmergedPullRequestsByHeadInfo(repo.ID, branch.Name)
|
||||
prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(repo.ID, branch.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = models.PullRequestList(prs).LoadAttributes(); err != nil {
|
||||
if err = issues_model.PullRequestList(prs).LoadAttributes(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -565,7 +566,7 @@ func CloseRepoBranchesPulls(ctx context.Context, doer *user_model.User, repo *re
|
|||
if pr.BaseRepoID == repo.ID {
|
||||
continue
|
||||
}
|
||||
if err = issue_service.ChangeStatus(pr.Issue, doer, true); err != nil && !models.IsErrPullWasClosed(err) {
|
||||
if err = issue_service.ChangeStatus(pr.Issue, doer, true); err != nil && !issues_model.IsErrPullWasClosed(err) {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
@ -580,7 +581,7 @@ func CloseRepoBranchesPulls(ctx context.Context, doer *user_model.User, repo *re
|
|||
var commitMessageTrailersPattern = regexp.MustCompile(`(?:^|\n\n)(?:[\w-]+[ \t]*:[^\n]+\n*(?:[ \t]+[^\n]+\n*)*)+$`)
|
||||
|
||||
// GetSquashMergeCommitMessages returns the commit messages between head and merge base (if there is one)
|
||||
func GetSquashMergeCommitMessages(ctx context.Context, pr *models.PullRequest) string {
|
||||
func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequest) string {
|
||||
if err := pr.LoadIssue(); err != nil {
|
||||
log.Error("Cannot load issue %d for PR id %d: Error: %v", pr.IssueID, pr.ID, err)
|
||||
return ""
|
||||
|
@ -608,7 +609,7 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *models.PullRequest) s
|
|||
defer closer.Close()
|
||||
|
||||
var headCommit *git.Commit
|
||||
if pr.Flow == models.PullRequestFlowGithub {
|
||||
if pr.Flow == issues_model.PullRequestFlowGithub {
|
||||
headCommit, err = gitRepo.GetBranchCommit(pr.HeadBranch)
|
||||
} else {
|
||||
pr.HeadCommitID, err = gitRepo.GetRefCommitID(pr.GetGitRefName())
|
||||
|
@ -736,13 +737,13 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *models.PullRequest) s
|
|||
}
|
||||
|
||||
// GetIssuesLastCommitStatus returns a map of issue ID to the most recent commit's latest status
|
||||
func GetIssuesLastCommitStatus(ctx context.Context, issues models.IssueList) (map[int64]*git_model.CommitStatus, error) {
|
||||
func GetIssuesLastCommitStatus(ctx context.Context, issues issues_model.IssueList) (map[int64]*git_model.CommitStatus, error) {
|
||||
_, lastStatus, err := GetIssuesAllCommitStatus(ctx, issues)
|
||||
return lastStatus, err
|
||||
}
|
||||
|
||||
// GetIssuesAllCommitStatus returns a map of issue ID to a list of all statuses for the most recent commit as well as a map of issue ID to only the commit's latest status
|
||||
func GetIssuesAllCommitStatus(ctx context.Context, issues models.IssueList) (map[int64][]*git_model.CommitStatus, map[int64]*git_model.CommitStatus, error) {
|
||||
func GetIssuesAllCommitStatus(ctx context.Context, issues issues_model.IssueList) (map[int64][]*git_model.CommitStatus, map[int64]*git_model.CommitStatus, error) {
|
||||
if err := issues.LoadPullRequests(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -788,7 +789,7 @@ func GetIssuesAllCommitStatus(ctx context.Context, issues models.IssueList) (map
|
|||
}
|
||||
|
||||
// getAllCommitStatus get pr's commit statuses.
|
||||
func getAllCommitStatus(gitRepo *git.Repository, pr *models.PullRequest) (statuses []*git_model.CommitStatus, lastStatus *git_model.CommitStatus, err error) {
|
||||
func getAllCommitStatus(gitRepo *git.Repository, pr *issues_model.PullRequest) (statuses []*git_model.CommitStatus, lastStatus *git_model.CommitStatus, err error) {
|
||||
sha, shaErr := gitRepo.GetRefCommitID(pr.GetGitRefName())
|
||||
if shaErr != nil {
|
||||
return nil, nil, shaErr
|
||||
|
@ -800,7 +801,7 @@ func getAllCommitStatus(gitRepo *git.Repository, pr *models.PullRequest) (status
|
|||
}
|
||||
|
||||
// IsHeadEqualWithBranch returns if the commits of branchName are available in pull request head
|
||||
func IsHeadEqualWithBranch(ctx context.Context, pr *models.PullRequest, branchName string) (bool, error) {
|
||||
func IsHeadEqualWithBranch(ctx context.Context, pr *issues_model.PullRequest, branchName string) (bool, error) {
|
||||
var err error
|
||||
if err = pr.LoadBaseRepoCtx(ctx); err != nil {
|
||||
return false, err
|
||||
|
@ -833,7 +834,7 @@ func IsHeadEqualWithBranch(ctx context.Context, pr *models.PullRequest, branchNa
|
|||
}
|
||||
|
||||
var headCommit *git.Commit
|
||||
if pr.Flow == models.PullRequestFlowGithub {
|
||||
if pr.Flow == issues_model.PullRequestFlowGithub {
|
||||
headCommit, err = headGitRepo.GetBranchCommit(pr.HeadBranch)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
|
|
@ -8,7 +8,7 @@ package pull
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
|
@ -38,7 +38,7 @@ func TestPullRequest_CommitMessageTrailersPattern(t *testing.T) {
|
|||
|
||||
func TestPullRequest_GetDefaultMergeMessage_InternalTracker(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
pr := unittest.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2}).(*models.PullRequest)
|
||||
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2}).(*issues_model.PullRequest)
|
||||
|
||||
assert.NoError(t, pr.LoadBaseRepo())
|
||||
gitRepo, err := git.OpenRepository(git.DefaultContext, pr.BaseRepo.RepoPath())
|
||||
|
@ -68,7 +68,7 @@ func TestPullRequest_GetDefaultMergeMessage_ExternalTracker(t *testing.T) {
|
|||
baseRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
|
||||
baseRepo.Units = []*repo_model.RepoUnit{&externalTracker}
|
||||
|
||||
pr := unittest.AssertExistsAndLoadBean(t, &models.PullRequest{ID: 2, BaseRepo: baseRepo}).(*models.PullRequest)
|
||||
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2, BaseRepo: baseRepo}).(*issues_model.PullRequest)
|
||||
|
||||
assert.NoError(t, pr.LoadBaseRepo())
|
||||
gitRepo, err := git.OpenRepository(git.DefaultContext, pr.BaseRepo.RepoPath())
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
|
@ -23,7 +23,7 @@ import (
|
|||
)
|
||||
|
||||
// CreateCodeComment creates a comment on the code line
|
||||
func CreateCodeComment(ctx context.Context, doer *user_model.User, gitRepo *git.Repository, issue *models.Issue, line int64, content, treePath string, isReview bool, replyReviewID int64, latestCommitID string) (*models.Comment, error) {
|
||||
func CreateCodeComment(ctx context.Context, doer *user_model.User, gitRepo *git.Repository, issue *issues_model.Issue, line int64, content, treePath string, isReview bool, replyReviewID int64, latestCommitID string) (*issues_model.Comment, error) {
|
||||
var (
|
||||
existsReview bool
|
||||
err error
|
||||
|
@ -37,7 +37,7 @@ func CreateCodeComment(ctx context.Context, doer *user_model.User, gitRepo *git.
|
|||
if !isReview && replyReviewID != 0 {
|
||||
// It's not part of a review; maybe a reply to a review comment or a single comment.
|
||||
// Check if there are reviews for that line already; if there are, this is a reply
|
||||
if existsReview, err = models.ReviewExists(issue, treePath, line); err != nil {
|
||||
if existsReview, err = issues_model.ReviewExists(issue, treePath, line); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func CreateCodeComment(ctx context.Context, doer *user_model.User, gitRepo *git.
|
|||
return nil, err
|
||||
}
|
||||
|
||||
mentions, err := models.FindAndUpdateIssueMentions(ctx, issue, doer, comment.Content)
|
||||
mentions, err := issues_model.FindAndUpdateIssueMentions(ctx, issue, doer, comment.Content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -71,14 +71,14 @@ func CreateCodeComment(ctx context.Context, doer *user_model.User, gitRepo *git.
|
|||
return comment, nil
|
||||
}
|
||||
|
||||
review, err := models.GetCurrentReview(ctx, doer, issue)
|
||||
review, err := issues_model.GetCurrentReview(ctx, doer, issue)
|
||||
if err != nil {
|
||||
if !models.IsErrReviewNotExist(err) {
|
||||
if !issues_model.IsErrReviewNotExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if review, err = models.CreateReview(ctx, models.CreateReviewOptions{
|
||||
Type: models.ReviewTypePending,
|
||||
if review, err = issues_model.CreateReview(ctx, issues_model.CreateReviewOptions{
|
||||
Type: issues_model.ReviewTypePending,
|
||||
Reviewer: doer,
|
||||
Issue: issue,
|
||||
Official: false,
|
||||
|
@ -103,7 +103,7 @@ func CreateCodeComment(ctx context.Context, doer *user_model.User, gitRepo *git.
|
|||
|
||||
if !isReview && !existsReview {
|
||||
// Submit the review we've just created so the comment shows up in the issue view
|
||||
if _, _, err = SubmitReview(ctx, doer, gitRepo, issue, models.ReviewTypeComment, "", latestCommitID, nil); err != nil {
|
||||
if _, _, err = SubmitReview(ctx, doer, gitRepo, issue, issues_model.ReviewTypeComment, "", latestCommitID, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ func CreateCodeComment(ctx context.Context, doer *user_model.User, gitRepo *git.
|
|||
var notEnoughLines = regexp.MustCompile(`exit status 128 - fatal: file .* has only \d+ lines?`)
|
||||
|
||||
// createCodeComment creates a plain code comment at the specified line / path
|
||||
func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, issue *models.Issue, content, treePath string, line, reviewID int64) (*models.Comment, error) {
|
||||
func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, issue *issues_model.Issue, content, treePath string, line, reviewID int64) (*issues_model.Comment, error) {
|
||||
var commitID, patch string
|
||||
if err := issue.LoadPullRequest(); err != nil {
|
||||
return nil, fmt.Errorf("GetPullRequestByIssueID: %v", err)
|
||||
|
@ -135,11 +135,11 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo
|
|||
head := pr.GetGitRefName()
|
||||
if line > 0 {
|
||||
if reviewID != 0 {
|
||||
first, err := models.FindComments(ctx, &models.FindCommentsOptions{
|
||||
first, err := issues_model.FindComments(ctx, &issues_model.FindCommentsOptions{
|
||||
ReviewID: reviewID,
|
||||
Line: line,
|
||||
TreePath: treePath,
|
||||
Type: models.CommentTypeCode,
|
||||
Type: issues_model.CommentTypeCode,
|
||||
ListOptions: db.ListOptions{
|
||||
PageSize: 1,
|
||||
Page: 1,
|
||||
|
@ -149,13 +149,13 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo
|
|||
commitID = first[0].CommitSHA
|
||||
invalidated = first[0].Invalidated
|
||||
patch = first[0].Patch
|
||||
} else if err != nil && !models.IsErrCommentNotExist(err) {
|
||||
} else if err != nil && !issues_model.IsErrCommentNotExist(err) {
|
||||
return nil, fmt.Errorf("Find first comment for %d line %d path %s. Error: %v", reviewID, line, treePath, err)
|
||||
} else {
|
||||
review, err := models.GetReviewByID(ctx, reviewID)
|
||||
review, err := issues_model.GetReviewByID(ctx, reviewID)
|
||||
if err == nil && len(review.CommitID) > 0 {
|
||||
head = review.CommitID
|
||||
} else if err != nil && !models.IsErrReviewNotExist(err) {
|
||||
} else if err != nil && !issues_model.IsErrReviewNotExist(err) {
|
||||
return nil, fmt.Errorf("GetReviewByID %d. Error: %v", reviewID, err)
|
||||
}
|
||||
}
|
||||
|
@ -196,14 +196,14 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo
|
|||
_ = writer.Close()
|
||||
}()
|
||||
|
||||
patch, err = git.CutDiffAroundLine(reader, int64((&models.Comment{Line: line}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)
|
||||
patch, err = git.CutDiffAroundLine(reader, int64((&issues_model.Comment{Line: line}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)
|
||||
if err != nil {
|
||||
log.Error("Error whilst generating patch: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return models.CreateComment(&models.CreateCommentOptions{
|
||||
Type: models.CommentTypeCode,
|
||||
return issues_model.CreateComment(&issues_model.CreateCommentOptions{
|
||||
Type: issues_model.CommentTypeCode,
|
||||
Doer: doer,
|
||||
Repo: repo,
|
||||
Issue: issue,
|
||||
|
@ -218,14 +218,14 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo
|
|||
}
|
||||
|
||||
// SubmitReview creates a review out of the existing pending review or creates a new one if no pending review exist
|
||||
func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repository, issue *models.Issue, reviewType models.ReviewType, content, commitID string, attachmentUUIDs []string) (*models.Review, *models.Comment, error) {
|
||||
func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repository, issue *issues_model.Issue, reviewType issues_model.ReviewType, content, commitID string, attachmentUUIDs []string) (*issues_model.Review, *issues_model.Comment, error) {
|
||||
pr, err := issue.GetPullRequest()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var stale bool
|
||||
if reviewType != models.ReviewTypeApprove && reviewType != models.ReviewTypeReject {
|
||||
if reviewType != issues_model.ReviewTypeApprove && reviewType != issues_model.ReviewTypeReject {
|
||||
stale = false
|
||||
} else {
|
||||
headCommitID, err := gitRepo.GetRefCommitID(pr.GetGitRefName())
|
||||
|
@ -243,12 +243,12 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
|
|||
}
|
||||
}
|
||||
|
||||
review, comm, err := models.SubmitReview(doer, issue, reviewType, content, commitID, stale, attachmentUUIDs)
|
||||
review, comm, err := issues_model.SubmitReview(doer, issue, reviewType, content, commitID, stale, attachmentUUIDs)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
mentions, err := models.FindAndUpdateIssueMentions(ctx, issue, doer, comm.Content)
|
||||
mentions, err := issues_model.FindAndUpdateIssueMentions(ctx, issue, doer, comm.Content)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
|
|||
for _, lines := range review.CodeComments {
|
||||
for _, comments := range lines {
|
||||
for _, codeComment := range comments {
|
||||
mentions, err := models.FindAndUpdateIssueMentions(ctx, issue, doer, codeComment.Content)
|
||||
mentions, err := issues_model.FindAndUpdateIssueMentions(ctx, issue, doer, codeComment.Content)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -271,17 +271,17 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
|
|||
}
|
||||
|
||||
// DismissReview dismissing stale review by repo admin
|
||||
func DismissReview(ctx context.Context, reviewID int64, message string, doer *user_model.User, isDismiss bool) (comment *models.Comment, err error) {
|
||||
review, err := models.GetReviewByID(ctx, reviewID)
|
||||
func DismissReview(ctx context.Context, reviewID int64, message string, doer *user_model.User, isDismiss bool) (comment *issues_model.Comment, err error) {
|
||||
review, err := issues_model.GetReviewByID(ctx, reviewID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if review.Type != models.ReviewTypeApprove && review.Type != models.ReviewTypeReject {
|
||||
if review.Type != issues_model.ReviewTypeApprove && review.Type != issues_model.ReviewTypeReject {
|
||||
return nil, fmt.Errorf("not need to dismiss this review because it's type is not Approve or change request")
|
||||
}
|
||||
|
||||
if err = models.DismissReview(review, isDismiss); err != nil {
|
||||
if err = issues_model.DismissReview(review, isDismiss); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -296,14 +296,14 @@ func DismissReview(ctx context.Context, reviewID int64, message string, doer *us
|
|||
if err = review.Issue.LoadPullRequest(); err != nil {
|
||||
return
|
||||
}
|
||||
if err = review.Issue.LoadAttributes(); err != nil {
|
||||
if err = review.Issue.LoadAttributes(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
comment, err = models.CreateComment(&models.CreateCommentOptions{
|
||||
comment, err = issues_model.CreateComment(&issues_model.CreateCommentOptions{
|
||||
Doer: doer,
|
||||
Content: message,
|
||||
Type: models.CommentTypeDismissReview,
|
||||
Type: issues_model.CommentTypeDismissReview,
|
||||
ReviewID: review.ID,
|
||||
Issue: review.Issue,
|
||||
Repo: review.Issue.Repo,
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
|
@ -21,7 +22,7 @@ import (
|
|||
|
||||
// createTemporaryRepo creates a temporary repo with "base" for pr.BaseBranch and "tracking" for pr.HeadBranch
|
||||
// it also create a second base branch called "original_base"
|
||||
func createTemporaryRepo(ctx context.Context, pr *models.PullRequest) (string, error) {
|
||||
func createTemporaryRepo(ctx context.Context, pr *issues_model.PullRequest) (string, error) {
|
||||
if err := pr.LoadHeadRepoCtx(ctx); err != nil {
|
||||
log.Error("LoadHeadRepo: %v", err)
|
||||
return "", fmt.Errorf("LoadHeadRepo: %v", err)
|
||||
|
@ -164,7 +165,7 @@ func createTemporaryRepo(ctx context.Context, pr *models.PullRequest) (string, e
|
|||
trackingBranch := "tracking"
|
||||
// Fetch head branch
|
||||
var headBranch string
|
||||
if pr.Flow == models.PullRequestFlowGithub {
|
||||
if pr.Flow == issues_model.PullRequestFlowGithub {
|
||||
headBranch = git.BranchPrefix + pr.HeadBranch
|
||||
} else if len(pr.HeadCommitID) == 40 { // for not created pull request
|
||||
headBranch = pr.HeadCommitID
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
access_model "code.gitea.io/gitea/models/perm/access"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
|
@ -19,9 +20,9 @@ import (
|
|||
)
|
||||
|
||||
// Update updates pull request with base branch.
|
||||
func Update(ctx context.Context, pull *models.PullRequest, doer *user_model.User, message string, rebase bool) error {
|
||||
func Update(ctx context.Context, pull *issues_model.PullRequest, doer *user_model.User, message string, rebase bool) error {
|
||||
var (
|
||||
pr *models.PullRequest
|
||||
pr *issues_model.PullRequest
|
||||
style repo_model.MergeStyle
|
||||
)
|
||||
|
||||
|
@ -33,7 +34,7 @@ func Update(ctx context.Context, pull *models.PullRequest, doer *user_model.User
|
|||
style = repo_model.MergeStyleRebaseUpdate
|
||||
} else {
|
||||
// use merge functions but switch repo's and branch's
|
||||
pr = &models.PullRequest{
|
||||
pr = &issues_model.PullRequest{
|
||||
HeadRepoID: pull.BaseRepoID,
|
||||
BaseRepoID: pull.HeadRepoID,
|
||||
HeadBranch: pull.BaseBranch,
|
||||
|
@ -42,7 +43,7 @@ func Update(ctx context.Context, pull *models.PullRequest, doer *user_model.User
|
|||
style = repo_model.MergeStyleMerge
|
||||
}
|
||||
|
||||
if pull.Flow == models.PullRequestFlowAGit {
|
||||
if pull.Flow == issues_model.PullRequestFlowAGit {
|
||||
// TODO: Not support update agit flow pull request's head branch
|
||||
return fmt.Errorf("Not support update agit flow pull request's head branch")
|
||||
}
|
||||
|
@ -76,8 +77,8 @@ func Update(ctx context.Context, pull *models.PullRequest, doer *user_model.User
|
|||
}
|
||||
|
||||
// IsUserAllowedToUpdate check if user is allowed to update PR with given permissions and branch protections
|
||||
func IsUserAllowedToUpdate(ctx context.Context, pull *models.PullRequest, user *user_model.User) (mergeAllowed, rebaseAllowed bool, err error) {
|
||||
if pull.Flow == models.PullRequestFlowAGit {
|
||||
func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest, user *user_model.User) (mergeAllowed, rebaseAllowed bool, err error) {
|
||||
if pull.Flow == issues_model.PullRequestFlowAGit {
|
||||
return false, false, nil
|
||||
}
|
||||
|
||||
|
@ -89,7 +90,7 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *models.PullRequest, user *
|
|||
return false, false, err
|
||||
}
|
||||
|
||||
pr := &models.PullRequest{
|
||||
pr := &issues_model.PullRequest{
|
||||
HeadRepoID: pull.BaseRepoID,
|
||||
BaseRepoID: pull.HeadRepoID,
|
||||
HeadBranch: pull.BaseBranch,
|
||||
|
@ -139,7 +140,7 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *models.PullRequest, user *
|
|||
}
|
||||
|
||||
// GetDiverging determines how many commits a PR is ahead or behind the PR base branch
|
||||
func GetDiverging(ctx context.Context, pr *models.PullRequest) (*git.DivergeObject, error) {
|
||||
func GetDiverging(ctx context.Context, pr *issues_model.PullRequest) (*git.DivergeObject, error) {
|
||||
log.Trace("GetDiverging[%d]: compare commits", pr.ID)
|
||||
if err := pr.LoadBaseRepoCtx(ctx); err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue