1// Copyright 2016 The Gogs Authors. All rights reserved.
2// SPDX-License-Identifier: MIT
3
4package structs
5
6import (
7 "time"
8)
9
10// PullRequest represents a pull request
11type PullRequest struct {
12 ID int64 `json:"id"`
13 URL string `json:"url"`
14 Index int64 `json:"number"`
15 Poster *User `json:"user"`
16 Title string `json:"title"`
17 Body string `json:"body"`
18 Labels []*Label `json:"labels"`
19 Milestone *Milestone `json:"milestone"`
20 Assignee *User `json:"assignee"`
21 Assignees []*User `json:"assignees"`
22 RequestedReviewers []*User `json:"requested_reviewers"`
23 RequestedReviewersTeams []*Team `json:"requested_reviewers_teams"`
24 State StateType `json:"state"`
25 Draft bool `json:"draft"`
26 IsLocked bool `json:"is_locked"`
27 Comments int `json:"comments"`
28 // number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)
29 ReviewComments int `json:"review_comments"`
30 Additions int `json:"additions"`
31 Deletions int `json:"deletions"`
32 ChangedFiles int `json:"changed_files"`
33
34 HTMLURL string `json:"html_url"`
35 DiffURL string `json:"diff_url"`
36 PatchURL string `json:"patch_url"`
37
38 Mergeable bool `json:"mergeable"`
39 HasMerged bool `json:"merged"`
40 // swagger:strfmt date-time
41 Merged *time.Time `json:"merged_at"`
42 MergedCommitID *string `json:"merge_commit_sha"`
43 MergedBy *User `json:"merged_by"`
44 AllowMaintainerEdit bool `json:"allow_maintainer_edit"`
45
46 Base *PRBranchInfo `json:"base"`
47 Head *PRBranchInfo `json:"head"`
48 MergeBase string `json:"merge_base"`
49
50 // swagger:strfmt date-time
51 Deadline *time.Time `json:"due_date"`
52
53 // swagger:strfmt date-time
54 Created *time.Time `json:"created_at"`
55 // swagger:strfmt date-time
56 Updated *time.Time `json:"updated_at"`
57 // swagger:strfmt date-time
58 Closed *time.Time `json:"closed_at"`
59
60 PinOrder int `json:"pin_order"`
61 Flow int64 `json:"flow"`
62}
63
64// PRBranchInfo information about a branch
65type PRBranchInfo struct {
66 Name string `json:"label"`
67 Ref string `json:"ref"`
68 Sha string `json:"sha"`
69 RepoID int64 `json:"repo_id"`
70 Repository *Repository `json:"repo"`
71}
72
73// ListPullRequestsOptions options for listing pull requests
74type ListPullRequestsOptions struct {
75 Page int `json:"page"`
76 State string `json:"state"`
77}
78
79// CreatePullRequestOption options when creating a pull request
80type CreatePullRequestOption struct {
81 Head string `json:"head" binding:"Required"`
82 Base string `json:"base" binding:"Required"`
83 Title string `json:"title" binding:"Required"`
84 Body string `json:"body"`
85 Assignee string `json:"assignee"`
86 Assignees []string `json:"assignees"`
87 Milestone int64 `json:"milestone"`
88 Labels []int64 `json:"labels"`
89 // swagger:strfmt date-time
90 Deadline *time.Time `json:"due_date"`
91}
92
93// EditPullRequestOption options when modify pull request
94type EditPullRequestOption struct {
95 Title string `json:"title"`
96 Body *string `json:"body"`
97 Base string `json:"base"`
98 Assignee string `json:"assignee"`
99 Assignees []string `json:"assignees"`
100 Milestone int64 `json:"milestone"`
101 Labels []int64 `json:"labels"`
102 State *string `json:"state"`
103 // swagger:strfmt date-time
104 Deadline *time.Time `json:"due_date"`
105 RemoveDeadline *bool `json:"unset_due_date"`
106 AllowMaintainerEdit *bool `json:"allow_maintainer_edit"`
107}
108
109// ChangedFile store information about files affected by the pull request
110type ChangedFile struct {
111 Filename string `json:"filename"`
112 PreviousFilename string `json:"previous_filename,omitempty"`
113 Status string `json:"status"`
114 Additions int `json:"additions"`
115 Deletions int `json:"deletions"`
116 Changes int `json:"changes"`
117 HTMLURL string `json:"html_url,omitempty"`
118 ContentsURL string `json:"contents_url,omitempty"`
119 RawURL string `json:"raw_url,omitempty"`
120}