From f4c493667cfede8edfa0ed32daeaed5eb9c1fbc6 Mon Sep 17 00:00:00 2001 From: Martijn van der Kleijn Date: Fri, 3 May 2024 14:54:54 +0000 Subject: [PATCH] Make final corrections before fork is finalized (#3) Reviewed-on: https://codeberg.org/mvdkleijn/forgejo-sdk/pulls/3 Co-authored-by: Martijn van der Kleijn Co-committed-by: Martijn van der Kleijn --- .changelog.yml | 2 +- CONTRIBUTING.md | 2 +- docs/migrate-v0.11-to-v0.12.md | 118 --------------------------------- docs/migrate-v0.12-to-v0.13.md | 87 ------------------------ docs/migrate-v0.13-to-v0.14.md | 46 ------------- docs/migrate-v0.14-to-v0.15.md | 20 ------ docs/migrate-v0.15-to-v0.16.md | 28 -------- forgejo/user_test.go | 2 +- 8 files changed, 3 insertions(+), 302 deletions(-) delete mode 100644 docs/migrate-v0.11-to-v0.12.md delete mode 100644 docs/migrate-v0.12-to-v0.13.md delete mode 100644 docs/migrate-v0.13-to-v0.14.md delete mode 100644 docs/migrate-v0.14-to-v0.15.md delete mode 100644 docs/migrate-v0.15-to-v0.16.md diff --git a/.changelog.yml b/.changelog.yml index beba96b..26f6705 100755 --- a/.changelog.yml +++ b/.changelog.yml @@ -4,7 +4,7 @@ repo: mvdkleijn/forgejo-sdk # Service type (forgejo or github) service: forgejo -# Base URL for Gitea instance if using gitea service type (optional) +# Base URL for Forgejo instance if using forgejo service type (optional) # Default: https://forgejo.org base-url: https://forgejo.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8254b92..63d1749 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ Please be kind, remember that Forgejo SDK comes at no cost to you, and you're ge The project welcomes submissions but please let everyone know what you're working on if you want to change or add something to the Forgejo SDK repository. -Before starting to write something new for the Forgejo SDK project, please [file an issue](https://coderberg.org/mvdkleijn/forgejo-sdk/issues/new). +Before starting to write something new for the Forgejo SDK project, please [file an issue](https://codeberg.org/mvdkleijn/forgejo-sdk/issues/new). ## Testing redux diff --git a/docs/migrate-v0.11-to-v0.12.md b/docs/migrate-v0.11-to-v0.12.md deleted file mode 100644 index 0f9969d..0000000 --- a/docs/migrate-v0.11-to-v0.12.md +++ /dev/null @@ -1,118 +0,0 @@ -# Migration Guide: v0.11 to v0.12 - -v0.12.0 introduces a number of breaking changes, through which it should not be difficult to migrate. -Just follow this guid and if you still encounter problems, ask for help on discord or feel free to create an issue. - - - -- [List Functions now always need an ListOption as argument (#205) (#243) (244)](#List-Functions-now-always-need-an-ListOption-as-argument) -- [Authentification was removed from all Functions (#241) (#335)](Authentification-was-removed-from-all-Functions) -- [Some Functions where deleted (#247) (#262)](Some-Functions-where-deleted) -- [SearchUsers arguments are move to an Option struct (#248)](SearchUsers-arguments-are-move-to-an-Option-struct) -- [RepoTopics functions now expect and return string slice directly (#276)](ListRepoTopics-return-now-string-slice-directly) -- [MergePullRequestOption field names changed and Enum is now used (#328)](MergePullRequestOption-field-names-changed-and-Enum-is-now-used) - - - -## List Functions now always need an ListOption as argument - -since paggination is introduced in gitea v1.12.0 for all list endpoints, -all List Functions acept at least **Page** and **PageSize**. - -If the function had had already an Option struct as argument this one is now extendet, -if not a new Options type was created. - -- migrate old paggination arguments to the new One. -- add a empty Option struct if a new one was created. - -Pulls: - -- [#205 Add Pagination Options for List Requests](https://gitea.com/gitea/go-sdk/pulls/205) -- [#243 Add ListIssueCommentOptions for optional param](https://gitea.com/gitea/go-sdk/pulls/243) -- [#244 Add ListMilestoneOption to ListRepoMilestones](https://gitea.com/gitea/go-sdk/pulls/244) - -## Authentification was removed from all Functions - -for Authentification the default credentials/token is used, -witch was set on Client initialisation. - -for RepoWatch functions remove arguments: - -- GetWatchedRepos: password (second) -- WatchRepo: username (first), password (second) -- UnWatchRepo: username (first), password (second) - -for Token functions remove: - -- the first two argument (user & password), - these functions still relay on BasicAuth so if not done, - just set username, password and optional otp before executing them. - -```go -client.SetBasicAuth(username, password) -client.SetOTP(otp) -``` - -Pulls: - -- [#241 Refactor RepoWatch](https://gitea.com/gitea/go-sdk/pulls/241) -- [#335 Support 2FA for basic auth & Refactor Token functions](https://gitea.com/gitea/go-sdk/pulls/335) - -## Some Functions where deleted - -Functions where deleted because they where only workarounds -or are helper functions witch could be replaced easely. - -- BasicAuthEncode - if you realy need this just copy the function into your project: - ```go - func BasicAuthEncode(user, pass string) string { - return base64.StdEncoding.EncodeToString([]byte(user + ":" + pass)) - } - ``` -- ListUserIssues - If you realy need this just use the Workaround witch was removed with #262 - and If you have time a pull upstream to gitea for a real API is always wellcome - -Pulls: - -- [#247 Fix & Refactor UserApp Functions](https://gitea.com/gitea/go-sdk/pulls/247) -- [#262 Remove ListUserIssues](https://gitea.com/gitea/go-sdk/pulls/262) - -## SearchUsers arguments are move to an Option struct - -Old: - `client.SearchUsers(query, limit)` -New: - `client.SearchUsers(SearchUsersOption{KeyWord: "query", Page: 1, PageSize: limit})` - -Pull: [#248 extend SearchUsers](https://gitea.com/gitea/go-sdk/pulls/248) - -## ListRepoTopics return now string slice directly - -ListRepoTopics returned a struct with Topics string slice. -Now it return the falue of this string slice directly - -Old: - -```go -client.SetRepoTopics(user, repo, TopicsList{topic_slice}) -``` - -New: - -```go -client.SetRepoTopics(user, repo, topic_slice) -``` - -Pull: [#276 Refactor List/SetRepoTopics](https://gitea.com/gitea/go-sdk/pulls/276) - -## MergePullRequestOption field names changed and Enum is now used - -Rename **MergeTitleField** to **Title** -Rename **MergeMessageField** to **Message** - -Do is now called Style and expect predefined falues: -MergeStyleMerge, MergeStyleRebase, MergeStyleRebaseMerge & MergeStyleSquash - -Pull: [#328 PullMerge: use enum for MergeStyle](https://gitea.com/gitea/go-sdk/pulls/328) diff --git a/docs/migrate-v0.12-to-v0.13.md b/docs/migrate-v0.12-to-v0.13.md deleted file mode 100644 index 26371c3..0000000 --- a/docs/migrate-v0.12-to-v0.13.md +++ /dev/null @@ -1,87 +0,0 @@ -# Migration Guide: v0.12 to v0.13 - -v0.13.0 introduces a number of breaking changes, through which it should not be difficult to migrate. -Just follow this guid and if you still encounter problems, ask for help on discord or feel free to create an issue. - - - -- [EditMilestoneOption use StateType (#350)](#EditMilestoneOption-use-StateType) -- [RepoSearch Options Struct was rewritten (#346)](#RepoSearch-Options-Struct-was-rewritten) -- [Variable Renames (#386)](#Variable-Renames) -- [Change Type of Permission Field (#408)](#Change-Type-of-Permission-Field) -- [All Function return http responce (#416)](#All-Function-return-http-responce) -- [NewClient has new Option Interface (#417)](#NewClient-has-new-Option-Interface) - - - -## EditMilestoneOption use StateType - -Instead of a raw string StateType is now used for State too. -just replace old strings with new enum. - - -Pulls: -- [#350 EditMilestoneOption also use StateType](https://gitea.com/gitea/go-sdk/pulls/350) - - -## RepoSearch Options Struct was rewritten - -Since the API itself is ugly and there was no nameconvention whats o ever. -You easely can pass the wrong options and dont get the result you want. - -Now it is rewritten and translated for the API. -The easyest way to migrate is to look at who this function is used and rewritten that code block. - -If there is a special edgecase you have you can pass a `RawQuery` to the API endpoint. - -Pulls: -- [#346 Refactor RepoSearch to be easy usable](https://gitea.com/gitea/go-sdk/pulls/346) - - -## Variable Renames - -Some names of strcut options have been renamed to describe there function/usecase more precisely. -if you use `CreateOrgOption` somewhere just rename `UserName` to `Name`. - -Pulls: -- [#386 CreateOrgOption rename UserName to Name](https://gitea.com/gitea/go-sdk/pulls/386) - -## Change Type of Permission Field - -The following functions are affected: ListOrgTeams, ListMyTeams, GetTeam, CreateTeam, EditTeam and AddCollaborator - -The `Permission` field has changed type from `string` to `AccessMode`, -which represent the raw strings you must use before. -Just replace the string with the AccessMode equivalent. - -Pulls: -- [#408 Use enum AccessMode for OrgTeam and Collaborator functions](https://gitea.com/gitea/go-sdk/pulls/408) - - -## All Function return http responce - -All functions got one new return (`Responce`)! -If you just like to migrate, add `_,` before the error return. - -example: -```diff -- user, err := c.GetMyUserInfo() -+ user, _, err := c.GetMyUserInfo() -``` - -If you like to check responce if an error ocure, make sure responce is not nil! -If an error ocure before an http request (e.g. gitea is to old), it will be nil. - -Pulls: -- [#416 All Function return http responce](https://gitea.com/gitea/go-sdk/pulls/416) - - -## NewClient has new Option Interface - -function `NewClient` use functional options now. -If you simply like to migrate replace `client := NewClient(giteaUrl, token)` with `client, _ := NewClient(giteaURL, SetToken(token))`. - -If you like tu utilize them, currently there are: SetContext, SetBasicAuth, SetOTP, SetToken, SetHTTPClient, SetSudo - -Pulls: -- [#417 Make http requests with context](https://gitea.com/gitea/go-sdk/pulls/417) diff --git a/docs/migrate-v0.13-to-v0.14.md b/docs/migrate-v0.13-to-v0.14.md deleted file mode 100644 index e199cd8..0000000 --- a/docs/migrate-v0.13-to-v0.14.md +++ /dev/null @@ -1,46 +0,0 @@ -# Migration Guide: v0.13 to v0.14 - -v0.14.0 introduces a number of breaking changes, through which it should not be difficult to migrate. -Just follow this guid and if you still encounter problems, ask for help on discord or feel free to create an issue. - - - -- [Removed Functions (#467)](#removed-functions) -- [Renamed Functions (#467)](#renamed-functions) -- [New Optional Fields (#486)](#new-optional-fields) -- [Arguemnts are escapted by the SDK iteslve now (#273)](#escape-function-arguments) - - - -## Removed Functions - - - for **GetUserTrackedTimes** and **GetRepoTrackedTimes** use **ListRepoTrackedTimes** with specific options set - -Pulls: -- [#467 Remove GetUserTrackedTimes](https://gitea.com/gitea/go-sdk/pulls/467) - - -## Renamed Functions - -- **ListTrackedTimes** is now **ListIssueTrackedTimes** - -Pulls: -- [#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) - - -## Escape Function Arguments - -String arguments like `user`, `repo`, `tag`, ... are now url/path/query escapted as they need. -If you had issues and did escape arguments by yourselve you have to remove this now. diff --git a/docs/migrate-v0.14-to-v0.15.md b/docs/migrate-v0.14-to-v0.15.md deleted file mode 100644 index 953e987..0000000 --- a/docs/migrate-v0.14-to-v0.15.md +++ /dev/null @@ -1,20 +0,0 @@ -# Migration Guide: v0.14 to v0.15 - -v0.15.0 introduces a number of API changes, which should be simple to migrate. -Just follow this guide and if you still encounter problems, ask for help on Discord or feel free to create an issue. - - - -- [Changed Struct Fields (#503) (#520)](#changed-struct-fields) - - - -## Changed Struct Fields - - - The `State` field at **NotificationSubject** changed from **StateType** to **NotifySubjectState**, it also contains `"open"`, `"closed"` and add `"merged"`. - - In **Issue**, **CreateIssueOption** and **EditIssueOption** structs, `Assignee` got removed. Use `Assignees`. - - `Type` field at **CreateHookOption** now use **HookType** instead of pure string. - -Pulls: -- [#503 Drop deprecations](https://gitea.com/gitea/go-sdk/pulls/503) -- [#520 Introduce NotifySubjectState](https://gitea.com/gitea/go-sdk/pulls/520) diff --git a/docs/migrate-v0.15-to-v0.16.md b/docs/migrate-v0.15-to-v0.16.md deleted file mode 100644 index 83a8f28..0000000 --- a/docs/migrate-v0.15-to-v0.16.md +++ /dev/null @@ -1,28 +0,0 @@ -# Migration Guide: v0.15 to v0.16 - -v0.16.0 introduces a number of API changes, which should be simple to migrate. -Just follow this guide and if you still encounter problems, ask for help on Discord or feel free to create an issue. - - - -- [Upstream API changes](#upstream-api-changes) -- [GetPullRequestDiff: add PullRequestDiffOption parameter (#542)](#getpullrequestdiff) - - - -## Upstream API changes - -As we aim to track API changes in Gitea 1.16 with this SDK release, you may find this [summary listing of changes](https://gitea.com/gitea/go-sdk/issues/558) helpful. - -## GetPullRequestDiff - Added new parameter `opts PullRequestDiffOption`. Gitea 1.16 will default to omit binary file changes in diffs; if you still need that information, set `opts.Binary = true`. - Related PRs: - - [go-sdk#542](https://gitea.com/gitea/go-sdk/pulls/542) - - [gitea#17158](https://github.com/go-gitea/gitea/pull/17158) - -## ReadNotification, ReadNotifications, ReadRepoNotifications -The function now has a new return argument. The read notifications will now be returned by Gitea 1.16. If you don't require this information, use a blank identifier for the return variable. - -Related PRs: - - [go-sdk#590](https://gitea.com/gitea/go-sdk/pulls/590) - - [gitea#17064](https://github.com/go-gitea/gitea/pull/17064) diff --git a/forgejo/user_test.go b/forgejo/user_test.go index a766714..98b4c72 100644 --- a/forgejo/user_test.go +++ b/forgejo/user_test.go @@ -36,7 +36,7 @@ func TestUserApp(t *testing.T) { result, _, err := c.ListAccessTokens(ListAccessTokensOptions{}) assert.NoError(t, err) assert.Len(t, result, 1) - // the gitea-admin name for the token is hardcoded in forgejo itself, until it's changed this will need to do + // TODO: the gitea-admin name for the token is hardcoded in forgejo itself, until it's changed this will need to do assert.EqualValues(t, "gitea-admin", result[0].Name) t1, _, err := c.CreateAccessToken(CreateAccessTokenOption{Name: "TestCreateAccessToken"})