mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-29 13:31:20 +00:00 
			
		
		
		
	- When migrating a pull requests from a Gitea or Forgejo instance, check if the pull request was created via the AGit flow and transfer that bit of information to the migrated pull request. - Expose this bit of information as the `flow` field for the pull request. - We have to do a horrible Go hack with Gitea's [go-sdk](gitea.com/gitea/go-sdk) to list all pull requests while being able to decode it to a struct that contains the new `Flow` field. The library does not allow you to do this out of the box, so we have to use `go:linkname` to access the private method that allows us to do this. This in turn means we have to do some boilerplate code that the library otherwise would do for us. The better option would be forking, but that would be a hassle of keeping the library in sync. - Resolves forgejo/forgejo#5848 - Unit test added. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7421 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
		
			
				
	
	
		
			120 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			120 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2016 The Gogs Authors. All rights reserved.
 | |
| // SPDX-License-Identifier: MIT
 | |
| 
 | |
| package structs
 | |
| 
 | |
| import (
 | |
| 	"time"
 | |
| )
 | |
| 
 | |
| // PullRequest represents a pull request
 | |
| type PullRequest struct {
 | |
| 	ID                      int64      `json:"id"`
 | |
| 	URL                     string     `json:"url"`
 | |
| 	Index                   int64      `json:"number"`
 | |
| 	Poster                  *User      `json:"user"`
 | |
| 	Title                   string     `json:"title"`
 | |
| 	Body                    string     `json:"body"`
 | |
| 	Labels                  []*Label   `json:"labels"`
 | |
| 	Milestone               *Milestone `json:"milestone"`
 | |
| 	Assignee                *User      `json:"assignee"`
 | |
| 	Assignees               []*User    `json:"assignees"`
 | |
| 	RequestedReviewers      []*User    `json:"requested_reviewers"`
 | |
| 	RequestedReviewersTeams []*Team    `json:"requested_reviewers_teams"`
 | |
| 	State                   StateType  `json:"state"`
 | |
| 	Draft                   bool       `json:"draft"`
 | |
| 	IsLocked                bool       `json:"is_locked"`
 | |
| 	Comments                int        `json:"comments"`
 | |
| 	// number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)
 | |
| 	ReviewComments int `json:"review_comments"`
 | |
| 	Additions      int `json:"additions"`
 | |
| 	Deletions      int `json:"deletions"`
 | |
| 	ChangedFiles   int `json:"changed_files"`
 | |
| 
 | |
| 	HTMLURL  string `json:"html_url"`
 | |
| 	DiffURL  string `json:"diff_url"`
 | |
| 	PatchURL string `json:"patch_url"`
 | |
| 
 | |
| 	Mergeable bool `json:"mergeable"`
 | |
| 	HasMerged bool `json:"merged"`
 | |
| 	// swagger:strfmt date-time
 | |
| 	Merged              *time.Time `json:"merged_at"`
 | |
| 	MergedCommitID      *string    `json:"merge_commit_sha"`
 | |
| 	MergedBy            *User      `json:"merged_by"`
 | |
| 	AllowMaintainerEdit bool       `json:"allow_maintainer_edit"`
 | |
| 
 | |
| 	Base      *PRBranchInfo `json:"base"`
 | |
| 	Head      *PRBranchInfo `json:"head"`
 | |
| 	MergeBase string        `json:"merge_base"`
 | |
| 
 | |
| 	// swagger:strfmt date-time
 | |
| 	Deadline *time.Time `json:"due_date"`
 | |
| 
 | |
| 	// swagger:strfmt date-time
 | |
| 	Created *time.Time `json:"created_at"`
 | |
| 	// swagger:strfmt date-time
 | |
| 	Updated *time.Time `json:"updated_at"`
 | |
| 	// swagger:strfmt date-time
 | |
| 	Closed *time.Time `json:"closed_at"`
 | |
| 
 | |
| 	PinOrder int   `json:"pin_order"`
 | |
| 	Flow     int64 `json:"flow"`
 | |
| }
 | |
| 
 | |
| // PRBranchInfo information about a branch
 | |
| type PRBranchInfo struct {
 | |
| 	Name       string      `json:"label"`
 | |
| 	Ref        string      `json:"ref"`
 | |
| 	Sha        string      `json:"sha"`
 | |
| 	RepoID     int64       `json:"repo_id"`
 | |
| 	Repository *Repository `json:"repo"`
 | |
| }
 | |
| 
 | |
| // ListPullRequestsOptions options for listing pull requests
 | |
| type ListPullRequestsOptions struct {
 | |
| 	Page  int    `json:"page"`
 | |
| 	State string `json:"state"`
 | |
| }
 | |
| 
 | |
| // CreatePullRequestOption options when creating a pull request
 | |
| type CreatePullRequestOption struct {
 | |
| 	Head      string   `json:"head" binding:"Required"`
 | |
| 	Base      string   `json:"base" binding:"Required"`
 | |
| 	Title     string   `json:"title" binding:"Required"`
 | |
| 	Body      string   `json:"body"`
 | |
| 	Assignee  string   `json:"assignee"`
 | |
| 	Assignees []string `json:"assignees"`
 | |
| 	Milestone int64    `json:"milestone"`
 | |
| 	Labels    []int64  `json:"labels"`
 | |
| 	// swagger:strfmt date-time
 | |
| 	Deadline *time.Time `json:"due_date"`
 | |
| }
 | |
| 
 | |
| // EditPullRequestOption options when modify pull request
 | |
| type EditPullRequestOption struct {
 | |
| 	Title     string   `json:"title"`
 | |
| 	Body      *string  `json:"body"`
 | |
| 	Base      string   `json:"base"`
 | |
| 	Assignee  string   `json:"assignee"`
 | |
| 	Assignees []string `json:"assignees"`
 | |
| 	Milestone int64    `json:"milestone"`
 | |
| 	Labels    []int64  `json:"labels"`
 | |
| 	State     *string  `json:"state"`
 | |
| 	// swagger:strfmt date-time
 | |
| 	Deadline            *time.Time `json:"due_date"`
 | |
| 	RemoveDeadline      *bool      `json:"unset_due_date"`
 | |
| 	AllowMaintainerEdit *bool      `json:"allow_maintainer_edit"`
 | |
| }
 | |
| 
 | |
| // ChangedFile store information about files affected by the pull request
 | |
| type ChangedFile struct {
 | |
| 	Filename         string `json:"filename"`
 | |
| 	PreviousFilename string `json:"previous_filename,omitempty"`
 | |
| 	Status           string `json:"status"`
 | |
| 	Additions        int    `json:"additions"`
 | |
| 	Deletions        int    `json:"deletions"`
 | |
| 	Changes          int    `json:"changes"`
 | |
| 	HTMLURL          string `json:"html_url,omitempty"`
 | |
| 	ContentsURL      string `json:"contents_url,omitempty"`
 | |
| 	RawURL           string `json:"raw_url,omitempty"`
 | |
| }
 |