pull

package
v1.22.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteScheduledAutoMerge

func DeleteScheduledAutoMerge(ctx context.Context, pullID int64) error

DeleteScheduledAutoMerge delete a scheduled pull request

func IsErrAlreadyScheduledToAutoMerge

func IsErrAlreadyScheduledToAutoMerge(err error) bool

IsErrAlreadyScheduledToAutoMerge checks if an error is a ErrAlreadyScheduledToAutoMerge.

func ScheduleAutoMerge

func ScheduleAutoMerge(ctx context.Context, doer *user_model.User, pullID int64, style repo_model.MergeStyle, message string) error

ScheduleAutoMerge schedules a pull request to be merged when all checks succeed

func UpdateReviewState

func UpdateReviewState(ctx context.Context, userID, pullID int64, commitSHA string, updatedFiles map[string]ViewedState) error

UpdateReviewState updates the given review inside the database, regardless of whether it existed before or not The given map of files with their viewed state will be merged with the previous review, if present

Types

type AutoMerge

type AutoMerge struct {
	ID          int64                 `xorm:"pk autoincr"`
	PullID      int64                 `xorm:"UNIQUE"`
	DoerID      int64                 `xorm:"INDEX NOT NULL"`
	Doer        *user_model.User      `xorm:"-"`
	MergeStyle  repo_model.MergeStyle `xorm:"varchar(30)"`
	Message     string                `xorm:"LONGTEXT"`
	CreatedUnix timeutil.TimeStamp    `xorm:"created"`
}

AutoMerge represents a pull request scheduled for merging when checks succeed

func GetScheduledMergeByPullID

func GetScheduledMergeByPullID(ctx context.Context, pullID int64) (bool, *AutoMerge, error)

GetScheduledMergeByPullID gets a scheduled pull request merge by pull request id

func (AutoMerge) TableName

func (AutoMerge) TableName() string

TableName return database table name for xorm

type ErrAlreadyScheduledToAutoMerge

type ErrAlreadyScheduledToAutoMerge struct {
	PullID int64
}

ErrAlreadyScheduledToAutoMerge represents a "PullRequestHasMerged"-error

func (ErrAlreadyScheduledToAutoMerge) Error

type ReviewState

type ReviewState struct {
	ID           int64                  `xorm:"pk autoincr"`
	UserID       int64                  `xorm:"NOT NULL UNIQUE(pull_commit_user)"`
	PullID       int64                  `xorm:"NOT NULL INDEX UNIQUE(pull_commit_user) DEFAULT 0"` // Which PR was the review on?
	CommitSHA    string                 `xorm:"NOT NULL VARCHAR(64) UNIQUE(pull_commit_user)"`     // Which commit was the head commit for the review?
	UpdatedFiles map[string]ViewedState `xorm:"NOT NULL LONGTEXT JSON"`                            // Stores for each of the changed files of a PR whether they have been viewed, changed since last viewed, or not viewed
	UpdatedUnix  timeutil.TimeStamp     `xorm:"updated"`                                           // Is an accurate indicator of the order of commits as we do not expect it to be possible to make reviews on previous commits
}

ReviewState stores for a user-PR-commit combination which files the user has already viewed

func GetNewestReviewState

func GetNewestReviewState(ctx context.Context, userID, pullID int64) (*ReviewState, error)

GetNewestReviewState gets the newest review of the current user in the current PR. The returned PR Review will be nil if the user has not yet reviewed this PR.

func GetReviewState

func GetReviewState(ctx context.Context, userID, pullID int64, commitSHA string) (*ReviewState, bool, error)

GetReviewState returns the ReviewState with all given values prefilled, whether or not it exists in the database. If the review didn't exist before in the database, it won't afterwards either. The returned boolean shows whether the review exists in the database

type ViewedState

type ViewedState uint8

ViewedState stores for a file in which state it is currently viewed

const (
	Unviewed   ViewedState = iota
	HasChanged             // cannot be set from the UI/ API, only internally
	Viewed
)

func (ViewedState) String

func (viewedState ViewedState) String() string

Jump to

Keyboard shortcuts

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