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 <xiaolunwen@gmail.com> Reviewed-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-committed-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
c5a981333c
commit
8947cd3b00
11 changed files with 239 additions and 152 deletions
|
@ -6,8 +6,9 @@ feel free to create an issue.
|
||||||
|
|
||||||
<!-- toc -->
|
<!-- toc -->
|
||||||
|
|
||||||
- [Removed Functions (#467)](#Removed-Functions)
|
- [Removed Functions (#467)](#removed-functions)
|
||||||
- [Renamed Functions (#467)](#Renamed-Functions)
|
- [Renamed Functions (#467)](#renamed-functions)
|
||||||
|
- [New Optional Fields (#486)](#new-optional-fields)
|
||||||
|
|
||||||
<!-- tocstop -->
|
<!-- tocstop -->
|
||||||
|
|
||||||
|
@ -25,3 +26,15 @@ Pulls:
|
||||||
|
|
||||||
Pulls:
|
Pulls:
|
||||||
- [#467 Remove & Rename TrackedTimes list functions](https://gitea.com/gitea/go-sdk/pulls/467)
|
- [#467 Remove & Rename TrackedTimes list functions](https://gitea.com/gitea/go-sdk/pulls/467)
|
||||||
|
|
||||||
|
|
||||||
|
## New Optional Fields
|
||||||
|
|
||||||
|
The `EditUserOption` struct has gained several new Optional fields.
|
||||||
|
For example Email type changed from `string` to `*string`.
|
||||||
|
|
||||||
|
The easiest migration path is, to wrap your options with:
|
||||||
|
**OptionalString()**, **OptionalBool()** and **OptionalInt64()**
|
||||||
|
|
||||||
|
Pulls:
|
||||||
|
- [#486 Update Structs](https://gitea.com/gitea/go-sdk/pulls/486)
|
||||||
|
|
|
@ -63,21 +63,21 @@ func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, *Response, error)
|
||||||
|
|
||||||
// EditUserOption edit user options
|
// EditUserOption edit user options
|
||||||
type EditUserOption struct {
|
type EditUserOption struct {
|
||||||
SourceID int64 `json:"source_id"`
|
SourceID int64 `json:"source_id"`
|
||||||
LoginName string `json:"login_name"`
|
LoginName string `json:"login_name"`
|
||||||
FullName string `json:"full_name"`
|
Email *string `json:"email"`
|
||||||
Email string `json:"email"`
|
FullName *string `json:"full_name"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
MustChangePassword *bool `json:"must_change_password"`
|
MustChangePassword *bool `json:"must_change_password"`
|
||||||
Website string `json:"website"`
|
Website *string `json:"website"`
|
||||||
Location string `json:"location"`
|
Location *string `json:"location"`
|
||||||
Active *bool `json:"active"`
|
Active *bool `json:"active"`
|
||||||
Admin *bool `json:"admin"`
|
Admin *bool `json:"admin"`
|
||||||
AllowGitHook *bool `json:"allow_git_hook"`
|
AllowGitHook *bool `json:"allow_git_hook"`
|
||||||
AllowImportLocal *bool `json:"allow_import_local"`
|
AllowImportLocal *bool `json:"allow_import_local"`
|
||||||
MaxRepoCreation *int `json:"max_repo_creation"`
|
MaxRepoCreation *int `json:"max_repo_creation"`
|
||||||
ProhibitLogin *bool `json:"prohibit_login"`
|
ProhibitLogin *bool `json:"prohibit_login"`
|
||||||
AllowCreateOrganization *bool `json:"allow_create_organization"`
|
AllowCreateOrganization *bool `json:"allow_create_organization"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminEditUser modify user informations
|
// AdminEditUser modify user informations
|
||||||
|
|
|
@ -218,11 +218,12 @@ type EditIssueOption struct {
|
||||||
Ref *string `json:"ref"`
|
Ref *string `json:"ref"`
|
||||||
// deprecated
|
// deprecated
|
||||||
// TODO: rm on sdk 0.15.0
|
// TODO: rm on sdk 0.15.0
|
||||||
Assignee *string `json:"assignee"`
|
Assignee *string `json:"assignee"`
|
||||||
Assignees []string `json:"assignees"`
|
Assignees []string `json:"assignees"`
|
||||||
Milestone *int64 `json:"milestone"`
|
Milestone *int64 `json:"milestone"`
|
||||||
State *StateType `json:"state"`
|
State *StateType `json:"state"`
|
||||||
Deadline *time.Time `json:"due_date"`
|
Deadline *time.Time `json:"due_date"`
|
||||||
|
RemoveDeadline *bool `json:"unset_due_date"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the EditIssueOption struct
|
// Validate the EditIssueOption struct
|
||||||
|
|
|
@ -11,8 +11,13 @@ import (
|
||||||
|
|
||||||
// StopWatch represents a running stopwatch of an issue / pr
|
// StopWatch represents a running stopwatch of an issue / pr
|
||||||
type StopWatch struct {
|
type StopWatch struct {
|
||||||
Created time.Time `json:"created"`
|
Created time.Time `json:"created"`
|
||||||
IssueIndex int64 `json:"issue_index"`
|
Seconds int64 `json:"seconds"`
|
||||||
|
Duration string `json:"duration"`
|
||||||
|
IssueIndex int64 `json:"issue_index"`
|
||||||
|
IssueTitle string `json:"issue_title"`
|
||||||
|
RepoOwnerName string `json:"repo_owner_name"`
|
||||||
|
RepoName string `json:"repo_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMyStopwatches list all stopwatches
|
// GetMyStopwatches list all stopwatches
|
||||||
|
|
|
@ -33,15 +33,17 @@ const (
|
||||||
|
|
||||||
// PullReview represents a pull request review
|
// PullReview represents a pull request review
|
||||||
type PullReview struct {
|
type PullReview struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Reviewer *User `json:"user"`
|
Reviewer *User `json:"user"`
|
||||||
State ReviewStateType `json:"state"`
|
ReviewerTeam *Team `json:"team"`
|
||||||
Body string `json:"body"`
|
State ReviewStateType `json:"state"`
|
||||||
CommitID string `json:"commit_id"`
|
Body string `json:"body"`
|
||||||
|
CommitID string `json:"commit_id"`
|
||||||
// Stale indicates if the pull has changed since the review
|
// Stale indicates if the pull has changed since the review
|
||||||
Stale bool `json:"stale"`
|
Stale bool `json:"stale"`
|
||||||
// Official indicates if the review counts towards the required approval limit, if PR base is a protected branch
|
// Official indicates if the review counts towards the required approval limit, if PR base is a protected branch
|
||||||
Official bool `json:"official"`
|
Official bool `json:"official"`
|
||||||
|
Dismissed bool `json:"dismissed"`
|
||||||
CodeCommentsCount int `json:"comments_count"`
|
CodeCommentsCount int `json:"comments_count"`
|
||||||
Submitted time.Time `json:"submitted_at"`
|
Submitted time.Time `json:"submitted_at"`
|
||||||
|
|
||||||
|
|
115
gitea/repo.go
115
gitea/repo.go
|
@ -22,42 +22,77 @@ type Permission struct {
|
||||||
Pull bool `json:"pull"`
|
Pull bool `json:"pull"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InternalTracker represents settings for internal tracker
|
||||||
|
type InternalTracker struct {
|
||||||
|
// Enable time tracking (Built-in issue tracker)
|
||||||
|
EnableTimeTracker bool `json:"enable_time_tracker"`
|
||||||
|
// Let only contributors track time (Built-in issue tracker)
|
||||||
|
AllowOnlyContributorsToTrackTime bool `json:"allow_only_contributors_to_track_time"`
|
||||||
|
// Enable dependencies for issues and pull requests (Built-in issue tracker)
|
||||||
|
EnableIssueDependencies bool `json:"enable_issue_dependencies"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExternalTracker represents settings for external tracker
|
||||||
|
type ExternalTracker struct {
|
||||||
|
// URL of external issue tracker.
|
||||||
|
ExternalTrackerURL string `json:"external_tracker_url"`
|
||||||
|
// External Issue Tracker URL Format. Use the placeholders {user}, {repo} and {index} for the username, repository name and issue index.
|
||||||
|
ExternalTrackerFormat string `json:"external_tracker_format"`
|
||||||
|
// External Issue Tracker Number Format, either `numeric` or `alphanumeric`
|
||||||
|
ExternalTrackerStyle string `json:"external_tracker_style"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExternalWiki represents setting for external wiki
|
||||||
|
type ExternalWiki struct {
|
||||||
|
// URL of external wiki.
|
||||||
|
ExternalWikiURL string `json:"external_wiki_url"`
|
||||||
|
}
|
||||||
|
|
||||||
// Repository represents a repository
|
// Repository represents a repository
|
||||||
type Repository struct {
|
type Repository struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Owner *User `json:"owner"`
|
Owner *User `json:"owner"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
FullName string `json:"full_name"`
|
FullName string `json:"full_name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Empty bool `json:"empty"`
|
Empty bool `json:"empty"`
|
||||||
Private bool `json:"private"`
|
Private bool `json:"private"`
|
||||||
Fork bool `json:"fork"`
|
Fork bool `json:"fork"`
|
||||||
Parent *Repository `json:"parent"`
|
Template bool `json:"template"`
|
||||||
Mirror bool `json:"mirror"`
|
Parent *Repository `json:"parent"`
|
||||||
Size int `json:"size"`
|
Mirror bool `json:"mirror"`
|
||||||
HTMLURL string `json:"html_url"`
|
Size int `json:"size"`
|
||||||
SSHURL string `json:"ssh_url"`
|
HTMLURL string `json:"html_url"`
|
||||||
CloneURL string `json:"clone_url"`
|
SSHURL string `json:"ssh_url"`
|
||||||
OriginalURL string `json:"original_url"`
|
CloneURL string `json:"clone_url"`
|
||||||
Website string `json:"website"`
|
OriginalURL string `json:"original_url"`
|
||||||
Stars int `json:"stars_count"`
|
Website string `json:"website"`
|
||||||
Forks int `json:"forks_count"`
|
Stars int `json:"stars_count"`
|
||||||
Watchers int `json:"watchers_count"`
|
Forks int `json:"forks_count"`
|
||||||
OpenIssues int `json:"open_issues_count"`
|
Watchers int `json:"watchers_count"`
|
||||||
DefaultBranch string `json:"default_branch"`
|
OpenIssues int `json:"open_issues_count"`
|
||||||
Archived bool `json:"archived"`
|
OpenPulls int `json:"open_pr_counter"`
|
||||||
Created time.Time `json:"created_at"`
|
Releases int `json:"release_counter"`
|
||||||
Updated time.Time `json:"updated_at"`
|
DefaultBranch string `json:"default_branch"`
|
||||||
Permissions *Permission `json:"permissions,omitempty"`
|
Archived bool `json:"archived"`
|
||||||
HasIssues bool `json:"has_issues"`
|
Created time.Time `json:"created_at"`
|
||||||
HasWiki bool `json:"has_wiki"`
|
Updated time.Time `json:"updated_at"`
|
||||||
HasPullRequests bool `json:"has_pull_requests"`
|
Permissions *Permission `json:"permissions,omitempty"`
|
||||||
IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"`
|
HasIssues bool `json:"has_issues"`
|
||||||
AllowMerge bool `json:"allow_merge_commits"`
|
InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
|
||||||
AllowRebase bool `json:"allow_rebase"`
|
ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
|
||||||
AllowRebaseMerge bool `json:"allow_rebase_explicit"`
|
HasWiki bool `json:"has_wiki"`
|
||||||
AllowSquash bool `json:"allow_squash_merge"`
|
ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"`
|
||||||
AvatarURL string `json:"avatar_url"`
|
HasPullRequests bool `json:"has_pull_requests"`
|
||||||
|
HasProjects bool `json:"has_projects"`
|
||||||
|
IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"`
|
||||||
|
AllowMerge bool `json:"allow_merge_commits"`
|
||||||
|
AllowRebase bool `json:"allow_rebase"`
|
||||||
|
AllowRebaseMerge bool `json:"allow_rebase_explicit"`
|
||||||
|
AllowSquash bool `json:"allow_squash_merge"`
|
||||||
|
AvatarURL string `json:"avatar_url"`
|
||||||
|
Internal bool `json:"internal"`
|
||||||
|
MirrorInterval string `json:"mirror_interval"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RepoType represent repo type
|
// RepoType represent repo type
|
||||||
|
@ -347,14 +382,24 @@ type EditRepoOption struct {
|
||||||
// Note: you will get a 422 error if the organization restricts changing repository visibility to organization
|
// Note: you will get a 422 error if the organization restricts changing repository visibility to organization
|
||||||
// owners and a non-owner tries to change the value of private.
|
// owners and a non-owner tries to change the value of private.
|
||||||
Private *bool `json:"private,omitempty"`
|
Private *bool `json:"private,omitempty"`
|
||||||
|
// either `true` to make this repository a template or `false` to make it a normal repository
|
||||||
|
Template *bool `json:"template,omitempty"`
|
||||||
// either `true` to enable issues for this repository or `false` to disable them.
|
// either `true` to enable issues for this repository or `false` to disable them.
|
||||||
HasIssues *bool `json:"has_issues,omitempty"`
|
HasIssues *bool `json:"has_issues,omitempty"`
|
||||||
|
// set this structure to configure internal issue tracker (requires has_issues)
|
||||||
|
InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
|
||||||
|
// set this structure to use external issue tracker (requires has_issues)
|
||||||
|
ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
|
||||||
// either `true` to enable the wiki for this repository or `false` to disable it.
|
// either `true` to enable the wiki for this repository or `false` to disable it.
|
||||||
HasWiki *bool `json:"has_wiki,omitempty"`
|
HasWiki *bool `json:"has_wiki,omitempty"`
|
||||||
|
// set this structure to use external wiki instead of internal (requires has_wiki)
|
||||||
|
ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"`
|
||||||
// sets the default branch for this repository.
|
// sets the default branch for this repository.
|
||||||
DefaultBranch *string `json:"default_branch,omitempty"`
|
DefaultBranch *string `json:"default_branch,omitempty"`
|
||||||
// either `true` to allow pull requests, or `false` to prevent pull request.
|
// either `true` to allow pull requests, or `false` to prevent pull request.
|
||||||
HasPullRequests *bool `json:"has_pull_requests,omitempty"`
|
HasPullRequests *bool `json:"has_pull_requests,omitempty"`
|
||||||
|
// either `true` to enable project unit, or `false` to disable them.
|
||||||
|
HasProjects *bool `json:"has_projects,omitempty"`
|
||||||
// either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. `has_pull_requests` must be `true`.
|
// either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. `has_pull_requests` must be `true`.
|
||||||
IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace_conflicts,omitempty"`
|
IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace_conflicts,omitempty"`
|
||||||
// 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`.
|
// 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 {
|
||||||
AllowSquash *bool `json:"allow_squash_merge,omitempty"`
|
AllowSquash *bool `json:"allow_squash_merge,omitempty"`
|
||||||
// set to `true` to archive this repository.
|
// set to `true` to archive this repository.
|
||||||
Archived *bool `json:"archived,omitempty"`
|
Archived *bool `json:"archived,omitempty"`
|
||||||
|
// set to a string like `8h30m0s` to set the mirror interval time
|
||||||
|
MirrorInterval *string `json:"mirror_interval,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditRepo edit the properties of a repository
|
// EditRepo edit the properties of a repository
|
||||||
|
|
|
@ -14,75 +14,78 @@ import (
|
||||||
|
|
||||||
// BranchProtection represents a branch protection for a repository
|
// BranchProtection represents a branch protection for a repository
|
||||||
type BranchProtection struct {
|
type BranchProtection struct {
|
||||||
BranchName string `json:"branch_name"`
|
BranchName string `json:"branch_name"`
|
||||||
EnablePush bool `json:"enable_push"`
|
EnablePush bool `json:"enable_push"`
|
||||||
EnablePushWhitelist bool `json:"enable_push_whitelist"`
|
EnablePushWhitelist bool `json:"enable_push_whitelist"`
|
||||||
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
||||||
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
||||||
PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
|
PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
|
||||||
EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
|
EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
|
||||||
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
||||||
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
||||||
EnableStatusCheck bool `json:"enable_status_check"`
|
EnableStatusCheck bool `json:"enable_status_check"`
|
||||||
StatusCheckContexts []string `json:"status_check_contexts"`
|
StatusCheckContexts []string `json:"status_check_contexts"`
|
||||||
RequiredApprovals int64 `json:"required_approvals"`
|
RequiredApprovals int64 `json:"required_approvals"`
|
||||||
EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
|
EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
|
||||||
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
||||||
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
||||||
BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
|
BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
|
||||||
BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
|
BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests"`
|
||||||
DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
|
BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
|
||||||
RequireSignedCommits bool `json:"require_signed_commits"`
|
DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
|
||||||
ProtectedFilePatterns string `json:"protected_file_patterns"`
|
RequireSignedCommits bool `json:"require_signed_commits"`
|
||||||
Created time.Time `json:"created_at"`
|
ProtectedFilePatterns string `json:"protected_file_patterns"`
|
||||||
Updated time.Time `json:"updated_at"`
|
Created time.Time `json:"created_at"`
|
||||||
|
Updated time.Time `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateBranchProtectionOption options for creating a branch protection
|
// CreateBranchProtectionOption options for creating a branch protection
|
||||||
type CreateBranchProtectionOption struct {
|
type CreateBranchProtectionOption struct {
|
||||||
BranchName string `json:"branch_name"`
|
BranchName string `json:"branch_name"`
|
||||||
EnablePush bool `json:"enable_push"`
|
EnablePush bool `json:"enable_push"`
|
||||||
EnablePushWhitelist bool `json:"enable_push_whitelist"`
|
EnablePushWhitelist bool `json:"enable_push_whitelist"`
|
||||||
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
||||||
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
||||||
PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
|
PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
|
||||||
EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
|
EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
|
||||||
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
||||||
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
||||||
EnableStatusCheck bool `json:"enable_status_check"`
|
EnableStatusCheck bool `json:"enable_status_check"`
|
||||||
StatusCheckContexts []string `json:"status_check_contexts"`
|
StatusCheckContexts []string `json:"status_check_contexts"`
|
||||||
RequiredApprovals int64 `json:"required_approvals"`
|
RequiredApprovals int64 `json:"required_approvals"`
|
||||||
EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
|
EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
|
||||||
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
||||||
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
||||||
BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
|
BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
|
||||||
BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
|
BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests"`
|
||||||
DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
|
BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
|
||||||
RequireSignedCommits bool `json:"require_signed_commits"`
|
DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
|
||||||
ProtectedFilePatterns string `json:"protected_file_patterns"`
|
RequireSignedCommits bool `json:"require_signed_commits"`
|
||||||
|
ProtectedFilePatterns string `json:"protected_file_patterns"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditBranchProtectionOption options for editing a branch protection
|
// EditBranchProtectionOption options for editing a branch protection
|
||||||
type EditBranchProtectionOption struct {
|
type EditBranchProtectionOption struct {
|
||||||
EnablePush *bool `json:"enable_push"`
|
EnablePush *bool `json:"enable_push"`
|
||||||
EnablePushWhitelist *bool `json:"enable_push_whitelist"`
|
EnablePushWhitelist *bool `json:"enable_push_whitelist"`
|
||||||
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
||||||
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
||||||
PushWhitelistDeployKeys *bool `json:"push_whitelist_deploy_keys"`
|
PushWhitelistDeployKeys *bool `json:"push_whitelist_deploy_keys"`
|
||||||
EnableMergeWhitelist *bool `json:"enable_merge_whitelist"`
|
EnableMergeWhitelist *bool `json:"enable_merge_whitelist"`
|
||||||
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
||||||
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
||||||
EnableStatusCheck *bool `json:"enable_status_check"`
|
EnableStatusCheck *bool `json:"enable_status_check"`
|
||||||
StatusCheckContexts []string `json:"status_check_contexts"`
|
StatusCheckContexts []string `json:"status_check_contexts"`
|
||||||
RequiredApprovals *int64 `json:"required_approvals"`
|
RequiredApprovals *int64 `json:"required_approvals"`
|
||||||
EnableApprovalsWhitelist *bool `json:"enable_approvals_whitelist"`
|
EnableApprovalsWhitelist *bool `json:"enable_approvals_whitelist"`
|
||||||
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
||||||
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
||||||
BlockOnRejectedReviews *bool `json:"block_on_rejected_reviews"`
|
BlockOnRejectedReviews *bool `json:"block_on_rejected_reviews"`
|
||||||
BlockOnOutdatedBranch *bool `json:"block_on_outdated_branch"`
|
BlockOnOfficialReviewRequests *bool `json:"block_on_official_review_requests"`
|
||||||
DismissStaleApprovals *bool `json:"dismiss_stale_approvals"`
|
BlockOnOutdatedBranch *bool `json:"block_on_outdated_branch"`
|
||||||
RequireSignedCommits *bool `json:"require_signed_commits"`
|
DismissStaleApprovals *bool `json:"dismiss_stale_approvals"`
|
||||||
ProtectedFilePatterns *string `json:"protected_file_patterns"`
|
RequireSignedCommits *bool `json:"require_signed_commits"`
|
||||||
|
ProtectedFilePatterns *string `json:"protected_file_patterns"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListBranchProtectionsOptions list branch protection options
|
// ListBranchProtectionsOptions list branch protection options
|
||||||
|
|
|
@ -42,11 +42,12 @@ type RepoCommit struct {
|
||||||
// Commit contains information generated from a Git commit.
|
// Commit contains information generated from a Git commit.
|
||||||
type Commit struct {
|
type Commit struct {
|
||||||
*CommitMeta
|
*CommitMeta
|
||||||
HTMLURL string `json:"html_url"`
|
HTMLURL string `json:"html_url"`
|
||||||
RepoCommit *RepoCommit `json:"commit"`
|
RepoCommit *RepoCommit `json:"commit"`
|
||||||
Author *User `json:"author"`
|
Author *User `json:"author"`
|
||||||
Committer *User `json:"committer"`
|
Committer *User `json:"committer"`
|
||||||
Parents []*CommitMeta `json:"parents"`
|
Parents []*CommitMeta `json:"parents"`
|
||||||
|
Files []*CommitAffectedFiles `json:"files"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE
|
// CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE
|
||||||
|
@ -55,6 +56,11 @@ type CommitDateOptions struct {
|
||||||
Committer time.Time `json:"committer"`
|
Committer time.Time `json:"committer"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CommitAffectedFiles store information about files affected by the commit
|
||||||
|
type CommitAffectedFiles struct {
|
||||||
|
Filename string `json:"filename"`
|
||||||
|
}
|
||||||
|
|
||||||
// GetSingleCommit returns a single commit
|
// GetSingleCommit returns a single commit
|
||||||
func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, *Response, error) {
|
func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, *Response, error) {
|
||||||
commit := new(Commit)
|
commit := new(Commit)
|
||||||
|
|
|
@ -23,6 +23,8 @@ type FileOptions struct {
|
||||||
Author Identity `json:"author"`
|
Author Identity `json:"author"`
|
||||||
Committer Identity `json:"committer"`
|
Committer Identity `json:"committer"`
|
||||||
Dates CommitDateOptions `json:"dates"`
|
Dates CommitDateOptions `json:"dates"`
|
||||||
|
// Add a Signed-off-by trailer by the committer at the end of the commit log message.
|
||||||
|
Signoff bool `json:"signoff"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateFileOptions options for creating files
|
// CreateFileOptions options for creating files
|
||||||
|
|
|
@ -22,10 +22,8 @@ const (
|
||||||
GitServiceGitlab GitServiceType = "gitlab"
|
GitServiceGitlab GitServiceType = "gitlab"
|
||||||
// GitServiceGitea represents a gitea service
|
// GitServiceGitea represents a gitea service
|
||||||
GitServiceGitea GitServiceType = "gitea"
|
GitServiceGitea GitServiceType = "gitea"
|
||||||
|
// GitServiceGogs represents a gogs service
|
||||||
// Not supported jet
|
GitServiceGogs GitServiceType = "gogs"
|
||||||
// // GitServiceGogs represents a gogs service
|
|
||||||
// GitServiceGogs GitServiceType = "gogs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MigrateRepoOption options for migrating a repository from an external service
|
// MigrateRepoOption options for migrating a repository from an external service
|
||||||
|
@ -33,21 +31,22 @@ type MigrateRepoOption struct {
|
||||||
RepoName string `json:"repo_name"`
|
RepoName string `json:"repo_name"`
|
||||||
RepoOwner string `json:"repo_owner"`
|
RepoOwner string `json:"repo_owner"`
|
||||||
// deprecated use RepoOwner
|
// deprecated use RepoOwner
|
||||||
RepoOwnerID int64 `json:"uid"`
|
RepoOwnerID int64 `json:"uid"`
|
||||||
CloneAddr string `json:"clone_addr"`
|
CloneAddr string `json:"clone_addr"`
|
||||||
Service GitServiceType `json:"service"`
|
Service GitServiceType `json:"service"`
|
||||||
AuthUsername string `json:"auth_username"`
|
AuthUsername string `json:"auth_username"`
|
||||||
AuthPassword string `json:"auth_password"`
|
AuthPassword string `json:"auth_password"`
|
||||||
AuthToken string `json:"auth_token"`
|
AuthToken string `json:"auth_token"`
|
||||||
Mirror bool `json:"mirror"`
|
Mirror bool `json:"mirror"`
|
||||||
Private bool `json:"private"`
|
Private bool `json:"private"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Wiki bool `json:"wiki"`
|
Wiki bool `json:"wiki"`
|
||||||
Milestones bool `json:"milestones"`
|
Milestones bool `json:"milestones"`
|
||||||
Labels bool `json:"labels"`
|
Labels bool `json:"labels"`
|
||||||
Issues bool `json:"issues"`
|
Issues bool `json:"issues"`
|
||||||
PullRequests bool `json:"pull_requests"`
|
PullRequests bool `json:"pull_requests"`
|
||||||
Releases bool `json:"releases"`
|
Releases bool `json:"releases"`
|
||||||
|
MirrorInterval string `json:"mirror_interval"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the MigrateRepoOption struct
|
// Validate the MigrateRepoOption struct
|
||||||
|
@ -67,17 +66,24 @@ func (opt *MigrateRepoOption) Validate(c *Client) error {
|
||||||
switch opt.Service {
|
switch opt.Service {
|
||||||
case GitServiceGithub:
|
case GitServiceGithub:
|
||||||
if len(opt.AuthToken) == 0 {
|
if len(opt.AuthToken) == 0 {
|
||||||
return fmt.Errorf("github require token authentication")
|
return fmt.Errorf("github requires token authentication")
|
||||||
}
|
}
|
||||||
case GitServiceGitlab, GitServiceGitea:
|
case GitServiceGitlab, GitServiceGitea:
|
||||||
if len(opt.AuthToken) == 0 {
|
if len(opt.AuthToken) == 0 {
|
||||||
return fmt.Errorf("%s require token authentication", opt.Service)
|
return fmt.Errorf("%s requires token authentication", opt.Service)
|
||||||
}
|
}
|
||||||
// Gitlab is supported since 1.12.0 but api cant handle it until 1.13.0
|
// Gitlab is supported since 1.12.0 but api cant handle it until 1.13.0
|
||||||
// https://github.com/go-gitea/gitea/pull/12672
|
// https://github.com/go-gitea/gitea/pull/12672
|
||||||
if c.checkServerVersionGreaterThanOrEqual(version1_13_0) != nil {
|
if c.checkServerVersionGreaterThanOrEqual(version1_13_0) != nil {
|
||||||
return fmt.Errorf("migrate from service %s need gitea >= 1.13.0", opt.Service)
|
return fmt.Errorf("migrate from service %s need gitea >= 1.13.0", opt.Service)
|
||||||
}
|
}
|
||||||
|
case GitServiceGogs:
|
||||||
|
if len(opt.AuthToken) == 0 {
|
||||||
|
return fmt.Errorf("gogs requires token authentication")
|
||||||
|
}
|
||||||
|
if c.checkServerVersionGreaterThanOrEqual(version1_14_0) != nil {
|
||||||
|
return fmt.Errorf("migrate from service gogs need gitea >= 1.14.0")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,15 @@ package gitea
|
||||||
|
|
||||||
// GlobalUISettings represent the global ui settings of a gitea instance witch is exposed by API
|
// GlobalUISettings represent the global ui settings of a gitea instance witch is exposed by API
|
||||||
type GlobalUISettings struct {
|
type GlobalUISettings struct {
|
||||||
|
DefaultTheme string `json:"default_theme"`
|
||||||
AllowedReactions []string `json:"allowed_reactions"`
|
AllowedReactions []string `json:"allowed_reactions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GlobalRepoSettings represent the global repository settings of a gitea instance witch is exposed by API
|
// GlobalRepoSettings represent the global repository settings of a gitea instance witch is exposed by API
|
||||||
type GlobalRepoSettings struct {
|
type GlobalRepoSettings struct {
|
||||||
MirrorsDisabled bool `json:"mirrors_disabled"`
|
MirrorsDisabled bool `json:"mirrors_disabled"`
|
||||||
HTTPGitDisabled bool `json:"http_git_disabled"`
|
HTTPGitDisabled bool `json:"http_git_disabled"`
|
||||||
|
MigrationsDisabled bool `json:"migrations_disabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GlobalAPISettings contains global api settings exposed by it
|
// GlobalAPISettings contains global api settings exposed by it
|
||||||
|
|
Loading…
Reference in a new issue