Skip to content

Commit 8947cd3

Browse files
committed
Update Structs (#486)
* FileOptions: add Signoff * Commit: add CommitAffectedFiles * BranchProtection, CreateBranchProtectionOption, EditBranchProtectionOption: add BlockOnOfficialReviewRequests * MigrateRepoOption: add MirrorInterval & enable gogs as source option * EditRepoOption: Add new fields * Repository: Add new fields & related structs * PullReview: Add fields * StopWatch: Add new fields * EditIssueOption: Add option to delete Deadline * EditUserOption: lot of options got optional close #479 Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/486 Reviewed-by: Lunny Xiao <[email protected]> Reviewed-by: Andrew Thornton <[email protected]> Co-authored-by: 6543 <[email protected]> Co-committed-by: 6543 <[email protected]>
1 parent c5a9813 commit 8947cd3

11 files changed

+239
-152
lines changed

docs/migrate-v0.13-to-v0.14.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ feel free to create an issue.
66

77
<!-- toc -->
88

9-
- [Removed Functions (#467)](#Removed-Functions)
10-
- [Renamed Functions (#467)](#Renamed-Functions)
9+
- [Removed Functions (#467)](#removed-functions)
10+
- [Renamed Functions (#467)](#renamed-functions)
11+
- [New Optional Fields (#486)](#new-optional-fields)
1112

1213
<!-- tocstop -->
1314

@@ -25,3 +26,15 @@ Pulls:
2526

2627
Pulls:
2728
- [#467 Remove & Rename TrackedTimes list functions](https://gitea.com/gitea/go-sdk/pulls/467)
29+
30+
31+
## New Optional Fields
32+
33+
The `EditUserOption` struct has gained several new Optional fields.
34+
For example Email type changed from `string` to `*string`.
35+
36+
The easiest migration path is, to wrap your options with:
37+
**OptionalString()**, **OptionalBool()** and **OptionalInt64()**
38+
39+
Pulls:
40+
- [#486 Update Structs](https://gitea.com/gitea/go-sdk/pulls/486)

gitea/admin_user.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,21 @@ func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, *Response, error)
6363

6464
// EditUserOption edit user options
6565
type EditUserOption struct {
66-
SourceID int64 `json:"source_id"`
67-
LoginName string `json:"login_name"`
68-
FullName string `json:"full_name"`
69-
Email string `json:"email"`
70-
Password string `json:"password"`
71-
MustChangePassword *bool `json:"must_change_password"`
72-
Website string `json:"website"`
73-
Location string `json:"location"`
74-
Active *bool `json:"active"`
75-
Admin *bool `json:"admin"`
76-
AllowGitHook *bool `json:"allow_git_hook"`
77-
AllowImportLocal *bool `json:"allow_import_local"`
78-
MaxRepoCreation *int `json:"max_repo_creation"`
79-
ProhibitLogin *bool `json:"prohibit_login"`
80-
AllowCreateOrganization *bool `json:"allow_create_organization"`
66+
SourceID int64 `json:"source_id"`
67+
LoginName string `json:"login_name"`
68+
Email *string `json:"email"`
69+
FullName *string `json:"full_name"`
70+
Password string `json:"password"`
71+
MustChangePassword *bool `json:"must_change_password"`
72+
Website *string `json:"website"`
73+
Location *string `json:"location"`
74+
Active *bool `json:"active"`
75+
Admin *bool `json:"admin"`
76+
AllowGitHook *bool `json:"allow_git_hook"`
77+
AllowImportLocal *bool `json:"allow_import_local"`
78+
MaxRepoCreation *int `json:"max_repo_creation"`
79+
ProhibitLogin *bool `json:"prohibit_login"`
80+
AllowCreateOrganization *bool `json:"allow_create_organization"`
8181
}
8282

8383
// AdminEditUser modify user informations

gitea/issue.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,12 @@ type EditIssueOption struct {
218218
Ref *string `json:"ref"`
219219
// deprecated
220220
// TODO: rm on sdk 0.15.0
221-
Assignee *string `json:"assignee"`
222-
Assignees []string `json:"assignees"`
223-
Milestone *int64 `json:"milestone"`
224-
State *StateType `json:"state"`
225-
Deadline *time.Time `json:"due_date"`
221+
Assignee *string `json:"assignee"`
222+
Assignees []string `json:"assignees"`
223+
Milestone *int64 `json:"milestone"`
224+
State *StateType `json:"state"`
225+
Deadline *time.Time `json:"due_date"`
226+
RemoveDeadline *bool `json:"unset_due_date"`
226227
}
227228

228229
// Validate the EditIssueOption struct

gitea/issue_stopwatch.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ import (
1111

1212
// StopWatch represents a running stopwatch of an issue / pr
1313
type StopWatch struct {
14-
Created time.Time `json:"created"`
15-
IssueIndex int64 `json:"issue_index"`
14+
Created time.Time `json:"created"`
15+
Seconds int64 `json:"seconds"`
16+
Duration string `json:"duration"`
17+
IssueIndex int64 `json:"issue_index"`
18+
IssueTitle string `json:"issue_title"`
19+
RepoOwnerName string `json:"repo_owner_name"`
20+
RepoName string `json:"repo_name"`
1621
}
1722

1823
// GetMyStopwatches list all stopwatches

gitea/pull_review.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ const (
3333

3434
// PullReview represents a pull request review
3535
type PullReview struct {
36-
ID int64 `json:"id"`
37-
Reviewer *User `json:"user"`
38-
State ReviewStateType `json:"state"`
39-
Body string `json:"body"`
40-
CommitID string `json:"commit_id"`
36+
ID int64 `json:"id"`
37+
Reviewer *User `json:"user"`
38+
ReviewerTeam *Team `json:"team"`
39+
State ReviewStateType `json:"state"`
40+
Body string `json:"body"`
41+
CommitID string `json:"commit_id"`
4142
// Stale indicates if the pull has changed since the review
4243
Stale bool `json:"stale"`
4344
// Official indicates if the review counts towards the required approval limit, if PR base is a protected branch
4445
Official bool `json:"official"`
46+
Dismissed bool `json:"dismissed"`
4547
CodeCommentsCount int `json:"comments_count"`
4648
Submitted time.Time `json:"submitted_at"`
4749

gitea/repo.go

Lines changed: 81 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,77 @@ type Permission struct {
2222
Pull bool `json:"pull"`
2323
}
2424

25+
// InternalTracker represents settings for internal tracker
26+
type InternalTracker struct {
27+
// Enable time tracking (Built-in issue tracker)
28+
EnableTimeTracker bool `json:"enable_time_tracker"`
29+
// Let only contributors track time (Built-in issue tracker)
30+
AllowOnlyContributorsToTrackTime bool `json:"allow_only_contributors_to_track_time"`
31+
// Enable dependencies for issues and pull requests (Built-in issue tracker)
32+
EnableIssueDependencies bool `json:"enable_issue_dependencies"`
33+
}
34+
35+
// ExternalTracker represents settings for external tracker
36+
type ExternalTracker struct {
37+
// URL of external issue tracker.
38+
ExternalTrackerURL string `json:"external_tracker_url"`
39+
// External Issue Tracker URL Format. Use the placeholders {user}, {repo} and {index} for the username, repository name and issue index.
40+
ExternalTrackerFormat string `json:"external_tracker_format"`
41+
// External Issue Tracker Number Format, either `numeric` or `alphanumeric`
42+
ExternalTrackerStyle string `json:"external_tracker_style"`
43+
}
44+
45+
// ExternalUncyclo represents setting for external wiki
46+
type ExternalUncyclo struct {
47+
// URL of external wiki.
48+
ExternalUncycloURL string `json:"external_wiki_url"`
49+
}
50+
2551
// Repository represents a repository
2652
type Repository struct {
27-
ID int64 `json:"id"`
28-
Owner *User `json:"owner"`
29-
Name string `json:"name"`
30-
FullName string `json:"full_name"`
31-
Description string `json:"description"`
32-
Empty bool `json:"empty"`
33-
Private bool `json:"private"`
34-
Fork bool `json:"fork"`
35-
Parent *Repository `json:"parent"`
36-
Mirror bool `json:"mirror"`
37-
Size int `json:"size"`
38-
HTMLURL string `json:"html_url"`
39-
SSHURL string `json:"ssh_url"`
40-
CloneURL string `json:"clone_url"`
41-
OriginalURL string `json:"original_url"`
42-
Website string `json:"website"`
43-
Stars int `json:"stars_count"`
44-
Forks int `json:"forks_count"`
45-
Watchers int `json:"watchers_count"`
46-
OpenIssues int `json:"open_issues_count"`
47-
DefaultBranch string `json:"default_branch"`
48-
Archived bool `json:"archived"`
49-
Created time.Time `json:"created_at"`
50-
Updated time.Time `json:"updated_at"`
51-
Permissions *Permission `json:"permissions,omitempty"`
52-
HasIssues bool `json:"has_issues"`
53-
HasUncyclo bool `json:"has_wiki"`
54-
HasPullRequests bool `json:"has_pull_requests"`
55-
IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"`
56-
AllowMerge bool `json:"allow_merge_commits"`
57-
AllowRebase bool `json:"allow_rebase"`
58-
AllowRebaseMerge bool `json:"allow_rebase_explicit"`
59-
AllowSquash bool `json:"allow_squash_merge"`
60-
AvatarURL string `json:"avatar_url"`
53+
ID int64 `json:"id"`
54+
Owner *User `json:"owner"`
55+
Name string `json:"name"`
56+
FullName string `json:"full_name"`
57+
Description string `json:"description"`
58+
Empty bool `json:"empty"`
59+
Private bool `json:"private"`
60+
Fork bool `json:"fork"`
61+
Template bool `json:"template"`
62+
Parent *Repository `json:"parent"`
63+
Mirror bool `json:"mirror"`
64+
Size int `json:"size"`
65+
HTMLURL string `json:"html_url"`
66+
SSHURL string `json:"ssh_url"`
67+
CloneURL string `json:"clone_url"`
68+
OriginalURL string `json:"original_url"`
69+
Website string `json:"website"`
70+
Stars int `json:"stars_count"`
71+
Forks int `json:"forks_count"`
72+
Watchers int `json:"watchers_count"`
73+
OpenIssues int `json:"open_issues_count"`
74+
OpenPulls int `json:"open_pr_counter"`
75+
Releases int `json:"release_counter"`
76+
DefaultBranch string `json:"default_branch"`
77+
Archived bool `json:"archived"`
78+
Created time.Time `json:"created_at"`
79+
Updated time.Time `json:"updated_at"`
80+
Permissions *Permission `json:"permissions,omitempty"`
81+
HasIssues bool `json:"has_issues"`
82+
InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
83+
ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
84+
HasUncyclo bool `json:"has_wiki"`
85+
ExternalUncyclo *ExternalUncyclo `json:"external_wiki,omitempty"`
86+
HasPullRequests bool `json:"has_pull_requests"`
87+
HasProjects bool `json:"has_projects"`
88+
IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"`
89+
AllowMerge bool `json:"allow_merge_commits"`
90+
AllowRebase bool `json:"allow_rebase"`
91+
AllowRebaseMerge bool `json:"allow_rebase_explicit"`
92+
AllowSquash bool `json:"allow_squash_merge"`
93+
AvatarURL string `json:"avatar_url"`
94+
Internal bool `json:"internal"`
95+
MirrorInterval string `json:"mirror_interval"`
6196
}
6297

6398
// RepoType represent repo type
@@ -347,14 +382,24 @@ type EditRepoOption struct {
347382
// Note: you will get a 422 error if the organization restricts changing repository visibility to organization
348383
// owners and a non-owner tries to change the value of private.
349384
Private *bool `json:"private,omitempty"`
385+
// either `true` to make this repository a template or `false` to make it a normal repository
386+
Template *bool `json:"template,omitempty"`
350387
// either `true` to enable issues for this repository or `false` to disable them.
351388
HasIssues *bool `json:"has_issues,omitempty"`
389+
// set this structure to configure internal issue tracker (requires has_issues)
390+
InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
391+
// set this structure to use external issue tracker (requires has_issues)
392+
ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
352393
// either `true` to enable the wiki for this repository or `false` to disable it.
353394
HasUncyclo *bool `json:"has_wiki,omitempty"`
395+
// set this structure to use external wiki instead of internal (requires has_wiki)
396+
ExternalUncyclo *ExternalUncyclo `json:"external_wiki,omitempty"`
354397
// sets the default branch for this repository.
355398
DefaultBranch *string `json:"default_branch,omitempty"`
356399
// either `true` to allow pull requests, or `false` to prevent pull request.
357400
HasPullRequests *bool `json:"has_pull_requests,omitempty"`
401+
// either `true` to enable project unit, or `false` to disable them.
402+
HasProjects *bool `json:"has_projects,omitempty"`
358403
// either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. `has_pull_requests` must be `true`.
359404
IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace_conflicts,omitempty"`
360405
// either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. `has_pull_requests` must be `true`.
@@ -367,6 +412,8 @@ type EditRepoOption struct {
367412
AllowSquash *bool `json:"allow_squash_merge,omitempty"`
368413
// set to `true` to archive this repository.
369414
Archived *bool `json:"archived,omitempty"`
415+
// set to a string like `8h30m0s` to set the mirror interval time
416+
MirrorInterval *string `json:"mirror_interval,omitempty"`
370417
}
371418

372419
// EditRepo edit the properties of a repository

0 commit comments

Comments
 (0)