From 158a1922741067a8a77bfb2a25d291c25375b041 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 30 Jun 2021 23:27:40 +0200 Subject: [PATCH 01/14] CreateUserOption: add Visibility --- gitea/admin_user.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gitea/admin_user.go b/gitea/admin_user.go index 161dc60..6aa797c 100644 --- a/gitea/admin_user.go +++ b/gitea/admin_user.go @@ -26,14 +26,15 @@ func (c *Client) AdminListUsers(opt AdminListUsersOptions) ([]*User, *Response, // CreateUserOption create user options type CreateUserOption struct { - SourceID int64 `json:"source_id"` - LoginName string `json:"login_name"` - Username string `json:"username"` - FullName string `json:"full_name"` - Email string `json:"email"` - Password string `json:"password"` - MustChangePassword *bool `json:"must_change_password"` - SendNotify bool `json:"send_notify"` + SourceID int64 `json:"source_id"` + LoginName string `json:"login_name"` + Username string `json:"username"` + FullName string `json:"full_name"` + Email string `json:"email"` + Password string `json:"password"` + MustChangePassword *bool `json:"must_change_password"` + SendNotify bool `json:"send_notify"` + Visibility *VisibleType `json:"visibility"` } // Validate the CreateUserOption struct -- 2.40.1 From 283cb311c4b0ab6768845aa89c1633cf829abc76 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 30 Jun 2021 23:28:13 +0200 Subject: [PATCH 02/14] EditUserOption: add Visibility, Description --- gitea/admin_user.go | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/gitea/admin_user.go b/gitea/admin_user.go index 6aa797c..172f064 100644 --- a/gitea/admin_user.go +++ b/gitea/admin_user.go @@ -64,21 +64,24 @@ func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, *Response, error) // EditUserOption edit user options type EditUserOption struct { - SourceID int64 `json:"source_id"` - LoginName string `json:"login_name"` - Email *string `json:"email"` - FullName *string `json:"full_name"` - Password string `json:"password"` - MustChangePassword *bool `json:"must_change_password"` - Website *string `json:"website"` - Location *string `json:"location"` - Active *bool `json:"active"` - Admin *bool `json:"admin"` - AllowGitHook *bool `json:"allow_git_hook"` - AllowImportLocal *bool `json:"allow_import_local"` - MaxRepoCreation *int `json:"max_repo_creation"` - ProhibitLogin *bool `json:"prohibit_login"` - AllowCreateOrganization *bool `json:"allow_create_organization"` + SourceID int64 `json:"source_id"` + LoginName string `json:"login_name"` + Email *string `json:"email"` + FullName *string `json:"full_name"` + Password string `json:"password"` + Description *string `json:"description"` + MustChangePassword *bool `json:"must_change_password"` + Website *string `json:"website"` + Location *string `json:"location"` + Active *bool `json:"active"` + Admin *bool `json:"admin"` + AllowGitHook *bool `json:"allow_git_hook"` + AllowImportLocal *bool `json:"allow_import_local"` + MaxRepoCreation *int `json:"max_repo_creation"` + ProhibitLogin *bool `json:"prohibit_login"` + AllowCreateOrganization *bool `json:"allow_create_organization"` + Restricted *bool `json:"restricted"` + Visibility *VisibleType `json:"visibility"` } // AdminEditUser modify user informations -- 2.40.1 From 2a95ffbc6b1db2ae35cf5dbd23ca1b4d50c08a24 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 30 Jun 2021 23:39:50 +0200 Subject: [PATCH 03/14] CreateHookOption: use new introduced HookType --- docs/migrate-v0.14-to-v0.15.md | 1 + gitea/hook.go | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/migrate-v0.14-to-v0.15.md b/docs/migrate-v0.14-to-v0.15.md index 118ad27..6f51bc7 100644 --- a/docs/migrate-v0.14-to-v0.15.md +++ b/docs/migrate-v0.14-to-v0.15.md @@ -12,6 +12,7 @@ Just follow this guid and if you still encounter problems, ask for help on disco ## Changed Struct Fields - the `State` field at **NotificationSubject** changed from **StateType** to **NotifySubjectState**, it also contains `"open"`, `"closed"` and add `"merged"` + - `Type` field at **CreateHookOption** now use HookType instead of pure string Pulls: - [#520 Introduce NotifySubjectState](https://gitea.com/gitea/go-sdk/pulls/520) diff --git a/gitea/hook.go b/gitea/hook.go index af4154e..67a7518 100644 --- a/gitea/hook.go +++ b/gitea/hook.go @@ -24,6 +24,28 @@ type Hook struct { Created time.Time `json:"created_at"` } +// HookType represent all webhook types gitea currently offer +type HookType string + +const ( + // HookTypeDingtalk webhook that dingtalk understand + HookTypeDingtalk HookType = "dingtalk" + // HookTypeDiscord webhook that discord understand + HookTypeDiscord HookType = "discord" + // HookTypeGitea webhook that gitea understand + HookTypeGitea HookType = "gitea" + // HookTypeGogs webhook that gogs understand + HookTypeGogs HookType = "gogs" + // HookTypeMsteams webhook that msteams understand + HookTypeMsteams HookType = "msteams" + // HookTypeSlack webhook that slack understand + HookTypeSlack HookType = "slack" + // HookTypeTelegram webhook that telegram understand + HookTypeTelegram HookType = "telegram" + // HookTypeFeishu webhook that feishu understand + HookTypeFeishu HookType = "feishu" +) + // ListHooksOptions options for listing hooks type ListHooksOptions struct { ListOptions @@ -73,7 +95,7 @@ func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, *Response, err // CreateHookOption options when create a hook type CreateHookOption struct { - Type string `json:"type"` + Type HookType `json:"type"` Config map[string]string `json:"config"` Events []string `json:"events"` BranchFilter string `json:"branch_filter"` -- 2.40.1 From dbb38b3f38a480e6a57b19a2923eddfcf3a638cf Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 30 Jun 2021 23:42:43 +0200 Subject: [PATCH 04/14] CreateOrgOption: add RepoAdminChangeTeamAccess# --- gitea/org.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gitea/org.go b/gitea/org.go index b7c439b..82e1bf5 100644 --- a/gitea/org.go +++ b/gitea/org.go @@ -73,12 +73,13 @@ func (c *Client) GetOrg(orgname string) (*Organization, *Response, error) { // CreateOrgOption options for creating an organization type CreateOrgOption struct { - Name string `json:"username"` - FullName string `json:"full_name"` - Description string `json:"description"` - Website string `json:"website"` - Location string `json:"location"` - Visibility VisibleType `json:"visibility"` + Name string `json:"username"` + FullName string `json:"full_name"` + Description string `json:"description"` + Website string `json:"website"` + Location string `json:"location"` + Visibility VisibleType `json:"visibility"` + RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access"` } // checkVisibilityOpt check if mode exist -- 2.40.1 From 7e718f902161267f79ff93131570cb1837a6b370 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 30 Jun 2021 23:56:45 +0200 Subject: [PATCH 05/14] Team,CreateTeamOption,EditTeamOption: use new introduced RepoUnitType --- gitea/org_team.go | 65 ++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/gitea/org_team.go b/gitea/org_team.go index 0373c6e..4b1b27b 100644 --- a/gitea/org_team.go +++ b/gitea/org_team.go @@ -12,17 +12,38 @@ import ( // Team represents a team in an organization type Team struct { - ID int64 `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - Organization *Organization `json:"organization"` - Permission AccessMode `json:"permission"` - CanCreateOrgRepo bool `json:"can_create_org_repo"` - IncludesAllRepositories bool `json:"includes_all_repositories"` - // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] - Units []string `json:"units"` + ID int64 `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + Organization *Organization `json:"organization"` + Permission AccessMode `json:"permission"` + CanCreateOrgRepo bool `json:"can_create_org_repo"` + IncludesAllRepositories bool `json:"includes_all_repositories"` + Units []RepoUnitType `json:"units"` } +// RepoUnitType represent all unit types of a repo gitea currently offer +type RepoUnitType string + +const ( + // RepoUnitCode represent file view of a repository + RepoUnitCode RepoUnitType = "repo.code" + // RepoUnitIssues represent issues of a repository + RepoUnitIssues RepoUnitType = "repo.issues" + // RepoUnitPulls represent pulls of a repository + RepoUnitPulls RepoUnitType = "repo.pulls" + // RepoUnitExtIssues represent external issues of a repository + RepoUnitExtIssues RepoUnitType = "repo.ext_issues" + // RepoUnitWiki represent wiki of a repository + RepoUnitWiki RepoUnitType = "repo.wiki" + // RepoUnitExtWiki represent external wiki of a repository + RepoUnitExtWiki RepoUnitType = "repo.ext_wiki" + // RepoUnitReleases represent releases of a repository + RepoUnitReleases RepoUnitType = "repo.releases" + // RepoUnitProjects represent projects of a repository + RepoUnitProjects RepoUnitType = "repo.projects" +) + // ListTeamsOptions options for listing teams type ListTeamsOptions struct { ListOptions @@ -56,13 +77,12 @@ func (c *Client) GetTeam(id int64) (*Team, *Response, error) { // CreateTeamOption options for creating a team type CreateTeamOption struct { - Name string `json:"name"` - Description string `json:"description"` - Permission AccessMode `json:"permission"` - CanCreateOrgRepo bool `json:"can_create_org_repo"` - IncludesAllRepositories bool `json:"includes_all_repositories"` - // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] - Units []string `json:"units"` + Name string `json:"name"` + Description string `json:"description"` + Permission AccessMode `json:"permission"` + CanCreateOrgRepo bool `json:"can_create_org_repo"` + IncludesAllRepositories bool `json:"includes_all_repositories"` + Units []RepoUnitType `json:"units"` } // Validate the CreateTeamOption struct @@ -103,13 +123,12 @@ func (c *Client) CreateTeam(org string, opt CreateTeamOption) (*Team, *Response, // EditTeamOption options for editing a team type EditTeamOption struct { - Name string `json:"name"` - Description *string `json:"description"` - Permission AccessMode `json:"permission"` - CanCreateOrgRepo *bool `json:"can_create_org_repo"` - IncludesAllRepositories *bool `json:"includes_all_repositories"` - // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] - Units []string `json:"units"` + Name string `json:"name"` + Description *string `json:"description"` + Permission AccessMode `json:"permission"` + CanCreateOrgRepo *bool `json:"can_create_org_repo"` + IncludesAllRepositories *bool `json:"includes_all_repositories"` + Units []RepoUnitType `json:"units"` } // Validate the EditTeamOption struct -- 2.40.1 From 6686e2992127dbe22bb2a46761d8f939fa3f839c Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 30 Jun 2021 23:59:13 +0200 Subject: [PATCH 06/14] PullReviewComment: add Resolver --- gitea/pull_review.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gitea/pull_review.go b/gitea/pull_review.go index fa7921b..a484dfd 100644 --- a/gitea/pull_review.go +++ b/gitea/pull_review.go @@ -57,6 +57,7 @@ type PullReviewComment struct { Body string `json:"body"` Reviewer *User `json:"user"` ReviewID int64 `json:"pull_request_review_id"` + Resolver *User `json:"resolver"` Created time.Time `json:"created_at"` Updated time.Time `json:"updated_at"` -- 2.40.1 From 73b4059d0e2b34006b9cbaf1d1be9f278bd4cf01 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 1 Jul 2021 00:00:38 +0200 Subject: [PATCH 07/14] Repository: add DefaultMergeStyle --- gitea/repo.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gitea/repo.go b/gitea/repo.go index 0d36571..9d3de13 100644 --- a/gitea/repo.go +++ b/gitea/repo.go @@ -93,6 +93,7 @@ type Repository struct { AvatarURL string `json:"avatar_url"` Internal bool `json:"internal"` MirrorInterval string `json:"mirror_interval"` + DefaultMergeStyle MergeStyle `json:"default_merge_style"` } // RepoType represent repo type -- 2.40.1 From 29cfecb702d652fba2adcaaa5cb7287d5e41ddeb Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 1 Jul 2021 00:04:06 +0200 Subject: [PATCH 08/14] EditRepoOption: add AllowManualMerge,AutodetectManualMerge,DefaultMergeStyle --- gitea/repo.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gitea/repo.go b/gitea/repo.go index 9d3de13..9c669ae 100644 --- a/gitea/repo.go +++ b/gitea/repo.go @@ -434,6 +434,13 @@ type EditRepoOption struct { Archived *bool `json:"archived,omitempty"` // set to a string like `8h30m0s` to set the mirror interval time MirrorInterval *string `json:"mirror_interval,omitempty"` + // either `true` to allow mark pr as merged manually, or `false` to prevent it. `has_pull_requests` must be `true`. + AllowManualMerge *bool `json:"allow_manual_merge,omitempty"` + // either `true` to enable AutodetectManualMerge, or `false` to prevent it. `has_pull_requests` must be `true`, Note: In some special cases, misjudgments can occur. + AutodetectManualMerge *bool `json:"autodetect_manual_merge,omitempty"` + // set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", or "squash". `has_pull_requests` must be `true`. + DefaultMergeStyle *MergeStyle `json:"default_merge_style,omitempty"` + // set to `true` to archive this repository. } // EditRepo edit the properties of a repository -- 2.40.1 From dcd1688553d14a67376a966c2b775c10727c753e Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 1 Jul 2021 00:06:07 +0200 Subject: [PATCH 09/14] MigrateRepoOption: add LFS,LFSEndpoint --- gitea/repo_migrate.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gitea/repo_migrate.go b/gitea/repo_migrate.go index 91f19d6..cd0fe44 100644 --- a/gitea/repo_migrate.go +++ b/gitea/repo_migrate.go @@ -47,6 +47,8 @@ type MigrateRepoOption struct { PullRequests bool `json:"pull_requests"` Releases bool `json:"releases"` MirrorInterval string `json:"mirror_interval"` + LFS bool `json:"lfs"` + LFSEndpoint string `json:"lfs_endpoint"` } // Validate the MigrateRepoOption struct -- 2.40.1 From 2a18564a9dfac564074c24b98167070f147c3725 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 1 Jul 2021 00:11:07 +0200 Subject: [PATCH 10/14] Tag: add Message --- gitea/repo_tag.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gitea/repo_tag.go b/gitea/repo_tag.go index 0a3c806..24792b5 100644 --- a/gitea/repo_tag.go +++ b/gitea/repo_tag.go @@ -11,6 +11,7 @@ import ( // Tag represents a repository tag type Tag struct { Name string `json:"name"` + Message string `json:"message"` ID string `json:"id"` Commit *CommitMeta `json:"commit"` ZipballURL string `json:"zipball_url"` -- 2.40.1 From 6881fe0cde265f0ba9f7d331c571320dd1c80f3a Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 1 Jul 2021 00:13:39 +0200 Subject: [PATCH 11/14] GlobalUISettings: add CustomEmojis --- gitea/settings.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gitea/settings.go b/gitea/settings.go index 134d2ad..adbd2a6 100644 --- a/gitea/settings.go +++ b/gitea/settings.go @@ -8,6 +8,7 @@ package gitea type GlobalUISettings struct { DefaultTheme string `json:"default_theme"` AllowedReactions []string `json:"allowed_reactions"` + CustomEmojis []string `json:"custom_emojis"` } // GlobalRepoSettings represent the global repository settings of a gitea instance witch is exposed by API -- 2.40.1 From 30fe2fd279f821cf1754b4ddb3a3d13156f25816 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 1 Jul 2021 00:14:11 +0200 Subject: [PATCH 12/14] GlobalRepoSettings: add StarsDisabled,TimeTrackingDisabled,LFSDisabled --- gitea/settings.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gitea/settings.go b/gitea/settings.go index adbd2a6..fb94248 100644 --- a/gitea/settings.go +++ b/gitea/settings.go @@ -13,9 +13,12 @@ type GlobalUISettings struct { // GlobalRepoSettings represent the global repository settings of a gitea instance witch is exposed by API type GlobalRepoSettings struct { - MirrorsDisabled bool `json:"mirrors_disabled"` - HTTPGitDisabled bool `json:"http_git_disabled"` - MigrationsDisabled bool `json:"migrations_disabled"` + MirrorsDisabled bool `json:"mirrors_disabled"` + HTTPGitDisabled bool `json:"http_git_disabled"` + MigrationsDisabled bool `json:"migrations_disabled"` + StarsDisabled bool `json:"stars_disabled"` + TimeTrackingDisabled bool `json:"time_tracking_disabled"` + LFSDisabled bool `json:"lfs_disabled"` } // GlobalAPISettings contains global api settings exposed by it -- 2.40.1 From 7db424461311c0695f7528a5bc34e9faeea5425c Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 1 Jul 2021 00:21:06 +0200 Subject: [PATCH 13/14] User: add Restricted,IsActive,ProhibitLogin,Location,Website,Description,Visibility,FollowerCount,FollowingCount,StarredRepoCount --- gitea/user.go | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/gitea/user.go b/gitea/user.go index 81867a0..c37627b 100644 --- a/gitea/user.go +++ b/gitea/user.go @@ -25,9 +25,30 @@ type User struct { // User locale Language string `json:"language"` // Is the user an administrator - IsAdmin bool `json:"is_admin"` - LastLogin time.Time `json:"last_login,omitempty"` - Created time.Time `json:"created,omitempty"` + IsAdmin bool `json:"is_admin"` + // Date and Time of last login + LastLogin time.Time `json:"last_login"` + // Date and Time of user creation + Created time.Time `json:"created"` + // Is user restricted + Restricted bool `json:"restricted"` + // Is user active + IsActive bool `json:"active"` + // Is user login prohibited + ProhibitLogin bool `json:"prohibit_login"` + // the user's location + Location string `json:"location"` + // the user's website + Website string `json:"website"` + // the user's description + Description string `json:"description"` + // User visibility level option + Visibility VisibleType `json:"visibility"` + + // user counts + FollowerCount int `json:"followers_count"` + FollowingCount int `json:"following_count"` + StarredRepoCount int `json:"starred_repos_count"` } // GetUserInfo get user info by user's name -- 2.40.1 From a658f3023fbfb819f010977168592a2f84cf96f8 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 1 Jul 2021 01:37:45 +0200 Subject: [PATCH 14/14] fix test --- gitea/settings_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gitea/settings_test.go b/gitea/settings_test.go index 9a135be..d5e3e06 100644 --- a/gitea/settings_test.go +++ b/gitea/settings_test.go @@ -25,6 +25,7 @@ func TestGetGlobalSettings(t *testing.T) { assert.EqualValues(t, &GlobalRepoSettings{ HTTPGitDisabled: false, MirrorsDisabled: false, + LFSDisabled: true, }, repoSettings) apiSettings, _, err := c.GetGlobalAPISettings() -- 2.40.1