pull

package
v1.20.0-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2023 License: MIT Imports: 44 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIsClosed              = errors.New("pull is closed")
	ErrUserNotAllowedToMerge = models.ErrDisallowedToMerge{}
	ErrHasMerged             = errors.New("has already been merged")
	ErrIsWorkInProgress      = errors.New("work in progress PRs cannot be merged")
	ErrIsChecking            = errors.New("cannot merge while conflict checking is in progress")
	ErrNotMergableState      = errors.New("not in mergeable state")
	ErrDependenciesLeft      = errors.New("is blocked by an open dependency")
)
View Source
var ErrUserHasNoPermissionForAction = errors.New("user not allowed to do this action")

Functions

func AddTestPullRequestTask added in v1.11.0

func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string, isSync bool, oldCommitID, newCommitID string)

AddTestPullRequestTask adds new test tasks by given head/base repository and head/base branch, and generate new patch for testing as needed.

func AddToTaskQueue added in v1.11.0

func AddToTaskQueue(pr *issues_model.PullRequest)

AddToTaskQueue adds itself to pull request test task queue.

func AttemptThreeWayMerge added in v1.17.0

func AttemptThreeWayMerge(ctx context.Context, gitPath string, gitRepo *git.Repository, base, ours, theirs, description string) (bool, []string, error)

AttemptThreeWayMerge will attempt to three way merge using git read-tree and then follow the git merge-one-file algorithm to attempt to resolve basic conflicts

func ChangeTargetBranch added in v1.11.0

func ChangeTargetBranch(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User, targetBranch string) (err error)

ChangeTargetBranch changes the target branch of this pull request, as the given user.

func CheckFileProtection added in v1.13.0

func CheckFileProtection(repo *git.Repository, oldCommitID, newCommitID string, patterns []glob.Glob, limit int, env []string) ([]string, error)

CheckFileProtection check file Protection

func CheckPRsForBaseBranch added in v1.19.0

func CheckPRsForBaseBranch(baseRepo *repo_model.Repository, baseBranchName string) error

CheckPRsForBaseBranch check all pulls with baseBrannch

func CheckPullBranchProtections added in v1.17.0

func CheckPullBranchProtections(ctx context.Context, pr *issues_model.PullRequest, skipProtectedFilesCheck bool) (err error)

CheckPullBranchProtections checks whether the PR is ready to be merged (reviews and status checks)

func CheckPullMergable added in v1.16.6

func CheckPullMergable(stdCtx context.Context, doer *user_model.User, perm *access_model.Permission, pr *issues_model.PullRequest, mergeCheckType MergeCheckType, adminSkipProtectionCheck bool) error

CheckPullMergable check if the pull mergable based on all conditions (branch protection, merge options, ...)

func CheckUnprotectedFiles added in v1.16.0

func CheckUnprotectedFiles(repo *git.Repository, oldCommitID, newCommitID string, patterns []glob.Glob, env []string) (bool, error)

CheckUnprotectedFiles check if the commit only touches unprotected files

func CloseBranchPulls added in v1.11.0

func CloseBranchPulls(doer *user_model.User, repoID int64, branch string) error

CloseBranchPulls close all the pull requests who's head branch is the branch

func CloseRepoBranchesPulls added in v1.11.0

func CloseRepoBranchesPulls(ctx context.Context, doer *user_model.User, repo *repo_model.Repository) error

CloseRepoBranchesPulls close all pull requests which head branches are in the given repository, but only whose base repo is not in the given repository

func CreateCodeComment added in v1.11.0

func CreateCodeComment(ctx context.Context, doer *user_model.User, gitRepo *git.Repository, issue *issues_model.Issue, line int64, content, treePath string, pendingReview bool, replyReviewID int64, latestCommitID string) (*issues_model.Comment, error)

CreateCodeComment creates a comment on the code line

func CreatePushPullComment added in v1.17.4

func CreatePushPullComment(ctx context.Context, pusher *user_model.User, pr *issues_model.PullRequest, oldCommitID, newCommitID string) (comment *issues_model.Comment, err error)

CreatePushPullComment create push code to pull base comment

func DismissReview added in v1.14.0

func DismissReview(ctx context.Context, reviewID, repoID int64, message string, doer *user_model.User, isDismiss, dismissPriors bool) (comment *issues_model.Comment, err error)

DismissReview dismissing stale review by repo admin

func DownloadDiffOrPatch added in v1.11.0

func DownloadDiffOrPatch(ctx context.Context, pr *issues_model.PullRequest, w io.Writer, patch, binary bool) error

DownloadDiffOrPatch will write the patch for the pr to the writer

func GetDefaultMergeMessage added in v1.17.0

func GetDefaultMergeMessage(ctx context.Context, baseGitRepo *git.Repository, pr *issues_model.PullRequest, mergeStyle repo_model.MergeStyle) (message, body string, err error)

GetDefaultMergeMessage returns default message used when merging pull request

func GetDiverging added in v1.12.0

func GetDiverging(ctx context.Context, pr *issues_model.PullRequest) (*git.DivergeObject, error)

GetDiverging determines how many commits a PR is ahead or behind the PR base branch

func GetIssuesAllCommitStatus added in v1.17.0

func GetIssuesAllCommitStatus(ctx context.Context, issues issues_model.IssueList) (map[int64][]*git_model.CommitStatus, map[int64]*git_model.CommitStatus, error)

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 GetIssuesLastCommitStatus added in v1.14.1

func GetIssuesLastCommitStatus(ctx context.Context, issues issues_model.IssueList) (map[int64]*git_model.CommitStatus, error)

GetIssuesLastCommitStatus returns a map of issue ID to the most recent commit's latest status

func GetPullRequestCommitStatusState added in v1.11.0

func GetPullRequestCommitStatusState(ctx context.Context, pr *issues_model.PullRequest) (structs.CommitStatusState, error)

GetPullRequestCommitStatusState returns pull request merged commit status state

func GetSquashMergeCommitMessages added in v1.14.0

func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequest) string

GetSquashMergeCommitMessages returns the commit messages between head and merge base (if there is one)

func Init added in v1.11.0

func Init() error

Init runs the task queue to test all the checking status pull requests

func InitializePullRequests added in v1.12.0

func InitializePullRequests(ctx context.Context)

InitializePullRequests checks and tests untested patches of pull requests.

func InvalidateCodeComments added in v1.18.4

func InvalidateCodeComments(ctx context.Context, prs issues_model.PullRequestList, doer *user_model.User, repo *git.Repository, branch string) error

InvalidateCodeComments will lookup the prs for code comments which got invalidated by change

func IsCommitStatusContextSuccess

func IsCommitStatusContextSuccess(commitStatuses []*git_model.CommitStatus, requiredContexts []string) bool

IsCommitStatusContextSuccess returns true if all required status check contexts succeed.

func IsHeadEqualWithBranch added in v1.12.0

func IsHeadEqualWithBranch(ctx context.Context, pr *issues_model.PullRequest, branchName string) (bool, error)

IsHeadEqualWithBranch returns if the commits of branchName are available in pull request head

func IsPullCommitStatusPass

func IsPullCommitStatusPass(ctx context.Context, pr *issues_model.PullRequest) (bool, error)

IsPullCommitStatusPass returns if all required status checks PASS

func IsUserAllowedToMerge added in v1.12.0

func IsUserAllowedToMerge(ctx context.Context, pr *issues_model.PullRequest, p access_model.Permission, user *user_model.User) (bool, error)

IsUserAllowedToMerge check if user is allowed to merge PR with given permissions and branch protections

func IsUserAllowedToUpdate added in v1.12.0

func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest, user *user_model.User) (mergeAllowed, rebaseAllowed bool, err error)

IsUserAllowedToUpdate check if user is allowed to update PR with given permissions and branch protections

func LFSPush

func LFSPush(ctx context.Context, tmpBasePath, mergeHeadSHA, mergeBaseSHA string, pr *issues_model.PullRequest) error

LFSPush pushes lfs objects referred to in new commits in the head repository from the base repository

func Merge

func Merge(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User, baseGitRepo *git.Repository, mergeStyle repo_model.MergeStyle, expectedHeadCommitID, message string, wasAutoMerged bool) error

Merge merges pull request to base repository. Caller should check PR is ready to be merged (review and status checks)

func MergeRequiredContextsCommitStatus added in v1.11.0

func MergeRequiredContextsCommitStatus(commitStatuses []*git_model.CommitStatus, requiredContexts []string) structs.CommitStatusState

MergeRequiredContextsCommitStatus returns a commit status state for given required contexts

func MergedManually added in v1.14.0

func MergedManually(pr *issues_model.PullRequest, doer *user_model.User, baseGitRepo *git.Repository, commitID string) error

MergedManually mark pr as merged manually

func NewPullRequest

func NewPullRequest(ctx context.Context, repo *repo_model.Repository, pull *issues_model.Issue, labelIDs []int64, uuids []string, pr *issues_model.PullRequest, assigneeIDs []int64) error

NewPullRequest creates new pull request with labels for repository.

func PushToBaseRepo added in v1.11.0

func PushToBaseRepo(ctx context.Context, pr *issues_model.PullRequest) (err error)

PushToBaseRepo pushes commits from branches of head repository to corresponding branches of base repository. FIXME: Only push branches that are actually updates?

func SetAllowEdits added in v1.17.0

func SetAllowEdits(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest, allow bool) error

SetAllowEdits allow edits from maintainers to PRs

func SubmitReview added in v1.11.0

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)

SubmitReview creates a review out of the existing pending review or creates a new one if no pending review exist

func TestPatch added in v1.11.0

func TestPatch(pr *issues_model.PullRequest) error

TestPatch will test whether a simple patch will apply

func Update added in v1.12.0

func Update(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User, message string, rebase bool) error

Update updates pull request with base branch.

func UpdateRef added in v1.16.0

func UpdateRef(ctx context.Context, pr *issues_model.PullRequest) (err error)

UpdateRef update refs/pull/id/head directly for agit flow pull request

Types

type MergeCheckType added in v1.18.5

type MergeCheckType int
const (
	MergeCheckTypeGeneral  MergeCheckType = iota // general merge checks for "merge", "rebase", "squash", etc
	MergeCheckTypeManually                       // Manually Merged button (mark a PR as merged manually)
	MergeCheckTypeAuto                           // Auto Merge (Scheduled Merge) After Checks Succeed
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL