pullreq

package
v0.0.0-...-4c964c4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

WireSet provides a wire set for this package.

Functions

This section is empty.

Types

type CombinedListResponse

type CombinedListResponse struct {
	Reviewers          []*types.PullReqReviewer   `json:"reviewers"`
	UserGroupReviewers []*types.UserGroupReviewer `json:"user_group_reviewers"`
}

type CommentApplySuggestionsInput

type CommentApplySuggestionsInput struct {
	Suggestions []SuggestionReference `json:"suggestions"`

	Title   string `json:"title"`
	Message string `json:"message"`

	DryRunRules bool `json:"dry_run_rules"`
	BypassRules bool `json:"bypass_rules"`
}

type CommentApplySuggestionsOutput

type CommentApplySuggestionsOutput struct {
	CommitID string `json:"commit_id"`
	types.DryRunRulesOutput
}

type CommentCreateInput

type CommentCreateInput struct {
	// ParentID is set only for replies
	ParentID int64 `json:"parent_id"`
	// Text is comment text
	Text string `json:"text"`
	// Used only for code comments
	TargetCommitSHA string `json:"target_commit_sha"`
	SourceCommitSHA string `json:"source_commit_sha"`
	Path            string `json:"path"`
	LineStart       int    `json:"line_start"`
	LineStartNew    bool   `json:"line_start_new"`
	LineEnd         int    `json:"line_end"`
	LineEndNew      bool   `json:"line_end_new"`
}

func (*CommentCreateInput) IsCodeComment

func (in *CommentCreateInput) IsCodeComment() bool

func (*CommentCreateInput) IsReply

func (in *CommentCreateInput) IsReply() bool

func (*CommentCreateInput) Sanitize

func (in *CommentCreateInput) Sanitize() error

type CommentStatusInput

type CommentStatusInput struct {
	Status enum.PullReqCommentStatus `json:"status"`
}

func (*CommentStatusInput) Validate

func (in *CommentStatusInput) Validate() error

type CommentUpdateInput

type CommentUpdateInput struct {
	Text string `json:"text"`
}

func (*CommentUpdateInput) Sanitize

func (in *CommentUpdateInput) Sanitize() error

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(
	tx dbtx.Transactor,
	urlProvider url.Provider,
	authorizer authz.Authorizer,
	auditService audit.Service,
	pullreqStore store.PullReqStore,
	pullreqActivityStore store.PullReqActivityStore,
	codeCommentView store.CodeCommentView,
	pullreqReviewStore store.PullReqReviewStore,
	pullreqReviewerStore store.PullReqReviewerStore,
	repoStore store.RepoStore,
	principalStore store.PrincipalStore,
	userGroupStore store.UserGroupStore,
	userGroupReviewerStore store.UserGroupReviewersStore,
	principalInfoCache store.PrincipalInfoCache,
	fileViewStore store.PullReqFileViewStore,
	membershipStore store.MembershipStore,
	checkStore store.CheckStore,
	aiStore store.AIStore,
	git git.Interface,
	eventReporter *pullreqevents.Reporter,
	codeCommentMigrator *codecomments.Migrator,
	pullreqService *pullreq.Service,
	pullreqListService *pullreq.ListService,
	protectionManager *protection.Manager,
	sseStreamer sse.Streamer,
	codeowners *codeowners.Service,
	locker *locker.Locker,
	importer *migrate.PullReq,
	labelSvc *label.Service,
	instrumentation instrument.Service,
	userGroupService usergroup.SearchService,
) *Controller

func ProvideController

func ProvideController(
	tx dbtx.Transactor,
	urlProvider url.Provider,
	authorizer authz.Authorizer,
	auditService audit.Service,
	pullReqStore store.PullReqStore, pullReqActivityStore store.PullReqActivityStore,
	codeCommentsView store.CodeCommentView,
	pullReqReviewStore store.PullReqReviewStore, pullReqReviewerStore store.PullReqReviewerStore,
	repoStore store.RepoStore,
	principalStore store.PrincipalStore,
	userGroupStore store.UserGroupStore,
	userGroupReviewerStore store.UserGroupReviewersStore,
	principalInfoCache store.PrincipalInfoCache,
	fileViewStore store.PullReqFileViewStore,
	membershipStore store.MembershipStore,
	checkStore store.CheckStore,
	aiStore store.AIStore,
	rpcClient git.Interface, eventReporter *pullreqevents.Reporter, codeCommentMigrator *codecomments.Migrator,
	pullreqService *pullreq.Service, pullreqListService *pullreq.ListService,
	ruleManager *protection.Manager, sseStreamer sse.Streamer,
	codeOwners *codeowners.Service, locker *locker.Locker, importer *migrate.PullReq,
	labelSvc *label.Service,
	instrumentation instrument.Service,
	userGroupService usergroup.SearchService,
) *Controller

func (*Controller) ActivityList

func (c *Controller) ActivityList(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	filter *types.PullReqActivityFilter,
) ([]*types.PullReqActivity, error)

ActivityList returns a list of pull request activities from the provided repository and pull request number.

func (*Controller) AssignLabel

func (c *Controller) AssignLabel(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
	in *types.PullReqCreateInput,
) (*types.PullReqLabel, error)

AssignLabel assigns a label to a pull request .

func (*Controller) CodeOwners

func (c *Controller) CodeOwners(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
) (types.CodeOwnerEvaluation, error)

func (*Controller) CommentApplySuggestions

func (c *Controller) CommentApplySuggestions(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	in *CommentApplySuggestionsInput,
) (CommentApplySuggestionsOutput, []types.RuleViolations, error)

CommentApplySuggestions applies suggestions for code comments.

func (*Controller) CommentCreate

func (c *Controller) CommentCreate(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	in *CommentCreateInput,
) (*types.PullReqActivity, error)

CommentCreate creates a new pull request comment (pull request activity, type=comment/code-comment).

func (*Controller) CommentDelete

func (c *Controller) CommentDelete(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	commentID int64,
) error

CommentDelete deletes a pull request comment.

func (*Controller) CommentStatus

func (c *Controller) CommentStatus(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	commentID int64,
	in *CommentStatusInput,
) (*types.PullReqActivity, error)

CommentStatus updates a pull request comment status.

func (*Controller) CommentUpdate

func (c *Controller) CommentUpdate(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	commentID int64,
	in *CommentUpdateInput,
) (*types.PullReqActivity, error)

CommentUpdate updates a pull request comment.

func (*Controller) Commits

func (c *Controller) Commits(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
	filter *types.PaginationFilter,
) ([]types.Commit, error)

Commits lists all commits from pr head branch.

func (*Controller) Create

func (c *Controller) Create(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	in *CreateInput,
) (*types.PullReq, error)

Create creates a new pull request.

func (*Controller) DeleteBranch

func (c *Controller) DeleteBranch(ctx context.Context,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
	bypassRules,
	dryRunRules bool,
) (types.DeleteBranchOutput, []types.RuleViolations, error)

DeleteBranch deletes the source branch of a PR.

func (*Controller) Diff

func (c *Controller) Diff(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
	setSHAs func(sourceSHA, mergeBaseSHA string),
	includePatch bool,
	files ...gittypes.FileDiffRequest,
) (types.Stream[*git.FileDiff], error)

func (*Controller) FileViewAdd

func (c *Controller) FileViewAdd(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	in *FileViewAddInput,
) (*types.PullReqFileView, error)

FileViewAdd marks a file as viewed. NOTE: We take the commit SHA from the user to ensure we mark as viewed only what the user actually sees. The downside is that the caller could provide a SHA that never was part of the PR in the first place. We can't block against that with our current data, as the existence of force push makes it impossible to verify whether the commit ever was part of the PR - it would require us to store the full pr.SourceSHA history.

func (*Controller) FileViewDelete

func (c *Controller) FileViewDelete(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	filePath string,
) error

FileViewDelete removes a file from being marked as viewed.

func (*Controller) FileViewList

func (c *Controller) FileViewList(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
) ([]*types.PullReqFileView, error)

FileViewList lists all files of the PR marked as viewed for the user.

func (*Controller) Find

func (c *Controller) Find(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
	options types.PullReqMetadataOptions,
) (*types.PullReq, error)

Find returns a pull request from the provided repository.

func (*Controller) FindByBranches

func (c *Controller) FindByBranches(
	ctx context.Context,
	session *auth.Session,
	repoRef,
	sourceRepoRef,
	sourceBranch,
	targetBranch string,
	options types.PullReqMetadataOptions,
) (*types.PullReq, error)

FindByBranches returns a pull request from the provided branch pair.

func (*Controller) LastAIReview

func (c *Controller) LastAIReview(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
) (*types.AIRequest, error)

func (*Controller) List

func (c *Controller) List(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	filter *types.PullReqFilter,
) ([]*types.PullReq, int64, error)

List returns a list of pull requests from the provided repository.

func (*Controller) ListChecks

func (c *Controller) ListChecks(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
) (types.PullReqChecks, error)

ListChecks return an array of status check results for a commit in a repository.

func (*Controller) ListLabels

func (c *Controller) ListLabels(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
	filter *types.AssignableLabelFilter,
) (*types.ScopesLabels, int64, error)

ListLabels list labels assigned to a specified pullreq.

func (*Controller) Merge

func (c *Controller) Merge(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
	in *MergeInput,
) (*types.MergeResponse, *types.MergeViolations, error)

Merge merges a pull request.

It supports dry running by providing the DryRun=true. Dry running can be used to find any rule violations that might block the merging. Dry running typically should be used with BypassRules=true.

MergeMethod doesn't need to be provided for dry running. If no MergeMethod has been provided the function will return allowed merge methods. Rules can limit allowed merge methods.

If the pull request has been successfully merged the function will return the SHA of the merge commit.

func (*Controller) RawDiff

func (c *Controller) RawDiff(
	ctx context.Context,
	w io.Writer,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
	setSHAs func(sourceSHA, mergeBaseSHA string),
	files ...gittypes.FileDiffRequest,
) error

RawDiff writes raw git diff to writer w.

func (*Controller) RestoreBranch

func (c *Controller) RestoreBranch(ctx context.Context,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
	in *RestoreBranchInput,
) (types.CreateBranchOutput, []types.RuleViolations, error)

RestoreBranch restores branch for the merged/closed PR.

func (*Controller) ReviewSubmit

func (c *Controller) ReviewSubmit(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	in *ReviewSubmitInput,
) (*types.PullReqReview, error)

ReviewSubmit creates a new pull request review.

func (*Controller) ReviewerAdd

func (c *Controller) ReviewerAdd(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	in *ReviewerAddInput,
) (*types.PullReqReviewer, error)

ReviewerAdd adds a new reviewer to the pull request.

func (*Controller) ReviewerDelete

func (c *Controller) ReviewerDelete(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	reviewerID int64,
) error

ReviewerDelete deletes reviewer from the reviewer list for the given PR.

func (*Controller) ReviewerList

func (c *Controller) ReviewerList(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
) ([]*types.PullReqReviewer, error)

ReviewerList returns reviewer list for the pull request.

func (*Controller) ReviewersListCombined

func (c *Controller) ReviewersListCombined(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
) (*CombinedListResponse, error)

ReviewersListCombined returns the combined reviewer list for the pull request.

func (*Controller) State

func (c *Controller) State(ctx context.Context,
	session *auth.Session, repoRef string, pullreqNum int64, in *StateInput,
) (*types.PullReq, error)

State updates the pull request's current state.

func (*Controller) UnassignLabel

func (c *Controller) UnassignLabel(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	pullreqNum int64,
	labelID int64,
) error

UnassignLabel removes a label from a pull request.

func (*Controller) Update

func (c *Controller) Update(ctx context.Context,
	session *auth.Session, repoRef string, pullreqNum int64, in *UpdateInput,
) (*types.PullReq, error)

Update updates an pull request.

func (*Controller) UserGroupReviewerAdd

func (c *Controller) UserGroupReviewerAdd(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum int64,
	in *UserGroupReviewerAddInput,
) (*types.UserGroupReviewer, error)

UserGroupReviewerAdd adds a new usergroup to the pull request in the usergroups db.

func (*Controller) UserGroupReviewerDelete

func (c *Controller) UserGroupReviewerDelete(
	ctx context.Context,
	session *auth.Session,
	repoRef string,
	prNum,
	reviewerID int64,
) error

UserGroupReviewerDelete deletes reviewer from the UserGroupReviewers store for the given PR.

type CreateInput

type CreateInput struct {
	IsDraft bool `json:"is_draft"`

	Title       string `json:"title"`
	Description string `json:"description"`

	SourceRepoRef string `json:"source_repo_ref"`
	SourceBranch  string `json:"source_branch"`
	TargetBranch  string `json:"target_branch"`
}

func (*CreateInput) Sanitize

func (in *CreateInput) Sanitize() error

type FileViewAddInput

type FileViewAddInput struct {
	Path      string `json:"path"`
	CommitSHA string `json:"commit_sha"`
}

func (*FileViewAddInput) Validate

func (f *FileViewAddInput) Validate() error

type MergeInput

type MergeInput struct {
	Method    enum.MergeMethod `json:"method"`
	SourceSHA string           `json:"source_sha"`
	Title     string           `json:"title"`
	Message   string           `json:"message"`

	BypassRules bool `json:"bypass_rules"`
	DryRun      bool `json:"dry_run"`
	DryRunRules bool `json:"dry_run_rules"`
}

type RestoreBranchInput

type RestoreBranchInput struct {
	DryRunRules bool `json:"dry_run_rules"`
	BypassRules bool `json:"bypass_rules"`
}

RestoreBranchInput used for branch restoration apis.

type ReviewSubmitInput

type ReviewSubmitInput struct {
	CommitSHA string                     `json:"commit_sha"`
	Decision  enum.PullReqReviewDecision `json:"decision"`
}

func (*ReviewSubmitInput) Validate

func (in *ReviewSubmitInput) Validate() error

type ReviewerAddInput

type ReviewerAddInput struct {
	ReviewerID int64 `json:"reviewer_id"`
}

type StateInput

type StateInput struct {
	State   enum.PullReqState `json:"state"`
	IsDraft bool              `json:"is_draft"`
}

func (*StateInput) Check

func (in *StateInput) Check() error

type SuggestionReference

type SuggestionReference struct {
	CommentID int64  `json:"comment_id"`
	CheckSum  string `json:"check_sum"`
}

type UpdateInput

type UpdateInput struct {
	Title       string `json:"title"`
	Description string `json:"description"`
}

func (*UpdateInput) Sanitize

func (in *UpdateInput) Sanitize() error

type UserGroupReviewerAddInput

type UserGroupReviewerAddInput struct {
	UserGroupID int64 `json:"usergroup_id"`
}

Jump to

Keyboard shortcuts

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