Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006)

Reviewed-on: https://gitea.com/gitea/tea/pulls/1006
Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com>
This commit is contained in:
Lunny Xiao
2026-05-26 04:51:09 +00:00
parent 579099f9d9
commit 28ba9b915b
179 changed files with 617 additions and 599 deletions
+5 -5
View File
@@ -11,7 +11,7 @@ import (
"strings"
"syscall"
"code.gitea.io/sdk/gitea"
gitea "gitea.dev/sdk"
"gitea.dev/tea/cmd/flags"
"gitea.dev/tea/modules/context"
@@ -83,7 +83,7 @@ var CmdUserCreate = cli.Command{
}
// RunUserCreate creates a new user
func RunUserCreate(_ stdctx.Context, cmd *cli.Command) error {
func RunUserCreate(requestCtx stdctx.Context, cmd *cli.Command) error {
ctx, err := context.InitCommand(cmd)
if err != nil {
return err
@@ -177,7 +177,7 @@ func RunUserCreate(_ stdctx.Context, cmd *cli.Command) error {
createOpts.Visibility = vis
// Create the user
user, _, err := client.AdminCreateUser(createOpts)
user, _, err := client.Admin.CreateUser(requestCtx, createOpts)
if err != nil {
return err
}
@@ -202,13 +202,13 @@ func RunUserCreate(_ stdctx.Context, cmd *cli.Command) error {
}
// Update user with admin/restricted/prohibit-login settings
_, err = client.AdminEditUser(username, editOpts)
_, err = client.Admin.EditUser(requestCtx, username, editOpts)
if err != nil {
return fmt.Errorf("user created but failed to update admin/restricted/prohibit-login status: %w", err)
}
// Refresh user info to reflect the changes
user, _, err = client.GetUserInfo(username)
user, _, err = client.Users.GetUserInfo(requestCtx, username)
if err != nil {
return fmt.Errorf("user updated but failed to retrieve updated user info: %w", err)
}
+3 -3
View File
@@ -31,7 +31,7 @@ var CmdUserDelete = cli.Command{
}
// RunUserDelete deletes a user
func RunUserDelete(_ stdctx.Context, cmd *cli.Command) error {
func RunUserDelete(requestCtx stdctx.Context, cmd *cli.Command) error {
ctx, err := context.InitCommand(cmd)
if err != nil {
return err
@@ -45,7 +45,7 @@ func RunUserDelete(_ stdctx.Context, cmd *cli.Command) error {
username := ctx.Args().First()
// Get user details first to show what we're deleting
user, _, err := client.GetUserInfo(username)
user, _, err := client.Users.GetUserInfo(requestCtx, username)
if err != nil {
return fmt.Errorf("failed to get user info: %w", err)
}
@@ -67,7 +67,7 @@ func RunUserDelete(_ stdctx.Context, cmd *cli.Command) error {
}
}
_, err = client.AdminDeleteUser(username)
_, err = client.Admin.DeleteUser(requestCtx, username)
if err != nil {
return fmt.Errorf("failed to delete user: %w", err)
}
+5 -6
View File
@@ -11,8 +11,7 @@ import (
"strings"
"syscall"
"code.gitea.io/sdk/gitea"
gitea "gitea.dev/sdk"
"gitea.dev/tea/cmd/flags"
"gitea.dev/tea/modules/context"
"gitea.dev/tea/modules/print"
@@ -135,7 +134,7 @@ var CmdUserEdit = cli.Command{
}
// RunUserEdit edits an existing user
func RunUserEdit(_ stdctx.Context, cmd *cli.Command) error {
func RunUserEdit(requestCtx stdctx.Context, cmd *cli.Command) error {
ctx, err := context.InitCommand(cmd)
if err != nil {
return err
@@ -149,7 +148,7 @@ func RunUserEdit(_ stdctx.Context, cmd *cli.Command) error {
username := ctx.Args().First()
// Verify the user exists before attempting an update.
_, _, err = client.GetUserInfo(username)
_, _, err = client.Users.GetUserInfo(requestCtx, username)
if err != nil {
return fmt.Errorf("failed to get user info: %w", err)
}
@@ -358,13 +357,13 @@ func RunUserEdit(_ stdctx.Context, cmd *cli.Command) error {
}
// Update the user
_, err = client.AdminEditUser(username, editOpts)
_, err = client.Admin.EditUser(requestCtx, username, editOpts)
if err != nil {
return fmt.Errorf("failed to update user: %w", err)
}
// Refresh user info to reflect the changes
updatedUser, _, err := client.GetUserInfo(username)
updatedUser, _, err := client.Users.GetUserInfo(requestCtx, username)
if err != nil {
return fmt.Errorf("user updated but failed to retrieve updated user info: %w", err)
}
+3 -3
View File
@@ -6,7 +6,7 @@ package users
import (
stdctx "context"
"code.gitea.io/sdk/gitea"
gitea "gitea.dev/sdk"
"gitea.dev/tea/cmd/flags"
"gitea.dev/tea/modules/context"
@@ -33,7 +33,7 @@ var CmdUserList = cli.Command{
}
// RunUserList list users
func RunUserList(_ stdctx.Context, cmd *cli.Command) error {
func RunUserList(requestCtx stdctx.Context, cmd *cli.Command) error {
ctx, err := context.InitCommand(cmd)
if err != nil {
return err
@@ -45,7 +45,7 @@ func RunUserList(_ stdctx.Context, cmd *cli.Command) error {
}
client := ctx.Login.Client()
users, _, err := client.AdminListUsers(gitea.AdminListUsersOptions{
users, _, err := client.Admin.ListUsers(requestCtx, gitea.AdminListUsersOptions{
ListOptions: flags.GetListOptions(cmd),
})
if err != nil {
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"fmt"
"strings"
"code.gitea.io/sdk/gitea"
"gitea.dev/sdk"
)
func parseUserVisibility(visibility string) (*gitea.VisibleType, error) {