From 34eee25bd42d19287e3e33afd169cc979ab61f37 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 11 May 2019 18:21:34 +0800 Subject: [PATCH] Move sdk structs to modules/structs (#6905) * move sdk structs to moduels/structs * fix tests * fix fmt * fix swagger * fix vendor --- go.mod | 1 - go.sum | 4 - integrations/api_admin_test.go | 2 +- integrations/api_branch_test.go | 2 +- integrations/api_comment_test.go | 2 +- integrations/api_fork_test.go | 2 +- integrations/api_gpg_keys_test.go | 2 +- .../api_helper_for_declarative_test.go | 2 +- integrations/api_issue_label_test.go | 2 +- integrations/api_issue_test.go | 2 +- integrations/api_keys_test.go | 2 +- integrations/api_org_test.go | 2 +- integrations/api_pull_test.go | 2 +- integrations/api_releases_test.go | 2 +- integrations/api_repo_file_content_test.go | 2 +- integrations/api_repo_file_create_test.go | 2 +- integrations/api_repo_file_delete_test.go | 2 +- integrations/api_repo_file_helpers.go | 2 +- integrations/api_repo_file_update_test.go | 2 +- integrations/api_repo_git_blobs_test.go | 2 +- integrations/api_repo_git_hook_test.go | 2 +- integrations/api_repo_lfs_locks_test.go | 2 +- integrations/api_repo_tags_test.go | 2 +- integrations/api_repo_test.go | 2 +- integrations/api_team_test.go | 2 +- integrations/api_token_test.go | 2 +- integrations/api_user_orgs_test.go | 2 +- integrations/api_user_search_test.go | 2 +- integrations/benchmarks_test.go | 2 +- integrations/links_test.go | 2 +- integrations/pull_status_test.go | 2 +- integrations/repo_commits_test.go | 2 +- integrations/ssh_key_test.go | 2 +- integrations/version_test.go | 4 +- models/action.go | 2 +- models/attachment.go | 2 +- models/issue.go | 2 +- models/issue_assignees.go | 2 +- models/issue_comment.go | 2 +- models/issue_label.go | 2 +- models/issue_label_test.go | 2 +- models/issue_milestone.go | 2 +- models/issue_milestone_test.go | 2 +- models/issue_tracked_time.go | 2 +- models/lfs_lock.go | 2 +- models/pull.go | 2 +- models/release.go | 2 +- models/repo.go | 2 +- models/review.go | 2 +- models/status.go | 2 +- models/user.go | 2 +- models/webhook.go | 2 +- models/webhook_dingtalk.go | 2 +- models/webhook_discord.go | 2 +- models/webhook_msteams.go | 2 +- models/webhook_slack.go | 2 +- models/webhook_telegram.go | 2 +- models/webhook_test.go | 2 +- modules/lfs/locks.go | 2 +- modules/repofiles/blob.go | 2 +- modules/repofiles/blob_test.go | 2 +- modules/repofiles/content.go | 2 +- modules/repofiles/content_test.go | 6 +- modules/repofiles/delete.go | 2 +- modules/repofiles/delete_test.go | 2 +- modules/repofiles/file.go | 2 +- modules/repofiles/file_test.go | 2 +- modules/repofiles/tree.go | 2 +- modules/repofiles/tree_test.go | 2 +- modules/repofiles/update.go | 4 +- modules/repofiles/update_test.go | 2 +- modules/repofiles/verification.go | 6 +- .../gitea => modules/structs}/admin_user.go | 44 +---- modules/structs/attachment.go | 27 +++ .../sdk/gitea => modules/structs}/doc.go | 2 +- modules/structs/fork.go | 11 ++ .../sdk/gitea => modules/structs}/git_blob.go | 2 +- modules/structs/git_hook.go | 20 ++ .../sdk/gitea => modules/structs}/hook.go | 80 +------- .../sdk/gitea => modules/structs}/issue.go | 67 +------ modules/structs/issue_comment.go | 35 ++++ modules/structs/issue_label.go | 36 ++++ modules/structs/issue_milestone.go | 39 ++++ modules/structs/issue_tracked_time.go | 30 +++ .../sdk/gitea => modules/structs}/lfs_lock.go | 2 +- .../structs}/miscellaneous.go | 8 +- .../sdk/gitea => modules/structs}/org.go | 36 +--- modules/structs/org_member.go | 10 + .../sdk/gitea => modules/structs}/org_team.go | 2 +- .../sdk/gitea => modules/structs}/pull.go | 61 +----- modules/structs/release.go | 50 +++++ .../sdk/gitea => modules/structs}/repo.go | 109 ++++------- modules/structs/repo_branch.go | 11 ++ modules/structs/repo_collaborator.go | 10 + .../gitea => modules/structs}/repo_commit.go | 12 +- .../gitea => modules/structs}/repo_file.go | 12 +- modules/structs/repo_key.go | 41 +++++ modules/structs/repo_refs.go | 19 ++ .../sdk/gitea => modules/structs}/repo_tag.go | 12 +- .../gitea => modules/structs}/repo_tree.go | 18 +- modules/structs/repo_watch.go | 19 ++ .../sdk/gitea => modules/structs}/status.go | 34 +--- .../sdk/gitea => modules/structs}/user.go | 17 +- modules/structs/user_app.go | 34 ++++ modules/structs/user_email.go | 25 +++ .../gitea => modules/structs}/user_gpgkey.go | 39 +--- modules/structs/user_key.go | 23 +++ modules/structs/user_search.go | 5 + .../sdk/gitea => modules/structs}/utils.go | 2 +- routers/api/v1/admin/org.go | 2 +- routers/api/v1/admin/repo.go | 2 +- routers/api/v1/admin/user.go | 2 +- routers/api/v1/api.go | 2 +- routers/api/v1/convert/convert.go | 2 +- routers/api/v1/misc/markdown.go | 2 +- routers/api/v1/misc/markdown_test.go | 2 +- routers/api/v1/misc/version.go | 4 +- routers/api/v1/org/hook.go | 2 +- routers/api/v1/org/member.go | 2 +- routers/api/v1/org/org.go | 2 +- routers/api/v1/org/team.go | 2 +- routers/api/v1/repo/branch.go | 2 +- routers/api/v1/repo/collaborators.go | 2 +- routers/api/v1/repo/commits.go | 2 +- routers/api/v1/repo/file.go | 2 +- routers/api/v1/repo/fork.go | 2 +- routers/api/v1/repo/git_hook.go | 2 +- routers/api/v1/repo/git_ref.go | 2 +- routers/api/v1/repo/hook.go | 2 +- routers/api/v1/repo/issue.go | 2 +- routers/api/v1/repo/issue_comment.go | 2 +- routers/api/v1/repo/issue_label.go | 2 +- routers/api/v1/repo/issue_tracked_time.go | 2 +- routers/api/v1/repo/key.go | 2 +- routers/api/v1/repo/label.go | 2 +- routers/api/v1/repo/milestone.go | 2 +- routers/api/v1/repo/pull.go | 2 +- routers/api/v1/repo/release.go | 2 +- routers/api/v1/repo/release_attachment.go | 2 +- routers/api/v1/repo/repo.go | 2 +- routers/api/v1/repo/star.go | 2 +- routers/api/v1/repo/status.go | 2 +- routers/api/v1/repo/subscriber.go | 2 +- routers/api/v1/repo/tag.go | 2 +- routers/api/v1/swagger/issue.go | 2 +- routers/api/v1/swagger/key.go | 2 +- routers/api/v1/swagger/misc.go | 2 +- routers/api/v1/swagger/options.go | 2 +- routers/api/v1/swagger/org.go | 2 +- routers/api/v1/swagger/repo.go | 2 +- routers/api/v1/swagger/user.go | 2 +- routers/api/v1/user/app.go | 2 +- routers/api/v1/user/email.go | 2 +- routers/api/v1/user/follower.go | 2 +- routers/api/v1/user/gpg_key.go | 2 +- routers/api/v1/user/key.go | 2 +- routers/api/v1/user/repo.go | 2 +- routers/api/v1/user/star.go | 2 +- routers/api/v1/user/user.go | 2 +- routers/api/v1/user/watch.go | 2 +- routers/api/v1/utils/hook.go | 2 +- routers/repo/webhook.go | 2 +- templates/swagger/v1_json.tmpl | 174 +++++++++--------- vendor/code.gitea.io/sdk/LICENSE | 20 -- vendor/code.gitea.io/sdk/gitea/admin_org.go | 22 --- vendor/code.gitea.io/sdk/gitea/admin_repo.go | 22 --- vendor/code.gitea.io/sdk/gitea/attachment.go | 92 --------- vendor/code.gitea.io/sdk/gitea/fork.go | 39 ---- vendor/code.gitea.io/sdk/gitea/git_hook.go | 54 ------ vendor/code.gitea.io/sdk/gitea/gitea.go | 125 ------------- .../code.gitea.io/sdk/gitea/issue_comment.go | 76 -------- vendor/code.gitea.io/sdk/gitea/issue_label.go | 122 ------------ .../sdk/gitea/issue_milestone.go | 80 -------- .../sdk/gitea/issue_tracked_time.go | 68 ------- vendor/code.gitea.io/sdk/gitea/org_member.go | 26 --- vendor/code.gitea.io/sdk/gitea/org_type.go | 49 ----- vendor/code.gitea.io/sdk/gitea/release.go | 105 ----------- vendor/code.gitea.io/sdk/gitea/repo_branch.go | 27 --- .../sdk/gitea/repo_collaborator.go | 57 ------ vendor/code.gitea.io/sdk/gitea/repo_key.go | 72 -------- vendor/code.gitea.io/sdk/gitea/repo_refs.go | 69 ------- vendor/code.gitea.io/sdk/gitea/repo_watch.go | 41 ----- vendor/code.gitea.io/sdk/gitea/user_app.go | 65 ------- vendor/code.gitea.io/sdk/gitea/user_email.go | 56 ------ vendor/code.gitea.io/sdk/gitea/user_follow.go | 55 ------ vendor/code.gitea.io/sdk/gitea/user_key.go | 60 ------ vendor/code.gitea.io/sdk/gitea/user_search.go | 14 -- vendor/modules.txt | 2 - 188 files changed, 717 insertions(+), 2144 deletions(-) rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/admin_user.go (59%) create mode 100644 modules/structs/attachment.go rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/doc.go (76%) create mode 100644 modules/structs/fork.go rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/git_blob.go (96%) create mode 100644 modules/structs/git_hook.go rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/hook.go (83%) rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/issue.go (52%) create mode 100644 modules/structs/issue_comment.go create mode 100644 modules/structs/issue_label.go create mode 100644 modules/structs/issue_milestone.go create mode 100644 modules/structs/issue_tracked_time.go rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/lfs_lock.go (99%) rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/miscellaneous.go (81%) rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/org.go (53%) create mode 100644 modules/structs/org_member.go rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/org_team.go (98%) rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/pull.go (57%) create mode 100644 modules/structs/release.go rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/repo.go (50%) create mode 100644 modules/structs/repo_branch.go create mode 100644 modules/structs/repo_collaborator.go rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/repo_commit.go (81%) rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/repo_file.go (88%) create mode 100644 modules/structs/repo_key.go create mode 100644 modules/structs/repo_refs.go rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/repo_tag.go (58%) rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/repo_tree.go (58%) create mode 100644 modules/structs/repo_watch.go rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/status.go (62%) rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/user.go (69%) create mode 100644 modules/structs/user_app.go create mode 100644 modules/structs/user_email.go rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/user_gpgkey.go (52%) create mode 100644 modules/structs/user_key.go create mode 100644 modules/structs/user_search.go rename {vendor/code.gitea.io/sdk/gitea => modules/structs}/utils.go (96%) delete mode 100644 vendor/code.gitea.io/sdk/LICENSE delete mode 100644 vendor/code.gitea.io/sdk/gitea/admin_org.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/admin_repo.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/attachment.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/fork.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/git_hook.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/gitea.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/issue_comment.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/issue_label.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/issue_milestone.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/org_member.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/org_type.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/release.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/repo_branch.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/repo_collaborator.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/repo_key.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/repo_refs.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/repo_watch.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/user_app.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/user_email.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/user_follow.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/user_key.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/user_search.go diff --git a/go.mod b/go.mod index 2657a2799..45f62e676 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module code.gitea.io/gitea go 1.12 require ( - code.gitea.io/sdk v0.0.0-20190510041517-9251befd3702 github.com/BurntSushi/toml v0.3.1 // indirect github.com/PuerkitoBio/goquery v0.0.0-20170324135448-ed7d758e9a34 github.com/RoaringBitmap/roaring v0.4.7 // indirect diff --git a/go.sum b/go.sum index ad9a0a9be..df3c606eb 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,4 @@ cloud.google.com/go v0.30.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -code.gitea.io/sdk v0.0.0-20190419065346-2858b80da5f7 h1:YggbbCVgggcOjKYmcB2wVOsEtJHgHUNFFJZDB6QcYTg= -code.gitea.io/sdk v0.0.0-20190419065346-2858b80da5f7/go.mod h1:5bZt0dRznpn2JysytQnV0yCru3FwDv9O5G91jo+lDAk= -code.gitea.io/sdk v0.0.0-20190510041517-9251befd3702 h1:MyOmF6QejeIZfsEQYoJVHOm1PGNyGZMAZmo6cO8Hq80= -code.gitea.io/sdk v0.0.0-20190510041517-9251befd3702/go.mod h1:5bZt0dRznpn2JysytQnV0yCru3FwDv9O5G91jo+lDAk= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/PuerkitoBio/goquery v0.0.0-20170324135448-ed7d758e9a34 h1:UsHpWO0Elp6NaWVARdZHjiYwkhrspHVEGsyIKPb9OI8= diff --git a/integrations/api_admin_test.go b/integrations/api_admin_test.go index 41add4545..825aed9d5 100644 --- a/integrations/api_admin_test.go +++ b/integrations/api_admin_test.go @@ -10,7 +10,7 @@ import ( "testing" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_branch_test.go b/integrations/api_branch_test.go index aff3f223c..fddbe4e40 100644 --- a/integrations/api_branch_test.go +++ b/integrations/api_branch_test.go @@ -8,7 +8,7 @@ import ( "net/http" "testing" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_comment_test.go b/integrations/api_comment_test.go index 60bb2cfb7..7bd364491 100644 --- a/integrations/api_comment_test.go +++ b/integrations/api_comment_test.go @@ -10,7 +10,7 @@ import ( "testing" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_fork_test.go b/integrations/api_fork_test.go index 2c5eb5516..fec288d96 100644 --- a/integrations/api_fork_test.go +++ b/integrations/api_fork_test.go @@ -8,7 +8,7 @@ import ( "net/http" "testing" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) func TestCreateForkNoLogin(t *testing.T) { diff --git a/integrations/api_gpg_keys_test.go b/integrations/api_gpg_keys_test.go index 0973fd33a..0384dcb22 100644 --- a/integrations/api_gpg_keys_test.go +++ b/integrations/api_gpg_keys_test.go @@ -10,7 +10,7 @@ import ( "strconv" "testing" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_helper_for_declarative_test.go b/integrations/api_helper_for_declarative_test.go index 32a4ce804..943981ead 100644 --- a/integrations/api_helper_for_declarative_test.go +++ b/integrations/api_helper_for_declarative_test.go @@ -10,7 +10,7 @@ import ( "net/http" "testing" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_issue_label_test.go b/integrations/api_issue_label_test.go index 57ca07337..bf50252ed 100644 --- a/integrations/api_issue_label_test.go +++ b/integrations/api_issue_label_test.go @@ -10,7 +10,7 @@ import ( "testing" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_issue_test.go b/integrations/api_issue_test.go index 0ac2f3b67..24535057e 100644 --- a/integrations/api_issue_test.go +++ b/integrations/api_issue_test.go @@ -10,7 +10,7 @@ import ( "testing" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_keys_test.go b/integrations/api_keys_test.go index 91cbd72f9..ca3d4b2d7 100644 --- a/integrations/api_keys_test.go +++ b/integrations/api_keys_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/assert" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) func TestViewDeployKeysNoLogin(t *testing.T) { diff --git a/integrations/api_org_test.go b/integrations/api_org_test.go index 3dd4b759b..b36650f2e 100644 --- a/integrations/api_org_test.go +++ b/integrations/api_org_test.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_pull_test.go b/integrations/api_pull_test.go index c378e563b..8d24cdc18 100644 --- a/integrations/api_pull_test.go +++ b/integrations/api_pull_test.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_releases_test.go b/integrations/api_releases_test.go index 5cc4522f0..897f863eb 100644 --- a/integrations/api_releases_test.go +++ b/integrations/api_releases_test.go @@ -11,7 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_repo_file_content_test.go b/integrations/api_repo_file_content_test.go index cb4666070..1f535ef3a 100644 --- a/integrations/api_repo_file_content_test.go +++ b/integrations/api_repo_file_content_test.go @@ -13,7 +13,7 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_repo_file_create_test.go b/integrations/api_repo_file_create_test.go index da35127a5..a43855b06 100644 --- a/integrations/api_repo_file_create_test.go +++ b/integrations/api_repo_file_create_test.go @@ -16,7 +16,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_repo_file_delete_test.go b/integrations/api_repo_file_delete_test.go index 2c2cd5643..b619f9c43 100644 --- a/integrations/api_repo_file_delete_test.go +++ b/integrations/api_repo_file_delete_test.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_repo_file_helpers.go b/integrations/api_repo_file_helpers.go index d06f484dd..80fefe8ab 100644 --- a/integrations/api_repo_file_helpers.go +++ b/integrations/api_repo_file_helpers.go @@ -7,7 +7,7 @@ package integrations import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/repofiles" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) func createFileInBranch(user *models.User, repo *models.Repository, treePath, branchName string) (*api.FileResponse, error) { diff --git a/integrations/api_repo_file_update_test.go b/integrations/api_repo_file_update_test.go index d62a0e279..71994564f 100644 --- a/integrations/api_repo_file_update_test.go +++ b/integrations/api_repo_file_update_test.go @@ -16,7 +16,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_repo_git_blobs_test.go b/integrations/api_repo_git_blobs_test.go index 69bb6cde2..ad81299ba 100644 --- a/integrations/api_repo_git_blobs_test.go +++ b/integrations/api_repo_git_blobs_test.go @@ -9,7 +9,7 @@ import ( "testing" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_repo_git_hook_test.go b/integrations/api_repo_git_hook_test.go index 11632e6fc..1c6de7867 100644 --- a/integrations/api_repo_git_hook_test.go +++ b/integrations/api_repo_git_hook_test.go @@ -10,7 +10,7 @@ import ( "testing" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_repo_lfs_locks_test.go b/integrations/api_repo_lfs_locks_test.go index 35b26e45a..657933dd5 100644 --- a/integrations/api_repo_lfs_locks_test.go +++ b/integrations/api_repo_lfs_locks_test.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_repo_tags_test.go b/integrations/api_repo_tags_test.go index f9026b4d2..13b446fb9 100644 --- a/integrations/api_repo_tags_test.go +++ b/integrations/api_repo_tags_test.go @@ -11,7 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go index d126e149f..d03ddcb35 100644 --- a/integrations/api_repo_test.go +++ b/integrations/api_repo_test.go @@ -13,7 +13,7 @@ import ( "testing" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_team_test.go b/integrations/api_team_test.go index 7bb0e5b1b..a884085f5 100644 --- a/integrations/api_team_test.go +++ b/integrations/api_team_test.go @@ -11,8 +11,8 @@ import ( "testing" "code.gitea.io/gitea/models" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/routers/api/v1/convert" - api "code.gitea.io/sdk/gitea" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_token_test.go b/integrations/api_token_test.go index 5768d3b48..76660d160 100644 --- a/integrations/api_token_test.go +++ b/integrations/api_token_test.go @@ -9,7 +9,7 @@ import ( "testing" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // TestAPICreateAndDeleteToken tests that token that was just created can be deleted diff --git a/integrations/api_user_orgs_test.go b/integrations/api_user_orgs_test.go index 9b250c063..63e67f435 100644 --- a/integrations/api_user_orgs_test.go +++ b/integrations/api_user_orgs_test.go @@ -10,7 +10,7 @@ import ( "testing" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/api_user_search_test.go b/integrations/api_user_search_test.go index 8e7c429e7..b4c95db2f 100644 --- a/integrations/api_user_search_test.go +++ b/integrations/api_user_search_test.go @@ -8,7 +8,7 @@ import ( "net/http" "testing" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/benchmarks_test.go b/integrations/benchmarks_test.go index 3f009f62e..4be3008f5 100644 --- a/integrations/benchmarks_test.go +++ b/integrations/benchmarks_test.go @@ -10,7 +10,7 @@ import ( "testing" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) func BenchmarkRepo(b *testing.B) { diff --git a/integrations/links_test.go b/integrations/links_test.go index 803d99205..84be7e059 100644 --- a/integrations/links_test.go +++ b/integrations/links_test.go @@ -11,8 +11,8 @@ import ( "testing" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" - api "code.gitea.io/sdk/gitea" "github.com/stretchr/testify/assert" ) diff --git a/integrations/pull_status_test.go b/integrations/pull_status_test.go index ad8bb236e..238144467 100644 --- a/integrations/pull_status_test.go +++ b/integrations/pull_status_test.go @@ -10,7 +10,7 @@ import ( "testing" "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/repo_commits_test.go b/integrations/repo_commits_test.go index 48aac1802..1f70d6925 100644 --- a/integrations/repo_commits_test.go +++ b/integrations/repo_commits_test.go @@ -9,7 +9,7 @@ import ( "path" "testing" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/ssh_key_test.go b/integrations/ssh_key_test.go index f6df5ff8f..e8fbf17c5 100644 --- a/integrations/ssh_key_test.go +++ b/integrations/ssh_key_test.go @@ -15,7 +15,7 @@ import ( "time" "code.gitea.io/gitea/modules/git" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/integrations/version_test.go b/integrations/version_test.go index 9a30bfb53..eaba3e085 100644 --- a/integrations/version_test.go +++ b/integrations/version_test.go @@ -9,7 +9,7 @@ import ( "testing" "code.gitea.io/gitea/modules/setting" - "code.gitea.io/sdk/gitea" + "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) @@ -21,7 +21,7 @@ func TestVersion(t *testing.T) { req := NewRequest(t, "GET", "/api/v1/version") resp := MakeRequest(t, req, http.StatusOK) - var version gitea.ServerVersion + var version structs.ServerVersion DecodeJSON(t, resp, &version) assert.Equal(t, setting.AppVer, string(version.Version)) } diff --git a/models/action.go b/models/action.go index f39729869..b4f4b1cb6 100644 --- a/models/action.go +++ b/models/action.go @@ -20,8 +20,8 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/Unknwon/com" "github.com/go-xorm/builder" diff --git a/models/attachment.go b/models/attachment.go index bbb88939b..1740f065d 100644 --- a/models/attachment.go +++ b/models/attachment.go @@ -11,8 +11,8 @@ import ( "path" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/go-xorm/xorm" gouuid "github.com/satori/go.uuid" diff --git a/models/issue.go b/models/issue.go index ddc7fa24a..f9394594b 100644 --- a/models/issue.go +++ b/models/issue.go @@ -14,8 +14,8 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/Unknwon/com" "github.com/go-xorm/builder" diff --git a/models/issue_assignees.go b/models/issue_assignees.go index 5806dd976..f6a2afe2c 100644 --- a/models/issue_assignees.go +++ b/models/issue_assignees.go @@ -9,7 +9,7 @@ import ( "code.gitea.io/gitea/modules/log" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/go-xorm/xorm" ) diff --git a/models/issue_comment.go b/models/issue_comment.go index a7d6e2e3e..60fb5b042 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -18,7 +18,7 @@ import ( "github.com/go-xorm/builder" "github.com/go-xorm/xorm" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" diff --git a/models/issue_label.go b/models/issue_label.go index 3c593e72f..38266f3e7 100644 --- a/models/issue_label.go +++ b/models/issue_label.go @@ -13,7 +13,7 @@ import ( "github.com/go-xorm/xorm" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) var labelColorPattern = regexp.MustCompile("#([a-fA-F0-9]{6})") diff --git a/models/issue_label_test.go b/models/issue_label_test.go index d103778df..5cdc059cf 100644 --- a/models/issue_label_test.go +++ b/models/issue_label_test.go @@ -8,7 +8,7 @@ import ( "html/template" "testing" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/models/issue_milestone.go b/models/issue_milestone.go index 5304d85e9..3bde4b558 100644 --- a/models/issue_milestone.go +++ b/models/issue_milestone.go @@ -9,8 +9,8 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/go-xorm/xorm" ) diff --git a/models/issue_milestone_test.go b/models/issue_milestone_test.go index 3ea63d2d6..fb1ee8b7a 100644 --- a/models/issue_milestone_test.go +++ b/models/issue_milestone_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/stretchr/testify/assert" ) diff --git a/models/issue_tracked_time.go b/models/issue_tracked_time.go index bb3e76712..56ba52577 100644 --- a/models/issue_tracked_time.go +++ b/models/issue_tracked_time.go @@ -8,7 +8,7 @@ import ( "time" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/go-xorm/builder" "github.com/go-xorm/xorm" diff --git a/models/lfs_lock.go b/models/lfs_lock.go index d12c7cb53..a27a6f495 100644 --- a/models/lfs_lock.go +++ b/models/lfs_lock.go @@ -12,7 +12,7 @@ import ( "time" "code.gitea.io/gitea/modules/log" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/go-xorm/xorm" ) diff --git a/models/pull.go b/models/pull.go index 71a2439b2..7382cbd12 100644 --- a/models/pull.go +++ b/models/pull.go @@ -23,9 +23,9 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/sync" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/Unknwon/com" "github.com/go-xorm/xorm" diff --git a/models/release.go b/models/release.go index b2d534824..b7ec4461f 100644 --- a/models/release.go +++ b/models/release.go @@ -13,8 +13,8 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/go-xorm/builder" ) diff --git a/models/repo.go b/models/repo.go index e8af9aa2d..66c1bdbab 100644 --- a/models/repo.go +++ b/models/repo.go @@ -28,9 +28,9 @@ import ( "code.gitea.io/gitea/modules/options" "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/sync" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/Unknwon/cae/zip" "github.com/Unknwon/com" diff --git a/models/review.go b/models/review.go index ea2ccebed..5f856fbd8 100644 --- a/models/review.go +++ b/models/review.go @@ -8,8 +8,8 @@ import ( "fmt" "code.gitea.io/gitea/modules/log" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/go-xorm/builder" "github.com/go-xorm/core" diff --git a/models/status.go b/models/status.go index 9cfd9e896..a3db47f45 100644 --- a/models/status.go +++ b/models/status.go @@ -12,8 +12,8 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/go-xorm/xorm" ) diff --git a/models/user.go b/models/user.go index a51f52afb..0c445b5af 100644 --- a/models/user.go +++ b/models/user.go @@ -32,8 +32,8 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/structs" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/Unknwon/com" "github.com/go-xorm/builder" diff --git a/models/webhook.go b/models/webhook.go index 8a7350bb6..51b91879e 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -20,9 +20,9 @@ import ( "code.gitea.io/gitea/modules/httplib" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/sync" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/Unknwon/com" gouuid "github.com/satori/go.uuid" ) diff --git a/models/webhook_dingtalk.go b/models/webhook_dingtalk.go index 708673270..6a4bdaf06 100644 --- a/models/webhook_dingtalk.go +++ b/models/webhook_dingtalk.go @@ -10,7 +10,7 @@ import ( "strings" "code.gitea.io/gitea/modules/git" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" dingtalk "github.com/lunny/dingtalk_webhook" ) diff --git a/models/webhook_discord.go b/models/webhook_discord.go index 8f1cb1694..0029e94fc 100644 --- a/models/webhook_discord.go +++ b/models/webhook_discord.go @@ -13,7 +13,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) type ( diff --git a/models/webhook_msteams.go b/models/webhook_msteams.go index b0fc4e7a2..f42defbd1 100644 --- a/models/webhook_msteams.go +++ b/models/webhook_msteams.go @@ -10,7 +10,7 @@ import ( "strings" "code.gitea.io/gitea/modules/git" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) type ( diff --git a/models/webhook_slack.go b/models/webhook_slack.go index 2bb84c2c4..f422953e4 100644 --- a/models/webhook_slack.go +++ b/models/webhook_slack.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // SlackMeta contains the slack metadata diff --git a/models/webhook_telegram.go b/models/webhook_telegram.go index 7976d14c5..ead669dd0 100644 --- a/models/webhook_telegram.go +++ b/models/webhook_telegram.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/markup" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) type ( diff --git a/models/webhook_test.go b/models/webhook_test.go index 518be8be8..d2fb3ea6e 100644 --- a/models/webhook_test.go +++ b/models/webhook_test.go @@ -8,7 +8,7 @@ import ( "encoding/json" "testing" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) diff --git a/modules/lfs/locks.go b/modules/lfs/locks.go index 7a7d3ad42..525a93645 100644 --- a/modules/lfs/locks.go +++ b/modules/lfs/locks.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) //checkIsValidRequest check if it a valid request in case of bad request it write the response to ctx. diff --git a/modules/repofiles/blob.go b/modules/repofiles/blob.go index 2f9ca72bd..e9d85a0dc 100644 --- a/modules/repofiles/blob.go +++ b/modules/repofiles/blob.go @@ -8,7 +8,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // GetBlobBySHA get the GitBlobResponse of a repository using a sha hash. diff --git a/modules/repofiles/blob_test.go b/modules/repofiles/blob_test.go index 55320345f..1dc183a8a 100644 --- a/modules/repofiles/blob_test.go +++ b/modules/repofiles/blob_test.go @@ -8,8 +8,8 @@ import ( "testing" "code.gitea.io/gitea/models" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" - api "code.gitea.io/sdk/gitea" "github.com/stretchr/testify/assert" ) diff --git a/modules/repofiles/content.go b/modules/repofiles/content.go index d35c5a6a6..3098087dc 100644 --- a/modules/repofiles/content.go +++ b/modules/repofiles/content.go @@ -9,7 +9,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // GetFileContents gets the meta data on a file's contents diff --git a/modules/repofiles/content_test.go b/modules/repofiles/content_test.go index 0257284a5..ce3f5f367 100644 --- a/modules/repofiles/content_test.go +++ b/modules/repofiles/content_test.go @@ -9,8 +9,8 @@ import ( "testing" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" - "code.gitea.io/sdk/gitea" "github.com/stretchr/testify/assert" ) @@ -30,7 +30,7 @@ func TestGetFileContents(t *testing.T) { treePath := "README.md" ref := ctx.Repo.Repository.DefaultBranch - expectedFileContentResponse := &gitea.FileContentResponse{ + expectedFileContentResponse := &structs.FileContentResponse{ Name: treePath, Path: treePath, SHA: "4b4851ad51df6a7d9f25c979345979eaeb5b349f", @@ -40,7 +40,7 @@ func TestGetFileContents(t *testing.T) { GitURL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/4b4851ad51df6a7d9f25c979345979eaeb5b349f", DownloadURL: "https://try.gitea.io/user2/repo1/raw/branch/master/README.md", Type: "blob", - Links: &gitea.FileLinksResponse{ + Links: &structs.FileLinksResponse{ Self: "https://try.gitea.io/api/v1/repos/user2/repo1/contents/README.md", GitURL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/4b4851ad51df6a7d9f25c979345979eaeb5b349f", HTMLURL: "https://try.gitea.io/user2/repo1/blob/master/README.md", diff --git a/modules/repofiles/delete.go b/modules/repofiles/delete.go index ce7993dc5..ccf90f43b 100644 --- a/modules/repofiles/delete.go +++ b/modules/repofiles/delete.go @@ -10,7 +10,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // DeleteRepoFileOptions holds the repository delete file options diff --git a/modules/repofiles/delete_test.go b/modules/repofiles/delete_test.go index 0b0558e76..9d034066f 100644 --- a/modules/repofiles/delete_test.go +++ b/modules/repofiles/delete_test.go @@ -8,8 +8,8 @@ import ( "testing" "code.gitea.io/gitea/models" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" - api "code.gitea.io/sdk/gitea" "github.com/stretchr/testify/assert" ) diff --git a/modules/repofiles/file.go b/modules/repofiles/file.go index 913a9ed53..de3ee71db 100644 --- a/modules/repofiles/file.go +++ b/modules/repofiles/file.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // GetFileResponseFromCommit Constructs a FileResponse from a Commit object diff --git a/modules/repofiles/file_test.go b/modules/repofiles/file_test.go index c9ee7f21e..5f6320a93 100644 --- a/modules/repofiles/file_test.go +++ b/modules/repofiles/file_test.go @@ -9,8 +9,8 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" - api "code.gitea.io/sdk/gitea" "github.com/stretchr/testify/assert" ) diff --git a/modules/repofiles/tree.go b/modules/repofiles/tree.go index e189fe122..4eb54a259 100644 --- a/modules/repofiles/tree.go +++ b/modules/repofiles/tree.go @@ -10,7 +10,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // GetTreeBySHA get the GitTreeResponse of a repository using a sha hash. diff --git a/modules/repofiles/tree_test.go b/modules/repofiles/tree_test.go index c211cfcfd..ecff8b907 100644 --- a/modules/repofiles/tree_test.go +++ b/modules/repofiles/tree_test.go @@ -8,8 +8,8 @@ import ( "testing" "code.gitea.io/gitea/models" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" - api "code.gitea.io/sdk/gitea" "github.com/stretchr/testify/assert" ) diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go index 8bc3b50ae..66e3f2bab 100644 --- a/modules/repofiles/update.go +++ b/modules/repofiles/update.go @@ -19,7 +19,7 @@ import ( "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - "code.gitea.io/sdk/gitea" + "code.gitea.io/gitea/modules/structs" ) // IdentityOptions for a person's identity like an author or committer @@ -108,7 +108,7 @@ func detectEncodingAndBOM(entry *git.TreeEntry, repo *models.Repository) (string } // CreateOrUpdateRepoFile adds or updates a file in the given repository -func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *UpdateRepoFileOptions) (*gitea.FileResponse, error) { +func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *UpdateRepoFileOptions) (*structs.FileResponse, error) { // If no branch name is set, assume master if opts.OldBranch == "" { opts.OldBranch = repo.DefaultBranch diff --git a/modules/repofiles/update_test.go b/modules/repofiles/update_test.go index bf2802179..a3a0b0a42 100644 --- a/modules/repofiles/update_test.go +++ b/modules/repofiles/update_test.go @@ -10,8 +10,8 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" - api "code.gitea.io/sdk/gitea" "github.com/stretchr/testify/assert" ) diff --git a/modules/repofiles/verification.go b/modules/repofiles/verification.go index 75ead92d0..be56f9b8b 100644 --- a/modules/repofiles/verification.go +++ b/modules/repofiles/verification.go @@ -7,12 +7,12 @@ package repofiles import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" - "code.gitea.io/sdk/gitea" + "code.gitea.io/gitea/modules/structs" ) // GetPayloadCommitVerification returns the verification information of a commit -func GetPayloadCommitVerification(commit *git.Commit) *gitea.PayloadCommitVerification { - verification := &gitea.PayloadCommitVerification{} +func GetPayloadCommitVerification(commit *git.Commit) *structs.PayloadCommitVerification { + verification := &structs.PayloadCommitVerification{} commitVerification := models.ParseCommitWithSignature(commit) if commit.Signature != nil { verification.Signature = commit.Signature.Signature diff --git a/vendor/code.gitea.io/sdk/gitea/admin_user.go b/modules/structs/admin_user.go similarity index 59% rename from vendor/code.gitea.io/sdk/gitea/admin_user.go rename to modules/structs/admin_user.go index a4df703b1..7a447e44f 100644 --- a/vendor/code.gitea.io/sdk/gitea/admin_user.go +++ b/modules/structs/admin_user.go @@ -3,13 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) +package structs // CreateUserOption create user options type CreateUserOption struct { @@ -27,16 +21,6 @@ type CreateUserOption struct { SendNotify bool `json:"send_notify"` } -// AdminCreateUser create a user -func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - user := new(User) - return user, c.getParsedResponse("POST", "/admin/users", jsonHeader, bytes.NewReader(body), user) -} - // EditUserOption edit user options type EditUserOption struct { SourceID int64 `json:"source_id"` @@ -57,29 +41,3 @@ type EditUserOption struct { ProhibitLogin *bool `json:"prohibit_login"` AllowCreateOrganization *bool `json:"allow_create_organization"` } - -// AdminEditUser modify user informations -func (c *Client) AdminEditUser(user string, opt EditUserOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PATCH", fmt.Sprintf("/admin/users/%s", user), jsonHeader, bytes.NewReader(body)) - return err -} - -// AdminDeleteUser delete one user according name -func (c *Client) AdminDeleteUser(user string) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/admin/users/%s", user), nil, nil) - return err -} - -// AdminCreateUserPublicKey create one user with options -func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - key := new(PublicKey) - return key, c.getParsedResponse("POST", fmt.Sprintf("/admin/users/%s/keys", user), jsonHeader, bytes.NewReader(body), key) -} diff --git a/modules/structs/attachment.go b/modules/structs/attachment.go new file mode 100644 index 000000000..954956f32 --- /dev/null +++ b/modules/structs/attachment.go @@ -0,0 +1,27 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs // import "code.gitea.io/gitea/modules/structs" +import ( + "time" +) + +// Attachment a generic attachment +// swagger:model +type Attachment struct { + ID int64 `json:"id"` + Name string `json:"name"` + Size int64 `json:"size"` + DownloadCount int64 `json:"download_count"` + // swagger:strfmt date-time + Created time.Time `json:"created_at"` + UUID string `json:"uuid"` + DownloadURL string `json:"browser_download_url"` +} + +// EditAttachmentOptions options for editing attachments +// swagger:model +type EditAttachmentOptions struct { + Name string `json:"name"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/doc.go b/modules/structs/doc.go similarity index 76% rename from vendor/code.gitea.io/sdk/gitea/doc.go rename to modules/structs/doc.go index 6bd327db4..4c2fdbf73 100644 --- a/vendor/code.gitea.io/sdk/gitea/doc.go +++ b/modules/structs/doc.go @@ -2,4 +2,4 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea // import "code.gitea.io/sdk/gitea" +package structs diff --git a/modules/structs/fork.go b/modules/structs/fork.go new file mode 100644 index 000000000..dd6e24e8b --- /dev/null +++ b/modules/structs/fork.go @@ -0,0 +1,11 @@ +// Copyright 2016 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +// CreateForkOption options for creating a fork +type CreateForkOption struct { + // organization name, if forking into an organization + Organization *string `json:"organization"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/git_blob.go b/modules/structs/git_blob.go similarity index 96% rename from vendor/code.gitea.io/sdk/gitea/git_blob.go rename to modules/structs/git_blob.go index abdd95aaf..5715f2585 100644 --- a/vendor/code.gitea.io/sdk/gitea/git_blob.go +++ b/modules/structs/git_blob.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs // GitBlobResponse represents a git blob type GitBlobResponse struct { diff --git a/modules/structs/git_hook.go b/modules/structs/git_hook.go new file mode 100644 index 000000000..8a36b0b26 --- /dev/null +++ b/modules/structs/git_hook.go @@ -0,0 +1,20 @@ +// Copyright 2019 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +// GitHook represents a Git repository hook +type GitHook struct { + Name string `json:"name"` + IsActive bool `json:"is_active"` + Content string `json:"content,omitempty"` +} + +// GitHookList represents a list of Git hooks +type GitHookList []*GitHook + +// EditGitHookOption options when modifying one Git hook +type EditGitHookOption struct { + Content string `json:"content"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/hook.go b/modules/structs/hook.go similarity index 83% rename from vendor/code.gitea.io/sdk/gitea/hook.go rename to modules/structs/hook.go index d36e4d437..8dae578ec 100644 --- a/vendor/code.gitea.io/sdk/gitea/hook.go +++ b/modules/structs/hook.go @@ -3,13 +3,11 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs import ( - "bytes" "encoding/json" "errors" - "fmt" "strings" "time" ) @@ -36,30 +34,6 @@ type Hook struct { // HookList represents a list of API hook. type HookList []*Hook -// ListOrgHooks list all the hooks of one organization -func (c *Client) ListOrgHooks(org string) (HookList, error) { - hooks := make([]*Hook, 0, 10) - return hooks, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks", org), nil, nil, &hooks) -} - -// ListRepoHooks list all the hooks of one repository -func (c *Client) ListRepoHooks(user, repo string) (HookList, error) { - hooks := make([]*Hook, 0, 10) - return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks", user, repo), nil, nil, &hooks) -} - -// GetOrgHook get a hook of an organization -func (c *Client) GetOrgHook(org string, id int64) (*Hook, error) { - h := new(Hook) - return h, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks/%d", org, id), nil, nil, h) -} - -// GetRepoHook get a hook of a repository -func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, error) { - h := new(Hook) - return h, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), nil, nil, h) -} - // CreateHookOption options when create a hook type CreateHookOption struct { // required: true @@ -72,26 +46,6 @@ type CreateHookOption struct { Active bool `json:"active"` } -// CreateOrgHook create one hook for an organization, with options -func (c *Client) CreateOrgHook(org string, opt CreateHookOption) (*Hook, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - h := new(Hook) - return h, c.getParsedResponse("POST", fmt.Sprintf("/orgs/%s/hooks", org), jsonHeader, bytes.NewReader(body), h) -} - -// CreateRepoHook create one hook for a repository, with options -func (c *Client) CreateRepoHook(user, repo string, opt CreateHookOption) (*Hook, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - h := new(Hook) - return h, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/hooks", user, repo), jsonHeader, bytes.NewReader(body), h) -} - // EditHookOption options when modify one hook type EditHookOption struct { Config map[string]string `json:"config"` @@ -99,38 +53,6 @@ type EditHookOption struct { Active *bool `json:"active"` } -// EditOrgHook modify one hook of an organization, with hook id and options -func (c *Client) EditOrgHook(org string, id int64, opt EditHookOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PATCH", fmt.Sprintf("/orgs/%s/hooks/%d", org, id), jsonHeader, bytes.NewReader(body)) - return err -} - -// EditRepoHook modify one hook of a repository, with hook id and options -func (c *Client) EditRepoHook(user, repo string, id int64, opt EditHookOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PATCH", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), jsonHeader, bytes.NewReader(body)) - return err -} - -// DeleteOrgHook delete one hook from an organization, with hook id -func (c *Client) DeleteOrgHook(org string, id int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/org/%s/hooks/%d", org, id), nil, nil) - return err -} - -// DeleteRepoHook delete one hook from a repository, with hook id -func (c *Client) DeleteRepoHook(user, repo string, id int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), nil, nil) - return err -} - // Payloader payload is some part of one hook type Payloader interface { SetSecret(string) diff --git a/vendor/code.gitea.io/sdk/gitea/issue.go b/modules/structs/issue.go similarity index 52% rename from vendor/code.gitea.io/sdk/gitea/issue.go rename to modules/structs/issue.go index 0a1defb6f..af6aa6e54 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue.go +++ b/modules/structs/issue.go @@ -2,12 +2,9 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs import ( - "bytes" - "encoding/json" - "fmt" "time" ) @@ -64,30 +61,6 @@ type ListIssueOption struct { State string } -// ListIssues returns all issues assigned the authenticated user -func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, error) { - issues := make([]*Issue, 0, 10) - return issues, c.getParsedResponse("GET", fmt.Sprintf("/issues?page=%d", opt.Page), nil, nil, &issues) -} - -// ListUserIssues returns all issues assigned to the authenticated user -func (c *Client) ListUserIssues(opt ListIssueOption) ([]*Issue, error) { - issues := make([]*Issue, 0, 10) - return issues, c.getParsedResponse("GET", fmt.Sprintf("/user/issues?page=%d", opt.Page), nil, nil, &issues) -} - -// ListRepoIssues returns all issues for a given repository -func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Issue, error) { - issues := make([]*Issue, 0, 10) - return issues, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues?page=%d", owner, repo, opt.Page), nil, nil, &issues) -} - -// GetIssue returns a single issue for a given repository -func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, error) { - issue := new(Issue) - return issue, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), nil, nil, issue) -} - // CreateIssueOption options to create one issue type CreateIssueOption struct { // required:true @@ -105,17 +78,6 @@ type CreateIssueOption struct { Closed bool `json:"closed"` } -// CreateIssue create a new issue for a given repository -func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - issue := new(Issue) - return issue, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues", owner, repo), - jsonHeader, bytes.NewReader(body), issue) -} - // EditIssueOption options for editing an issue type EditIssueOption struct { Title string `json:"title"` @@ -128,33 +90,6 @@ type EditIssueOption struct { Deadline *time.Time `json:"due_date"` } -// EditIssue modify an existing issue for a given repository -func (c *Client) EditIssue(owner, repo string, index int64, opt EditIssueOption) (*Issue, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - issue := new(Issue) - return issue, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), - jsonHeader, bytes.NewReader(body), issue) -} - -// StartIssueStopWatch starts a stopwatch for an existing issue for a given -// repository -func (c *Client) StartIssueStopWatch(owner, repo string, index int64) error { - _, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/stopwatch/start", owner, repo, index), - jsonHeader, nil) - return err -} - -// StopIssueStopWatch stops an existing stopwatch for an issue in a given -// repository -func (c *Client) StopIssueStopWatch(owner, repo string, index int64) error { - _, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/stopwatch/stop", owner, repo, index), - jsonHeader, nil) - return err -} - // EditDeadlineOption options for creating a deadline type EditDeadlineOption struct { // required:true diff --git a/modules/structs/issue_comment.go b/modules/structs/issue_comment.go new file mode 100644 index 000000000..185f3910e --- /dev/null +++ b/modules/structs/issue_comment.go @@ -0,0 +1,35 @@ +// Copyright 2016 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +import ( + "time" +) + +// Comment represents a comment on a commit or issue +type Comment struct { + ID int64 `json:"id"` + HTMLURL string `json:"html_url"` + PRURL string `json:"pull_request_url"` + IssueURL string `json:"issue_url"` + Poster *User `json:"user"` + Body string `json:"body"` + // swagger:strfmt date-time + Created time.Time `json:"created_at"` + // swagger:strfmt date-time + Updated time.Time `json:"updated_at"` +} + +// CreateIssueCommentOption options for creating a comment on an issue +type CreateIssueCommentOption struct { + // required:true + Body string `json:"body" binding:"Required"` +} + +// EditIssueCommentOption options for editing a comment +type EditIssueCommentOption struct { + // required: true + Body string `json:"body" binding:"Required"` +} diff --git a/modules/structs/issue_label.go b/modules/structs/issue_label.go new file mode 100644 index 000000000..f0821fbaf --- /dev/null +++ b/modules/structs/issue_label.go @@ -0,0 +1,36 @@ +// Copyright 2016 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +// Label a label to an issue or a pr +// swagger:model +type Label struct { + ID int64 `json:"id"` + Name string `json:"name"` + // example: 00aabb + Color string `json:"color"` + URL string `json:"url"` +} + +// CreateLabelOption options for creating a label +type CreateLabelOption struct { + // required:true + Name string `json:"name" binding:"Required"` + // required:true + // example: #00aabb + Color string `json:"color" binding:"Required;Size(7)"` +} + +// EditLabelOption options for editing a label +type EditLabelOption struct { + Name *string `json:"name"` + Color *string `json:"color"` +} + +// IssueLabelsOption a collection of labels +type IssueLabelsOption struct { + // list of label IDs + Labels []int64 `json:"labels"` +} diff --git a/modules/structs/issue_milestone.go b/modules/structs/issue_milestone.go new file mode 100644 index 000000000..2bfdcd6bf --- /dev/null +++ b/modules/structs/issue_milestone.go @@ -0,0 +1,39 @@ +// Copyright 2016 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +import ( + "time" +) + +// Milestone milestone is a collection of issues on one repository +type Milestone struct { + ID int64 `json:"id"` + Title string `json:"title"` + Description string `json:"description"` + State StateType `json:"state"` + OpenIssues int `json:"open_issues"` + ClosedIssues int `json:"closed_issues"` + // swagger:strfmt date-time + Closed *time.Time `json:"closed_at"` + // swagger:strfmt date-time + Deadline *time.Time `json:"due_on"` +} + +// CreateMilestoneOption options for creating a milestone +type CreateMilestoneOption struct { + Title string `json:"title"` + Description string `json:"description"` + // swagger:strfmt date-time + Deadline *time.Time `json:"due_on"` +} + +// EditMilestoneOption options for editing a milestone +type EditMilestoneOption struct { + Title string `json:"title"` + Description *string `json:"description"` + State *string `json:"state"` + Deadline *time.Time `json:"due_on"` +} diff --git a/modules/structs/issue_tracked_time.go b/modules/structs/issue_tracked_time.go new file mode 100644 index 000000000..be90b3626 --- /dev/null +++ b/modules/structs/issue_tracked_time.go @@ -0,0 +1,30 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +import ( + "time" +) + +// TrackedTime worked time for an issue / pr +type TrackedTime struct { + ID int64 `json:"id"` + // swagger:strfmt date-time + Created time.Time `json:"created"` + // Time in seconds + Time int64 `json:"time"` + UserID int64 `json:"user_id"` + IssueID int64 `json:"issue_id"` +} + +// TrackedTimes represent a list of tracked times +type TrackedTimes []*TrackedTime + +// AddTimeOption options for adding time to an issue +type AddTimeOption struct { + // time in seconds + // required: true + Time int64 `json:"time" binding:"Required"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/lfs_lock.go b/modules/structs/lfs_lock.go similarity index 99% rename from vendor/code.gitea.io/sdk/gitea/lfs_lock.go rename to modules/structs/lfs_lock.go index 356636a3a..370910631 100644 --- a/vendor/code.gitea.io/sdk/gitea/lfs_lock.go +++ b/modules/structs/lfs_lock.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs import ( "time" diff --git a/vendor/code.gitea.io/sdk/gitea/miscellaneous.go b/modules/structs/miscellaneous.go similarity index 81% rename from vendor/code.gitea.io/sdk/gitea/miscellaneous.go rename to modules/structs/miscellaneous.go index 3735047b7..8eca90330 100644 --- a/vendor/code.gitea.io/sdk/gitea/miscellaneous.go +++ b/modules/structs/miscellaneous.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs // SearchResults results of a successful search type SearchResults struct { @@ -44,9 +44,3 @@ type MarkdownRender string type ServerVersion struct { Version string `json:"version"` } - -// ServerVersion returns the version of the server -func (c *Client) ServerVersion() (string, error) { - v := ServerVersion{} - return v.Version, c.getParsedResponse("GET", "/api/v1/version", nil, nil, &v) -} diff --git a/vendor/code.gitea.io/sdk/gitea/org.go b/modules/structs/org.go similarity index 53% rename from vendor/code.gitea.io/sdk/gitea/org.go rename to modules/structs/org.go index 0897da3ef..fd15da1ce 100644 --- a/vendor/code.gitea.io/sdk/gitea/org.go +++ b/modules/structs/org.go @@ -2,13 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) +package structs // Organization represents an organization type Organization struct { @@ -22,24 +16,6 @@ type Organization struct { Visibility VisibleType `json:"visibility"` } -// ListMyOrgs list all of current user's organizations -func (c *Client) ListMyOrgs() ([]*Organization, error) { - orgs := make([]*Organization, 0, 5) - return orgs, c.getParsedResponse("GET", "/user/orgs", nil, nil, &orgs) -} - -// ListUserOrgs list all of some user's organizations -func (c *Client) ListUserOrgs(user string) ([]*Organization, error) { - orgs := make([]*Organization, 0, 5) - return orgs, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/orgs", user), nil, nil, &orgs) -} - -// GetOrg get one organization by name -func (c *Client) GetOrg(orgname string) (*Organization, error) { - org := new(Organization) - return org, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s", orgname), nil, nil, org) -} - // CreateOrgOption options for creating an organization type CreateOrgOption struct { // required: true @@ -58,13 +34,3 @@ type EditOrgOption struct { Website string `json:"website"` Location string `json:"location"` } - -// EditOrg modify one organization via options -func (c *Client) EditOrg(orgname string, opt EditOrgOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PATCH", fmt.Sprintf("/orgs/%s", orgname), jsonHeader, bytes.NewReader(body)) - return err -} diff --git a/modules/structs/org_member.go b/modules/structs/org_member.go new file mode 100644 index 000000000..3b2a8b599 --- /dev/null +++ b/modules/structs/org_member.go @@ -0,0 +1,10 @@ +// Copyright 2016 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +// AddOrgMembershipOption add user to organization options +type AddOrgMembershipOption struct { + Role string `json:"role" binding:"Required"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/org_team.go b/modules/structs/org_team.go similarity index 98% rename from vendor/code.gitea.io/sdk/gitea/org_team.go rename to modules/structs/org_team.go index 9de0a8d00..b8b509022 100644 --- a/vendor/code.gitea.io/sdk/gitea/org_team.go +++ b/modules/structs/org_team.go @@ -3,7 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs // Team represents a team in an organization type Team struct { diff --git a/vendor/code.gitea.io/sdk/gitea/pull.go b/modules/structs/pull.go similarity index 57% rename from vendor/code.gitea.io/sdk/gitea/pull.go rename to modules/structs/pull.go index 6fcdd1d41..722d245af 100644 --- a/vendor/code.gitea.io/sdk/gitea/pull.go +++ b/modules/structs/pull.go @@ -2,12 +2,9 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs import ( - "bytes" - "encoding/json" - "fmt" "time" ) @@ -67,22 +64,6 @@ type ListPullRequestsOptions struct { State string `json:"state"` } -// ListRepoPullRequests list PRs of one repository -func (c *Client) ListRepoPullRequests(owner, repo string, opt ListPullRequestsOptions) ([]*PullRequest, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - prs := make([]*PullRequest, 0, 10) - return prs, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/pulls", owner, repo), jsonHeader, bytes.NewReader(body), &prs) -} - -// GetPullRequest get information of one PR -func (c *Client) GetPullRequest(owner, repo string, index int64) (*PullRequest, error) { - pr := new(PullRequest) - return pr, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/pulls/%d", owner, repo, index), nil, nil, pr) -} - // CreatePullRequestOption options when creating a pull request type CreatePullRequestOption struct { Head string `json:"head" binding:"Required"` @@ -97,17 +78,6 @@ type CreatePullRequestOption struct { Deadline *time.Time `json:"due_date"` } -// CreatePullRequest create pull request with options -func (c *Client) CreatePullRequest(owner, repo string, opt CreatePullRequestOption) (*PullRequest, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - pr := new(PullRequest) - return pr, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/pulls", owner, repo), - jsonHeader, bytes.NewReader(body), pr) -} - // EditPullRequestOption options when modify pull request type EditPullRequestOption struct { Title string `json:"title"` @@ -120,32 +90,3 @@ type EditPullRequestOption struct { // swagger:strfmt date-time Deadline *time.Time `json:"due_date"` } - -// EditPullRequest modify pull request with PR id and options -func (c *Client) EditPullRequest(owner, repo string, index int64, opt EditPullRequestOption) (*PullRequest, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - pr := new(PullRequest) - return pr, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), - jsonHeader, bytes.NewReader(body), pr) -} - -// MergePullRequest merge a PR to repository by PR id -func (c *Client) MergePullRequest(owner, repo string, index int64) error { - _, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", owner, repo, index), nil, nil) - return err -} - -// IsPullRequestMerged test if one PR is merged to one repository -func (c *Client) IsPullRequestMerged(owner, repo string, index int64) (bool, error) { - statusCode, err := c.getStatusCode("GET", fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", owner, repo, index), nil, nil) - - if err != nil { - return false, err - } - - return statusCode == 204, nil - -} diff --git a/modules/structs/release.go b/modules/structs/release.go new file mode 100644 index 000000000..b7575af39 --- /dev/null +++ b/modules/structs/release.go @@ -0,0 +1,50 @@ +// Copyright 2016 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +import ( + "time" +) + +// Release represents a repository release +type Release struct { + ID int64 `json:"id"` + TagName string `json:"tag_name"` + Target string `json:"target_commitish"` + Title string `json:"name"` + Note string `json:"body"` + URL string `json:"url"` + TarURL string `json:"tarball_url"` + ZipURL string `json:"zipball_url"` + IsDraft bool `json:"draft"` + IsPrerelease bool `json:"prerelease"` + // swagger:strfmt date-time + CreatedAt time.Time `json:"created_at"` + // swagger:strfmt date-time + PublishedAt time.Time `json:"published_at"` + Publisher *User `json:"author"` + Attachments []*Attachment `json:"assets"` +} + +// CreateReleaseOption options when creating a release +type CreateReleaseOption struct { + // required: true + TagName string `json:"tag_name" binding:"Required"` + Target string `json:"target_commitish"` + Title string `json:"name"` + Note string `json:"body"` + IsDraft bool `json:"draft"` + IsPrerelease bool `json:"prerelease"` +} + +// EditReleaseOption options when editing a release +type EditReleaseOption struct { + TagName string `json:"tag_name"` + Target string `json:"target_commitish"` + Title string `json:"name"` + Note string `json:"body"` + IsDraft *bool `json:"draft"` + IsPrerelease *bool `json:"prerelease"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/repo.go b/modules/structs/repo.go similarity index 50% rename from vendor/code.gitea.io/sdk/gitea/repo.go rename to modules/structs/repo.go index 8b7c0b1e6..b5283beea 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo.go +++ b/modules/structs/repo.go @@ -2,12 +2,9 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs import ( - "bytes" - "encoding/json" - "fmt" "time" ) @@ -48,24 +45,6 @@ type Repository struct { Permissions *Permission `json:"permissions,omitempty"` } -// ListMyRepos lists all repositories for the authenticated user that has access to. -func (c *Client) ListMyRepos() ([]*Repository, error) { - repos := make([]*Repository, 0, 10) - return repos, c.getParsedResponse("GET", "/user/repos", nil, nil, &repos) -} - -// ListUserRepos list all repositories of one user by user's name -func (c *Client) ListUserRepos(user string) ([]*Repository, error) { - repos := make([]*Repository, 0, 10) - return repos, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/repos", user), nil, nil, &repos) -} - -// ListOrgRepos list all repositories of one organization by organization's name -func (c *Client) ListOrgRepos(org string) ([]*Repository, error) { - repos := make([]*Repository, 0, 10) - return repos, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/repos", org), nil, nil, &repos) -} - // CreateRepoOption options when creating repository // swagger:model type CreateRepoOption struct { @@ -88,36 +67,42 @@ type CreateRepoOption struct { Readme string `json:"readme"` } -// CreateRepo creates a repository for authenticated user. -func (c *Client) CreateRepo(opt CreateRepoOption) (*Repository, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - repo := new(Repository) - return repo, c.getParsedResponse("POST", "/user/repos", jsonHeader, bytes.NewReader(body), repo) -} - -// CreateOrgRepo creates an organization repository for authenticated user. -func (c *Client) CreateOrgRepo(org string, opt CreateRepoOption) (*Repository, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - repo := new(Repository) - return repo, c.getParsedResponse("POST", fmt.Sprintf("/org/%s/repos", org), jsonHeader, bytes.NewReader(body), repo) -} - -// GetRepo returns information of a repository of given owner. -func (c *Client) GetRepo(owner, reponame string) (*Repository, error) { - repo := new(Repository) - return repo, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s", owner, reponame), nil, nil, repo) -} - -// DeleteRepo deletes a repository of user or organization. -func (c *Client) DeleteRepo(owner, repo string) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s", owner, repo), nil, nil) - return err +// EditRepoOption options when editing a repository's properties +// swagger:model +type EditRepoOption struct { + // Name of the repository + // + // required: true + // unique: true + Name *string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"` + // A short description of the repository. + Description *string `json:"description,omitempty" binding:"MaxSize(255)"` + // A URL with more information about the repository. + Website *string `json:"website,omitempty" binding:"MaxSize(255)"` + // Either `true` to make the repository private or `false` to make it public. + // 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. + Private *bool `json:"private,omitempty"` + // Either `true` to enable issues for this repository or `false` to disable them. + EnableIssues *bool `json:"enable_issues,omitempty"` + // Either `true` to enable the wiki for this repository or `false` to disable it. + EnableWiki *bool `json:"enable_wiki,omitempty"` + // Updates the default branch for this repository. + DefaultBranch *string `json:"default_branch,omitempty"` + // Either `true` to allow pull requests, or `false` to prevent pull request. + EnablePullRequests *bool `json:"enable_pull_requests,omitempty"` + // Either `true` to ignore whitepace for conflicts, or `false` to not ignore whitespace. `enabled_pull_requests` must be `true`. + IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace,omitempty"` + // Either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. `enabled_pull_requests` must be `true`. + AllowMerge *bool `json:"allow_merge_commits,omitempty"` + // Either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. `enabled_pull_requests` must be `true`. + AllowRebase *bool `json:"allow_rebase,omitempty"` + // Either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits. `enabled_pull_requests` must be `true`. + AllowRebaseMerge *bool `json:"allow_rebase_explicit,omitempty"` + // Either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. `enabled_pull_requests` must be `true`. + AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` + // `true` to archive this repository. Note: You cannot unarchive repositories through the API. + Archived *bool `json:"archived,omitempty"` } // MigrateRepoOption options for migrating a repository from an external service @@ -134,23 +119,3 @@ type MigrateRepoOption struct { Private bool `json:"private"` Description string `json:"description"` } - -// MigrateRepo migrates a repository from other Git hosting sources for the -// authenticated user. -// -// To migrate a repository for a organization, the authenticated user must be a -// owner of the specified organization. -func (c *Client) MigrateRepo(opt MigrateRepoOption) (*Repository, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - repo := new(Repository) - return repo, c.getParsedResponse("POST", "/repos/migrate", jsonHeader, bytes.NewReader(body), repo) -} - -// MirrorSync adds a mirrored repository to the mirror sync queue. -func (c *Client) MirrorSync(owner, repo string) error { - _, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/mirror-sync", owner, repo), nil, nil) - return err -} diff --git a/modules/structs/repo_branch.go b/modules/structs/repo_branch.go new file mode 100644 index 000000000..a6ae6c166 --- /dev/null +++ b/modules/structs/repo_branch.go @@ -0,0 +1,11 @@ +// Copyright 2016 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +// Branch represents a repository branch +type Branch struct { + Name string `json:"name"` + Commit *PayloadCommit `json:"commit"` +} diff --git a/modules/structs/repo_collaborator.go b/modules/structs/repo_collaborator.go new file mode 100644 index 000000000..2b4fa390d --- /dev/null +++ b/modules/structs/repo_collaborator.go @@ -0,0 +1,10 @@ +// Copyright 2016 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +// AddCollaboratorOption options when adding a user as a collaborator of a repository +type AddCollaboratorOption struct { + Permission *string `json:"permission"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_commit.go b/modules/structs/repo_commit.go similarity index 81% rename from vendor/code.gitea.io/sdk/gitea/repo_commit.go rename to modules/structs/repo_commit.go index 1df66428a..9cde2873d 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_commit.go +++ b/modules/structs/repo_commit.go @@ -3,11 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea - -import ( - "fmt" -) +package structs // Identity for a person's identity like an author or committer type Identity struct { @@ -46,9 +42,3 @@ type Commit struct { Committer *User `json:"committer"` Parents []*CommitMeta `json:"parents"` } - -// GetSingleCommit returns a single commit -func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, error) { - commit := new(Commit) - return commit, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/commits/%s", user, repo, commitID), nil, nil, &commit) -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_file.go b/modules/structs/repo_file.go similarity index 88% rename from vendor/code.gitea.io/sdk/gitea/repo_file.go rename to modules/structs/repo_file.go index 1e9e45ec2..ac8b9333f 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_file.go +++ b/modules/structs/repo_file.go @@ -3,17 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea - -import ( - "fmt" -) - -// GetFile downloads a file of repository, ref can be branch/tag/commit. -// e.g.: ref -> master, tree -> macaron.go(no leading slash) -func (c *Client) GetFile(user, repo, ref, tree string) ([]byte, error) { - return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/raw/%s/%s", user, repo, ref, tree), nil, nil) -} +package structs // FileOptions options for all file APIs type FileOptions struct { diff --git a/modules/structs/repo_key.go b/modules/structs/repo_key.go new file mode 100644 index 000000000..29928bd97 --- /dev/null +++ b/modules/structs/repo_key.go @@ -0,0 +1,41 @@ +// Copyright 2015 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +import ( + "time" +) + +// DeployKey a deploy key +type DeployKey struct { + ID int64 `json:"id"` + KeyID int64 `json:"key_id"` + Key string `json:"key"` + URL string `json:"url"` + Title string `json:"title"` + Fingerprint string `json:"fingerprint"` + // swagger:strfmt date-time + Created time.Time `json:"created_at"` + ReadOnly bool `json:"read_only"` + Repository *Repository `json:"repository,omitempty"` +} + +// CreateKeyOption options when creating a key +type CreateKeyOption struct { + // Title of the key to add + // + // required: true + // unique: true + Title string `json:"title" binding:"Required"` + // An armored SSH key to add + // + // required: true + // unique: true + Key string `json:"key" binding:"Required"` + // Describe if the key has only read access or read/write + // + // required: false + ReadOnly bool `json:"read_only"` +} diff --git a/modules/structs/repo_refs.go b/modules/structs/repo_refs.go new file mode 100644 index 000000000..0bf4b94ae --- /dev/null +++ b/modules/structs/repo_refs.go @@ -0,0 +1,19 @@ +// Copyright 2018 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +// Reference represents a Git reference. +type Reference struct { + Ref string `json:"ref"` + URL string `json:"url"` + Object *GitObject `json:"object"` +} + +// GitObject represents a Git object. +type GitObject struct { + Type string `json:"type"` + SHA string `json:"sha"` + URL string `json:"url"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_tag.go b/modules/structs/repo_tag.go similarity index 58% rename from vendor/code.gitea.io/sdk/gitea/repo_tag.go rename to modules/structs/repo_tag.go index 27efe8da2..6294a8099 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_tag.go +++ b/modules/structs/repo_tag.go @@ -2,11 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea - -import ( - "fmt" -) +package structs // Tag represents a repository tag type Tag struct { @@ -18,9 +14,3 @@ type Tag struct { ZipballURL string `json:"zipball_url"` TarballURL string `json:"tarball_url"` } - -// ListRepoTags list all the branches of one repository -func (c *Client) ListRepoTags(user, repo string) ([]*Tag, error) { - tags := make([]*Tag, 0, 10) - return tags, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/tags", user, repo), nil, nil, &tags) -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_tree.go b/modules/structs/repo_tree.go similarity index 58% rename from vendor/code.gitea.io/sdk/gitea/repo_tree.go rename to modules/structs/repo_tree.go index 842ab9b43..58aa3b833 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_tree.go +++ b/modules/structs/repo_tree.go @@ -2,11 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea - -import ( - "fmt" -) +package structs // GitEntry represents a git tree type GitEntry struct { @@ -27,15 +23,3 @@ type GitTreeResponse struct { Page int `json:"page"` TotalCount int `json:"total_count"` } - -// GetTrees downloads a file of repository, ref can be branch/tag/commit. -// e.g.: ref -> master, tree -> macaron.go(no leading slash) -func (c *Client) GetTrees(user, repo, ref string, recursive bool) (*GitTreeResponse, error) { - var trees GitTreeResponse - var path = fmt.Sprintf("/repos/%s/%s/git/trees/%s", user, repo, ref) - if recursive { - path += "?recursive=1" - } - err := c.getParsedResponse("GET", path, nil, nil, &trees) - return &trees, err -} diff --git a/modules/structs/repo_watch.go b/modules/structs/repo_watch.go new file mode 100644 index 000000000..606785a4f --- /dev/null +++ b/modules/structs/repo_watch.go @@ -0,0 +1,19 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +import ( + "time" +) + +// WatchInfo represents an API watch status of one repository +type WatchInfo struct { + Subscribed bool `json:"subscribed"` + Ignored bool `json:"ignored"` + Reason interface{} `json:"reason"` + CreatedAt time.Time `json:"created_at"` + URL string `json:"url"` + RepositoryURL string `json:"repository_url"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/status.go b/modules/structs/status.go similarity index 62% rename from vendor/code.gitea.io/sdk/gitea/status.go rename to modules/structs/status.go index 3060ab1b2..e833bd69e 100644 --- a/vendor/code.gitea.io/sdk/gitea/status.go +++ b/modules/structs/status.go @@ -2,12 +2,9 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs import ( - "bytes" - "encoding/json" - "fmt" "time" ) @@ -66,32 +63,3 @@ type CreateStatusOption struct { type ListStatusesOption struct { Page int } - -// CreateStatus creates a new Status for a given Commit -// -// POST /repos/:owner/:repo/statuses/:sha -func (c *Client) CreateStatus(owner, repo, sha string, opts CreateStatusOption) (*Status, error) { - body, err := json.Marshal(&opts) - if err != nil { - return nil, err - } - status := &Status{} - return status, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/statuses/%s", owner, repo, sha), - jsonHeader, bytes.NewReader(body), status) -} - -// ListStatuses returns all statuses for a given Commit -// -// GET /repos/:owner/:repo/commits/:ref/statuses -func (c *Client) ListStatuses(owner, repo, sha string, opts ListStatusesOption) ([]*Status, error) { - statuses := make([]*Status, 0, 10) - return statuses, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/statuses?page=%d", owner, repo, sha, opts.Page), nil, nil, &statuses) -} - -// GetCombinedStatus returns the CombinedStatus for a given Commit -// -// GET /repos/:owner/:repo/commits/:ref/status -func (c *Client) GetCombinedStatus(owner, repo, sha string) (*CombinedStatus, error) { - status := &CombinedStatus{} - return status, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/status", owner, repo, sha), nil, nil, status) -} diff --git a/vendor/code.gitea.io/sdk/gitea/user.go b/modules/structs/user.go similarity index 69% rename from vendor/code.gitea.io/sdk/gitea/user.go rename to modules/structs/user.go index 42d9b983e..251c80312 100644 --- a/vendor/code.gitea.io/sdk/gitea/user.go +++ b/modules/structs/user.go @@ -2,11 +2,10 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs import ( "encoding/json" - "fmt" ) // User represents a user @@ -37,17 +36,3 @@ func (u User) MarshalJSON() ([]byte, error) { CompatUserName string `json:"username"` }{shadow(u), u.UserName}) } - -// GetUserInfo get user info by user's name -func (c *Client) GetUserInfo(user string) (*User, error) { - u := new(User) - err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s", user), nil, nil, u) - return u, err -} - -// GetMyUserInfo get user info of current user -func (c *Client) GetMyUserInfo() (*User, error) { - u := new(User) - err := c.getParsedResponse("GET", "/user", nil, nil, u) - return u, err -} diff --git a/modules/structs/user_app.go b/modules/structs/user_app.go new file mode 100644 index 000000000..934048668 --- /dev/null +++ b/modules/structs/user_app.go @@ -0,0 +1,34 @@ +// Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2019 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +import ( + "encoding/base64" +) + +// BasicAuthEncode generate base64 of basic auth head +func BasicAuthEncode(user, pass string) string { + return base64.StdEncoding.EncodeToString([]byte(user + ":" + pass)) +} + +// AccessToken represents an API access token. +// swagger:response AccessToken +type AccessToken struct { + ID int64 `json:"id"` + Name string `json:"name"` + Token string `json:"sha1"` + TokenLastEight string `json:"token_last_eight"` +} + +// AccessTokenList represents a list of API access token. +// swagger:response AccessTokenList +type AccessTokenList []*AccessToken + +// CreateAccessTokenOption options when create access token +// swagger:parameters userCreateToken +type CreateAccessTokenOption struct { + Name string `json:"name" binding:"Required"` +} diff --git a/modules/structs/user_email.go b/modules/structs/user_email.go new file mode 100644 index 000000000..a72b04119 --- /dev/null +++ b/modules/structs/user_email.go @@ -0,0 +1,25 @@ +// Copyright 2015 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +// Email an email address belonging to a user +type Email struct { + // swagger:strfmt email + Email string `json:"email"` + Verified bool `json:"verified"` + Primary bool `json:"primary"` +} + +// CreateEmailOption options when creating email addresses +type CreateEmailOption struct { + // email addresses to add + Emails []string `json:"emails"` +} + +// DeleteEmailOption options when deleting email addresses +type DeleteEmailOption struct { + // email addresses to delete + Emails []string `json:"emails"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go b/modules/structs/user_gpgkey.go similarity index 52% rename from vendor/code.gitea.io/sdk/gitea/user_gpgkey.go rename to modules/structs/user_gpgkey.go index 0817d8946..f501a09cb 100644 --- a/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go +++ b/modules/structs/user_gpgkey.go @@ -2,12 +2,9 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs import ( - "bytes" - "encoding/json" - "fmt" "time" ) @@ -44,37 +41,3 @@ type CreateGPGKeyOption struct { // unique: true ArmoredKey string `json:"armored_public_key" binding:"Required"` } - -// ListGPGKeys list all the GPG keys of the user -func (c *Client) ListGPGKeys(user string) ([]*GPGKey, error) { - keys := make([]*GPGKey, 0, 10) - return keys, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/gpg_keys", user), nil, nil, &keys) -} - -// ListMyGPGKeys list all the GPG keys of current user -func (c *Client) ListMyGPGKeys() ([]*GPGKey, error) { - keys := make([]*GPGKey, 0, 10) - return keys, c.getParsedResponse("GET", "/user/gpg_keys", nil, nil, &keys) -} - -// GetGPGKey get current user's GPG key by key id -func (c *Client) GetGPGKey(keyID int64) (*GPGKey, error) { - key := new(GPGKey) - return key, c.getParsedResponse("GET", fmt.Sprintf("/user/gpg_keys/%d", keyID), nil, nil, &key) -} - -// CreateGPGKey create GPG key with options -func (c *Client) CreateGPGKey(opt CreateGPGKeyOption) (*GPGKey, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - key := new(GPGKey) - return key, c.getParsedResponse("POST", "/user/gpg_keys", jsonHeader, bytes.NewReader(body), key) -} - -// DeleteGPGKey delete GPG key with key id -func (c *Client) DeleteGPGKey(keyID int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/user/gpg_keys/%d", keyID), nil, nil) - return err -} diff --git a/modules/structs/user_key.go b/modules/structs/user_key.go new file mode 100644 index 000000000..ee487607c --- /dev/null +++ b/modules/structs/user_key.go @@ -0,0 +1,23 @@ +// Copyright 2015 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package structs + +import ( + "time" +) + +// PublicKey publickey is a user key to push code to repository +type PublicKey struct { + ID int64 `json:"id"` + Key string `json:"key"` + URL string `json:"url,omitempty"` + Title string `json:"title,omitempty"` + Fingerprint string `json:"fingerprint,omitempty"` + // swagger:strfmt date-time + Created time.Time `json:"created_at,omitempty"` + Owner *User `json:"user,omitempty"` + ReadOnly bool `json:"read_only,omitempty"` + KeyType string `json:"key_type,omitempty"` +} diff --git a/modules/structs/user_search.go b/modules/structs/user_search.go new file mode 100644 index 000000000..1650cf736 --- /dev/null +++ b/modules/structs/user_search.go @@ -0,0 +1,5 @@ +package structs + +type searchUsersResponse struct { + Users []*User `json:"data"` +} diff --git a/vendor/code.gitea.io/sdk/gitea/utils.go b/modules/structs/utils.go similarity index 96% rename from vendor/code.gitea.io/sdk/gitea/utils.go rename to modules/structs/utils.go index 80892a1e7..1b9d68956 100644 --- a/vendor/code.gitea.io/sdk/gitea/utils.go +++ b/modules/structs/utils.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package gitea +package structs import ( "net/http" diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 03263a86d..fba41a8cf 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -6,7 +6,7 @@ package admin import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/admin/repo.go b/routers/api/v1/admin/repo.go index d883e2cbd..aaa7957a5 100644 --- a/routers/api/v1/admin/repo.go +++ b/routers/api/v1/admin/repo.go @@ -5,7 +5,7 @@ package admin import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/routers/api/v1/repo" diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 0c7088151..6dc3b0325 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -10,9 +10,9 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/routers/api/v1/convert" "code.gitea.io/gitea/routers/api/v1/user" - api "code.gitea.io/sdk/gitea" ) func parseLoginSource(ctx *context.APIContext, u *models.User, sourceID int64, loginName string) { diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index b68bf4b0b..dfe705f7a 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -65,13 +65,13 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/routers/api/v1/admin" "code.gitea.io/gitea/routers/api/v1/misc" "code.gitea.io/gitea/routers/api/v1/org" "code.gitea.io/gitea/routers/api/v1/repo" _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation "code.gitea.io/gitea/routers/api/v1/user" - api "code.gitea.io/sdk/gitea" "github.com/go-macaron/binding" "gopkg.in/macaron.v1" diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go index f132dedb5..74fd9b3af 100644 --- a/routers/api/v1/convert/convert.go +++ b/routers/api/v1/convert/convert.go @@ -11,8 +11,8 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/Unknwon/com" ) diff --git a/routers/api/v1/misc/markdown.go b/routers/api/v1/misc/markdown.go index 9ae7a6c58..06e344a15 100644 --- a/routers/api/v1/misc/markdown.go +++ b/routers/api/v1/misc/markdown.go @@ -7,7 +7,7 @@ package misc import ( "strings" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/markup/markdown" diff --git a/routers/api/v1/misc/markdown_test.go b/routers/api/v1/misc/markdown_test.go index 9de1f77f6..6cb6b92f9 100644 --- a/routers/api/v1/misc/markdown_test.go +++ b/routers/api/v1/misc/markdown_test.go @@ -10,8 +10,8 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" "github.com/go-macaron/inject" "github.com/stretchr/testify/assert" diff --git a/routers/api/v1/misc/version.go b/routers/api/v1/misc/version.go index 20e0a60c7..803f5ac71 100644 --- a/routers/api/v1/misc/version.go +++ b/routers/api/v1/misc/version.go @@ -7,7 +7,7 @@ package misc import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" - "code.gitea.io/sdk/gitea" + "code.gitea.io/gitea/modules/structs" ) // Version shows the version of the Gitea server @@ -20,5 +20,5 @@ func Version(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ServerVersion" - ctx.JSON(200, &gitea.ServerVersion{Version: setting.AppVer}) + ctx.JSON(200, &structs.ServerVersion{Version: setting.AppVer}) } diff --git a/routers/api/v1/org/hook.go b/routers/api/v1/org/hook.go index 5825de2c1..128cfec32 100644 --- a/routers/api/v1/org/hook.go +++ b/routers/api/v1/org/hook.go @@ -5,7 +5,7 @@ package org import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/org/member.go b/routers/api/v1/org/member.go index 33c906ec6..ad60dfbda 100644 --- a/routers/api/v1/org/member.go +++ b/routers/api/v1/org/member.go @@ -7,7 +7,7 @@ package org import ( "fmt" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index e3916046f..e1d0663f0 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -6,7 +6,7 @@ package org import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index 340dd96c7..40b6e008b 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -6,7 +6,7 @@ package org import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go index b9a23d3b5..1aaae8723 100644 --- a/routers/api/v1/repo/branch.go +++ b/routers/api/v1/repo/branch.go @@ -10,7 +10,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/routers/api/v1/convert" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // GetBranch get a branch of a repository diff --git a/routers/api/v1/repo/collaborators.go b/routers/api/v1/repo/collaborators.go index be4a65f9c..98daf2c9d 100644 --- a/routers/api/v1/repo/collaborators.go +++ b/routers/api/v1/repo/collaborators.go @@ -11,7 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // ListCollaborators list a repository's collaborators diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index d29f18853..3f3bd1326 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // GetSingleCommit get a commit via diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 10108e11c..db952263e 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -13,8 +13,8 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/repofiles" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/routers/repo" - api "code.gitea.io/sdk/gitea" ) // GetRawFile get a file by path on a repository diff --git a/routers/api/v1/repo/fork.go b/routers/api/v1/repo/fork.go index d10f66871..c004544f5 100644 --- a/routers/api/v1/repo/fork.go +++ b/routers/api/v1/repo/fork.go @@ -8,7 +8,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // ListForks list a repository's forks diff --git a/routers/api/v1/repo/git_hook.go b/routers/api/v1/repo/git_hook.go index b7a8691cd..80610356d 100644 --- a/routers/api/v1/repo/git_hook.go +++ b/routers/api/v1/repo/git_hook.go @@ -7,8 +7,8 @@ package repo import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/routers/api/v1/convert" - api "code.gitea.io/sdk/gitea" ) // ListGitHooks list all Git hooks of a repository diff --git a/routers/api/v1/repo/git_ref.go b/routers/api/v1/repo/git_ref.go index 6a6ed9ff3..2ec874905 100644 --- a/routers/api/v1/repo/git_ref.go +++ b/routers/api/v1/repo/git_ref.go @@ -7,7 +7,7 @@ package repo import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // GetGitAllRefs get ref or an list all the refs of a repository diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index ef9d5ac1d..b35a10ac3 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -8,9 +8,9 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/routers/api/v1/convert" "code.gitea.io/gitea/routers/api/v1/utils" - api "code.gitea.io/sdk/gitea" ) // ListHooks list all hooks of a repository diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index c14fc78ee..daaa3d598 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -18,7 +18,7 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // ListIssues list the issues of a repository diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go index 7a720deab..14e81222e 100644 --- a/routers/api/v1/repo/issue_comment.go +++ b/routers/api/v1/repo/issue_comment.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/notification" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // ListIssueComments list all the comments of an issue diff --git a/routers/api/v1/repo/issue_label.go b/routers/api/v1/repo/issue_label.go index 4c8ca8d52..7c22e6885 100644 --- a/routers/api/v1/repo/issue_label.go +++ b/routers/api/v1/repo/issue_label.go @@ -9,7 +9,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // ListIssueLabels list all the labels of an issue diff --git a/routers/api/v1/repo/issue_tracked_time.go b/routers/api/v1/repo/issue_tracked_time.go index d2ddb0e0c..194f7d32c 100644 --- a/routers/api/v1/repo/issue_tracked_time.go +++ b/routers/api/v1/repo/issue_tracked_time.go @@ -8,7 +8,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) func trackedTimesToAPIFormat(trackedTimes []*models.TrackedTime) []*api.TrackedTime { diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go index e26ce8cf5..59782d05f 100644 --- a/routers/api/v1/repo/key.go +++ b/routers/api/v1/repo/key.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers/api/v1/convert" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // appendPrivateInformation appends the owner and key type information to api.PublicKey diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go index f61751f3a..1cd8890ca 100644 --- a/routers/api/v1/repo/label.go +++ b/routers/api/v1/repo/label.go @@ -11,7 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // ListLabels list all the labels of a repository diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go index a76f601a2..1d0109330 100644 --- a/routers/api/v1/repo/milestone.go +++ b/routers/api/v1/repo/milestone.go @@ -11,7 +11,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // ListMilestones list all the opened milestones for a repository diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index ab8a85b64..dda838791 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -15,8 +15,8 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/notification" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - api "code.gitea.io/sdk/gitea" ) // ListPullRequests returns a list of all PRs diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go index 1b5b19666..0fdcfa355 100644 --- a/routers/api/v1/repo/release.go +++ b/routers/api/v1/repo/release.go @@ -9,7 +9,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // GetRelease get a single release of a repository diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go index 5efdd6981..f85787bc5 100644 --- a/routers/api/v1/repo/release_attachment.go +++ b/routers/api/v1/repo/release_attachment.go @@ -13,7 +13,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // GetReleaseAttachment gets a single attachment of the release diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 35fea20d4..56aac8014 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -19,7 +19,7 @@ import ( "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/routers/api/v1/convert" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) var searchOrderByMap = map[string]map[string]models.SearchOrderBy{ diff --git a/routers/api/v1/repo/star.go b/routers/api/v1/repo/star.go index df4241dde..046142252 100644 --- a/routers/api/v1/repo/star.go +++ b/routers/api/v1/repo/star.go @@ -7,7 +7,7 @@ package repo import ( "code.gitea.io/gitea/modules/context" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // ListStargazers list a repository's stargazers diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go index da2b459c2..487e62c91 100644 --- a/routers/api/v1/repo/status.go +++ b/routers/api/v1/repo/status.go @@ -10,7 +10,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // NewCommitStatus creates a new CommitStatus diff --git a/routers/api/v1/repo/subscriber.go b/routers/api/v1/repo/subscriber.go index a3d5e2a27..b7d329dc7 100644 --- a/routers/api/v1/repo/subscriber.go +++ b/routers/api/v1/repo/subscriber.go @@ -7,7 +7,7 @@ package repo import ( "code.gitea.io/gitea/modules/context" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // ListSubscribers list a repo's subscribers (i.e. watchers) diff --git a/routers/api/v1/repo/tag.go b/routers/api/v1/repo/tag.go index 505f5b40c..dd1b5aa7c 100644 --- a/routers/api/v1/repo/tag.go +++ b/routers/api/v1/repo/tag.go @@ -8,7 +8,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/routers/api/v1/convert" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // ListTags list all the tags of a repository diff --git a/routers/api/v1/swagger/issue.go b/routers/api/v1/swagger/issue.go index 16711e9b7..c06186bf6 100644 --- a/routers/api/v1/swagger/issue.go +++ b/routers/api/v1/swagger/issue.go @@ -5,7 +5,7 @@ package swagger import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // Issue diff --git a/routers/api/v1/swagger/key.go b/routers/api/v1/swagger/key.go index b24783238..c3da37af6 100644 --- a/routers/api/v1/swagger/key.go +++ b/routers/api/v1/swagger/key.go @@ -5,7 +5,7 @@ package swagger import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // PublicKey diff --git a/routers/api/v1/swagger/misc.go b/routers/api/v1/swagger/misc.go index c28ba02db..9fd0ab5b0 100644 --- a/routers/api/v1/swagger/misc.go +++ b/routers/api/v1/swagger/misc.go @@ -5,7 +5,7 @@ package swagger import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // ServerVersion diff --git a/routers/api/v1/swagger/options.go b/routers/api/v1/swagger/options.go index 83f7cfec8..2df97304a 100644 --- a/routers/api/v1/swagger/options.go +++ b/routers/api/v1/swagger/options.go @@ -6,7 +6,7 @@ package swagger import ( "code.gitea.io/gitea/modules/auth" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // not actually a response, just a hack to get go-swagger to include definitions diff --git a/routers/api/v1/swagger/org.go b/routers/api/v1/swagger/org.go index eb4a1084e..c962e7b18 100644 --- a/routers/api/v1/swagger/org.go +++ b/routers/api/v1/swagger/org.go @@ -5,7 +5,7 @@ package swagger import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // Organization diff --git a/routers/api/v1/swagger/repo.go b/routers/api/v1/swagger/repo.go index a23e670da..e7df0b8f7 100644 --- a/routers/api/v1/swagger/repo.go +++ b/routers/api/v1/swagger/repo.go @@ -5,7 +5,7 @@ package swagger import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // Repository diff --git a/routers/api/v1/swagger/user.go b/routers/api/v1/swagger/user.go index caaf7df70..a2df40e4c 100644 --- a/routers/api/v1/swagger/user.go +++ b/routers/api/v1/swagger/user.go @@ -6,7 +6,7 @@ package swagger import ( "code.gitea.io/gitea/models" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // User diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go index d9716f419..c090a724b 100644 --- a/routers/api/v1/user/app.go +++ b/routers/api/v1/user/app.go @@ -6,7 +6,7 @@ package user import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go index 1d071e697..67659cfb0 100644 --- a/routers/api/v1/user/email.go +++ b/routers/api/v1/user/email.go @@ -5,7 +5,7 @@ package user import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/user/follower.go b/routers/api/v1/user/follower.go index c2f0c6e65..453f73137 100644 --- a/routers/api/v1/user/follower.go +++ b/routers/api/v1/user/follower.go @@ -5,7 +5,7 @@ package user import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/user/gpg_key.go b/routers/api/v1/user/gpg_key.go index 9d6579e41..c2c55e9b9 100644 --- a/routers/api/v1/user/gpg_key.go +++ b/routers/api/v1/user/gpg_key.go @@ -5,7 +5,7 @@ package user import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go index 8e0cde053..286f9ae4c 100644 --- a/routers/api/v1/user/key.go +++ b/routers/api/v1/user/key.go @@ -5,7 +5,7 @@ package user import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/user/repo.go b/routers/api/v1/user/repo.go index 1ddb3bd57..584816908 100644 --- a/routers/api/v1/user/repo.go +++ b/routers/api/v1/user/repo.go @@ -7,7 +7,7 @@ package user import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" ) // listUserRepos - List the repositories owned by the given user. diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go index 62c820f8f..e5eec71b6 100644 --- a/routers/api/v1/user/star.go +++ b/routers/api/v1/user/star.go @@ -5,7 +5,7 @@ package user import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index 76b4fc8dc..8d05a6718 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -10,8 +10,8 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/routers/api/v1/convert" - api "code.gitea.io/sdk/gitea" "github.com/Unknwon/com" ) diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go index 2ce0be2ff..f0eb95ac1 100644 --- a/routers/api/v1/user/watch.go +++ b/routers/api/v1/user/watch.go @@ -5,7 +5,7 @@ package user import ( - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" diff --git a/routers/api/v1/utils/hook.go b/routers/api/v1/utils/hook.go index f0c6b91a1..da15850ec 100644 --- a/routers/api/v1/utils/hook.go +++ b/routers/api/v1/utils/hook.go @@ -11,9 +11,9 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" + api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/routers/api/v1/convert" "code.gitea.io/gitea/routers/utils" - api "code.gitea.io/sdk/gitea" "github.com/Unknwon/com" ) diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 2e76cbfe0..7695f208c 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -18,7 +18,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/sdk/gitea" + api "code.gitea.io/gitea/modules/structs" "github.com/Unknwon/com" ) diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 198c18919..0752e7be2 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -6673,7 +6673,7 @@ "x-go-name": "Permission" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "AddTimeOption": { "description": "AddTimeOption options for adding time to an issue", @@ -6689,7 +6689,7 @@ "x-go-name": "Time" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Attachment": { "description": "Attachment a generic attachment", @@ -6728,7 +6728,7 @@ "x-go-name": "UUID" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Branch": { "description": "Branch represents a repository branch", @@ -6742,7 +6742,7 @@ "x-go-name": "Name" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Comment": { "description": "Comment represents a comment on a commit or issue", @@ -6783,7 +6783,7 @@ "$ref": "#/definitions/User" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Commit": { "type": "object", @@ -6818,7 +6818,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CommitMeta": { "type": "object", @@ -6833,7 +6833,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CommitUser": { "type": "object", @@ -6853,7 +6853,7 @@ "x-go-name": "Name" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateEmailOption": { "description": "CreateEmailOption options when creating email addresses", @@ -6868,7 +6868,7 @@ "x-go-name": "Emails" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateFileOptions": { "description": "CreateFileOptions options for creating files", @@ -6897,7 +6897,7 @@ "x-go-name": "NewBranchName" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateForkOption": { "description": "CreateForkOption options for creating a fork", @@ -6909,7 +6909,7 @@ "x-go-name": "Organization" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateGPGKeyOption": { "description": "CreateGPGKeyOption options create user GPG key", @@ -6925,7 +6925,7 @@ "x-go-name": "ArmoredKey" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateHookOption": { "description": "CreateHookOption options when create a hook", @@ -6965,7 +6965,7 @@ "x-go-name": "Type" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateIssueCommentOption": { "description": "CreateIssueCommentOption options for creating a comment on an issue", @@ -6979,7 +6979,7 @@ "x-go-name": "Body" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateIssueOption": { "description": "CreateIssueOption options to create one issue", @@ -7033,7 +7033,7 @@ "x-go-name": "Title" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateKeyOption": { "description": "CreateKeyOption options when creating a key", @@ -7061,7 +7061,7 @@ "x-go-name": "Title" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateLabelOption": { "description": "CreateLabelOption options for creating a label", @@ -7081,7 +7081,7 @@ "x-go-name": "Name" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateMilestoneOption": { "description": "CreateMilestoneOption options for creating a milestone", @@ -7101,7 +7101,7 @@ "x-go-name": "Title" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateOrgOption": { "description": "CreateOrgOption options for creating an organization", @@ -7134,7 +7134,7 @@ "x-go-name": "Website" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreatePullRequestOption": { "description": "CreatePullRequestOption options when creating a pull request", @@ -7186,7 +7186,7 @@ "x-go-name": "Title" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateReleaseOption": { "description": "CreateReleaseOption options when creating a release", @@ -7220,7 +7220,7 @@ "x-go-name": "Target" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateRepoOption": { "description": "CreateRepoOption options when creating repository", @@ -7266,7 +7266,7 @@ "x-go-name": "Readme" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateStatusOption": { "description": "CreateStatusOption holds the information needed to create a new Status for a Commit", @@ -7288,7 +7288,7 @@ "x-go-name": "TargetURL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateTeamOption": { "description": "CreateTeamOption options for creating a team", @@ -7331,7 +7331,7 @@ "x-go-name": "Units" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateUserOption": { "description": "CreateUserOption create user options", @@ -7377,7 +7377,7 @@ "x-go-name": "Username" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "DeleteEmailOption": { "description": "DeleteEmailOption options when deleting email addresses", @@ -7392,7 +7392,7 @@ "x-go-name": "Emails" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "DeleteFileOptions": { "description": "DeleteFileOptions options for deleting files (used for other File structs below)", @@ -7421,7 +7421,7 @@ "x-go-name": "SHA" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "DeployKey": { "description": "DeployKey a deploy key", @@ -7466,7 +7466,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditAttachmentOptions": { "description": "EditAttachmentOptions options for editing attachments", @@ -7477,7 +7477,7 @@ "x-go-name": "Name" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditDeadlineOption": { "description": "EditDeadlineOption options for creating a deadline", @@ -7492,7 +7492,7 @@ "x-go-name": "Deadline" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditGitHookOption": { "description": "EditGitHookOption options when modifying one Git hook", @@ -7503,7 +7503,7 @@ "x-go-name": "Content" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditHookOption": { "description": "EditHookOption options when modify one hook", @@ -7528,7 +7528,7 @@ "x-go-name": "Events" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditIssueCommentOption": { "description": "EditIssueCommentOption options for editing a comment", @@ -7542,7 +7542,7 @@ "x-go-name": "Body" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditIssueOption": { "description": "EditIssueOption options for editing an issue", @@ -7582,7 +7582,7 @@ "x-go-name": "Title" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditLabelOption": { "description": "EditLabelOption options for editing a label", @@ -7597,7 +7597,7 @@ "x-go-name": "Name" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditMilestoneOption": { "description": "EditMilestoneOption options for editing a milestone", @@ -7621,7 +7621,7 @@ "x-go-name": "Title" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditOrgOption": { "description": "EditOrgOption options for editing an organization", @@ -7644,7 +7644,7 @@ "x-go-name": "Website" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditPullRequestOption": { "description": "EditPullRequestOption options when modify pull request", @@ -7692,7 +7692,7 @@ "x-go-name": "Title" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditReleaseOption": { "description": "EditReleaseOption options when editing a release", @@ -7723,7 +7723,7 @@ "x-go-name": "Target" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditTeamOption": { "description": "EditTeamOption options for editing a team", @@ -7766,7 +7766,7 @@ "x-go-name": "Units" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "EditUserOption": { "description": "EditUserOption edit user options", @@ -7839,7 +7839,7 @@ "x-go-name": "Website" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Email": { "description": "Email an email address belonging to a user", @@ -7859,7 +7859,7 @@ "x-go-name": "Verified" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "FileCommitResponse": { "type": "object", @@ -7898,7 +7898,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "FileContentResponse": { "description": "FileContentResponse contains information about a repo's file stats and content", @@ -7945,7 +7945,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "FileDeleteResponse": { "description": "FileDeleteResponse contains information about a repo's file that was deleted", @@ -7962,7 +7962,7 @@ "$ref": "#/definitions/PayloadCommitVerification" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "FileLinksResponse": { "description": "FileLinksResponse contains the links for a repo's file", @@ -7981,7 +7981,7 @@ "x-go-name": "Self" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "FileResponse": { "description": "FileResponse contains information about a repo's file", @@ -7997,7 +7997,7 @@ "$ref": "#/definitions/PayloadCommitVerification" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "GPGKey": { "description": "GPGKey a user GPG key to sign commit and tag in repository", @@ -8061,7 +8061,7 @@ "x-go-name": "SubsKey" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "GPGKeyEmail": { "description": "GPGKeyEmail an email attached to a GPGKey", @@ -8076,7 +8076,7 @@ "x-go-name": "Verified" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "GitBlobResponse": { "description": "GitBlobResponse represents a git blob", @@ -8104,7 +8104,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "GitEntry": { "description": "GitEntry represents a git tree", @@ -8136,7 +8136,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "GitHook": { "description": "GitHook represents a Git repository hook", @@ -8155,7 +8155,7 @@ "x-go-name": "Name" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "GitObject": { "type": "object", @@ -8174,7 +8174,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "GitTreeResponse": { "description": "GitTreeResponse returns a git tree", @@ -8210,7 +8210,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Hook": { "description": "Hook a hook is a web hook when one repository changed", @@ -8254,7 +8254,7 @@ "x-go-name": "Updated" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Identity": { "description": "Identity for a person's identity like an author or committer", @@ -8270,7 +8270,7 @@ "x-go-name": "Name" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Issue": { "description": "Issue represents an issue in a repository", @@ -8353,7 +8353,7 @@ "$ref": "#/definitions/User" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "IssueDeadline": { "description": "IssueDeadline represents an issue deadline", @@ -8365,7 +8365,7 @@ "x-go-name": "Deadline" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "IssueLabelsOption": { "description": "IssueLabelsOption a collection of labels", @@ -8381,7 +8381,7 @@ "x-go-name": "Labels" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Label": { "description": "Label a label to an issue or a pr", @@ -8406,7 +8406,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "MarkdownOption": { "description": "MarkdownOption markdown options", @@ -8429,7 +8429,7 @@ "type": "boolean" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "MergePullRequestOption": { "description": "MergePullRequestForm form for merging Pull Request", @@ -8567,7 +8567,7 @@ "x-go-name": "Title" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Organization": { "description": "Organization represents an organization", @@ -8606,7 +8606,7 @@ "x-go-name": "Website" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "PRBranchInfo": { "description": "PRBranchInfo information about a branch", @@ -8633,7 +8633,7 @@ "x-go-name": "Sha" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "PayloadCommit": { "description": "PayloadCommit represents a commit", @@ -8688,7 +8688,7 @@ "$ref": "#/definitions/PayloadCommitVerification" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "PayloadCommitVerification": { "description": "PayloadCommitVerification represents the GPG verification of a commit", @@ -8711,7 +8711,7 @@ "x-go-name": "Verified" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "PayloadUser": { "description": "PayloadUser represents the author or committer of a commit", @@ -8732,7 +8732,7 @@ "x-go-name": "UserName" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Permission": { "description": "Permission represents a set of permissions", @@ -8751,7 +8751,7 @@ "x-go-name": "Push" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "PublicKey": { "description": "PublicKey publickey is a user key to push code to repository", @@ -8795,7 +8795,7 @@ "$ref": "#/definitions/User" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "PullRequest": { "description": "PullRequest represents a pull request", @@ -8917,7 +8917,7 @@ "$ref": "#/definitions/User" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "PullRequestMeta": { "description": "PullRequestMeta PR info if an issue is a PR", @@ -8933,7 +8933,7 @@ "x-go-name": "Merged" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Reference": { "type": "object", @@ -8951,7 +8951,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Release": { "description": "Release represents a repository release", @@ -9019,7 +9019,7 @@ "x-go-name": "ZipURL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "RepoCommit": { "type": "object", @@ -9043,7 +9043,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Repository": { "description": "Repository represents a repository", @@ -9151,7 +9151,7 @@ "x-go-name": "Website" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "SearchResults": { "description": "SearchResults results of a successful search", @@ -9169,7 +9169,7 @@ "x-go-name": "OK" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "ServerVersion": { "description": "ServerVersion wraps the version of the server", @@ -9180,12 +9180,12 @@ "x-go-name": "Version" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "StateType": { "description": "StateType issue state type", "type": "string", - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Status": { "description": "Status holds a single Status of a single Commit", @@ -9229,12 +9229,12 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "StatusState": { "description": "StatusState holds the state of a Status\nIt can be \"pending\", \"success\", \"error\", \"failure\", and \"warning\"", "type": "string", - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Tag": { "description": "Tag represents a repository tag", @@ -9267,7 +9267,7 @@ "x-go-name": "ZipballURL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "Team": { "description": "Team represents a team in an organization", @@ -9317,7 +9317,7 @@ "x-go-name": "Units" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "TimeStamp": { "description": "TimeStamp defines a timestamp", @@ -9356,7 +9356,7 @@ "x-go-name": "UserID" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "UpdateFileOptions": { "description": "UpdateFileOptions options for updating files", @@ -9393,7 +9393,7 @@ "x-go-name": "SHA" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "User": { "description": "User represents a user", @@ -9436,7 +9436,7 @@ "x-go-name": "UserName" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "UserHeatmapData": { "description": "UserHeatmapData represents the data needed to create a heatmap", @@ -9457,7 +9457,7 @@ "description": "VisibleType defines the visibility (Organization only)", "type": "integer", "format": "int64", - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" }, "WatchInfo": { "description": "WatchInfo represents an API watch status of one repository", @@ -9489,7 +9489,7 @@ "x-go-name": "URL" } }, - "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" + "x-go-package": "code.gitea.io/gitea/modules/structs" } }, "responses": { diff --git a/vendor/code.gitea.io/sdk/LICENSE b/vendor/code.gitea.io/sdk/LICENSE deleted file mode 100644 index 10aeba46b..000000000 --- a/vendor/code.gitea.io/sdk/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2016 The Gitea Authors -Copyright (c) 2014 The Gogs Authors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/code.gitea.io/sdk/gitea/admin_org.go b/vendor/code.gitea.io/sdk/gitea/admin_org.go deleted file mode 100644 index 4071b6f18..000000000 --- a/vendor/code.gitea.io/sdk/gitea/admin_org.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// AdminCreateOrg create an organization -func (c *Client) AdminCreateOrg(user string, opt CreateOrgOption) (*Organization, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - org := new(Organization) - return org, c.getParsedResponse("POST", fmt.Sprintf("/admin/users/%s/orgs", user), - jsonHeader, bytes.NewReader(body), org) -} diff --git a/vendor/code.gitea.io/sdk/gitea/admin_repo.go b/vendor/code.gitea.io/sdk/gitea/admin_repo.go deleted file mode 100644 index cf565ffa3..000000000 --- a/vendor/code.gitea.io/sdk/gitea/admin_repo.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// AdminCreateRepo create a repo -func (c *Client) AdminCreateRepo(user string, opt CreateRepoOption) (*Repository, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - repo := new(Repository) - return repo, c.getParsedResponse("POST", fmt.Sprintf("/admin/users/%s/repos", user), - jsonHeader, bytes.NewReader(body), repo) -} diff --git a/vendor/code.gitea.io/sdk/gitea/attachment.go b/vendor/code.gitea.io/sdk/gitea/attachment.go deleted file mode 100644 index 8c527de73..000000000 --- a/vendor/code.gitea.io/sdk/gitea/attachment.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2017 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea // import "code.gitea.io/sdk/gitea" -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "mime/multipart" - "net/http" - "time" -) - -// Attachment a generic attachment -// swagger:model -type Attachment struct { - ID int64 `json:"id"` - Name string `json:"name"` - Size int64 `json:"size"` - DownloadCount int64 `json:"download_count"` - // swagger:strfmt date-time - Created time.Time `json:"created_at"` - UUID string `json:"uuid"` - DownloadURL string `json:"browser_download_url"` -} - -// ListReleaseAttachments list release's attachments -func (c *Client) ListReleaseAttachments(user, repo string, release int64) ([]*Attachment, error) { - attachments := make([]*Attachment, 0, 10) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/releases/%d/assets", user, repo, release), - nil, nil, &attachments) - return attachments, err -} - -// GetReleaseAttachment returns the requested attachment -func (c *Client) GetReleaseAttachment(user, repo string, release int64, id int64) (*Attachment, error) { - a := new(Attachment) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, id), - nil, nil, &a) - return a, err -} - -// CreateReleaseAttachment creates an attachment for the given release -func (c *Client) CreateReleaseAttachment(user, repo string, release int64, file io.Reader, filename string) (*Attachment, error) { - // Write file to body - body := new(bytes.Buffer) - writer := multipart.NewWriter(body) - part, err := writer.CreateFormFile("attachment", filename) - if err != nil { - return nil, err - } - - if _, err = io.Copy(part, file); err != nil { - return nil, err - } - if err = writer.Close(); err != nil { - return nil, err - } - - // Send request - attachment := new(Attachment) - err = c.getParsedResponse("POST", - fmt.Sprintf("/repos/%s/%s/releases/%d/assets", user, repo, release), - http.Header{"Content-Type": {writer.FormDataContentType()}}, body, &attachment) - return attachment, err -} - -// EditReleaseAttachment updates the given attachment with the given options -func (c *Client) EditReleaseAttachment(user, repo string, release int64, attachment int64, form EditAttachmentOptions) (*Attachment, error) { - body, err := json.Marshal(&form) - if err != nil { - return nil, err - } - attach := new(Attachment) - return attach, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, attachment), jsonHeader, bytes.NewReader(body), attach) -} - -// DeleteReleaseAttachment deletes the given attachment including the uploaded file -func (c *Client) DeleteReleaseAttachment(user, repo string, release int64, id int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, id), nil, nil) - return err -} - -// EditAttachmentOptions options for editing attachments -// swagger:model -type EditAttachmentOptions struct { - Name string `json:"name"` -} diff --git a/vendor/code.gitea.io/sdk/gitea/fork.go b/vendor/code.gitea.io/sdk/gitea/fork.go deleted file mode 100644 index 57222498e..000000000 --- a/vendor/code.gitea.io/sdk/gitea/fork.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2016 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// ListForks list a repository's forks -func (c *Client) ListForks(user, repo string) ([]*Repository, error) { - forks := make([]*Repository, 10) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/forks", user, repo), - nil, nil, &forks) - return forks, err -} - -// CreateForkOption options for creating a fork -type CreateForkOption struct { - // organization name, if forking into an organization - Organization *string `json:"organization"` -} - -// CreateFork create a fork of a repository -func (c *Client) CreateFork(user, repo string, form CreateForkOption) (*Repository, error) { - body, err := json.Marshal(form) - if err != nil { - return nil, err - } - fork := new(Repository) - err = c.getParsedResponse("POST", - fmt.Sprintf("/repos/%s/%s/forks", user, repo), - jsonHeader, bytes.NewReader(body), &fork) - return fork, err -} diff --git a/vendor/code.gitea.io/sdk/gitea/git_hook.go b/vendor/code.gitea.io/sdk/gitea/git_hook.go deleted file mode 100644 index d47fe1d0c..000000000 --- a/vendor/code.gitea.io/sdk/gitea/git_hook.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// GitHook represents a Git repository hook -type GitHook struct { - Name string `json:"name"` - IsActive bool `json:"is_active"` - Content string `json:"content,omitempty"` -} - -// GitHookList represents a list of Git hooks -type GitHookList []*GitHook - -// ListRepoGitHooks list all the Git hooks of one repository -func (c *Client) ListRepoGitHooks(user, repo string) (GitHookList, error) { - hooks := make([]*GitHook, 0, 10) - return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git", user, repo), nil, nil, &hooks) -} - -// GetRepoGitHook get a Git hook of a repository -func (c *Client) GetRepoGitHook(user, repo, id string) (*GitHook, error) { - h := new(GitHook) - return h, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git/%s", user, repo, id), nil, nil, h) -} - -// EditGitHookOption options when modifying one Git hook -type EditGitHookOption struct { - Content string `json:"content"` -} - -// EditRepoGitHook modify one Git hook of a repository -func (c *Client) EditRepoGitHook(user, repo, id string, opt EditGitHookOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PATCH", fmt.Sprintf("/repos/%s/%s/hooks/git/%s", user, repo, id), jsonHeader, bytes.NewReader(body)) - return err -} - -// DeleteRepoGitHook delete one Git hook from a repository -func (c *Client) DeleteRepoGitHook(user, repo, id string) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/hooks/git/%s", user, repo, id), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/gitea.go b/vendor/code.gitea.io/sdk/gitea/gitea.go deleted file mode 100644 index fa35e0955..000000000 --- a/vendor/code.gitea.io/sdk/gitea/gitea.go +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2014 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "encoding/json" - "errors" - "fmt" - "io" - "io/ioutil" - "net/http" - "strings" -) - -// Version return the library version -func Version() string { - return "0.12.3" -} - -// Client represents a Gogs API client. -type Client struct { - url string - accessToken string - sudo string - client *http.Client -} - -// NewClient initializes and returns a API client. -func NewClient(url, token string) *Client { - return &Client{ - url: strings.TrimSuffix(url, "/"), - accessToken: token, - client: &http.Client{}, - } -} - -// NewClientWithHTTP creates an API client with a custom http client -func NewClientWithHTTP(url string, httpClient *http.Client) { - client := NewClient(url, "") - client.client = httpClient -} - -// SetHTTPClient replaces default http.Client with user given one. -func (c *Client) SetHTTPClient(client *http.Client) { - c.client = client -} - -// SetSudo sets username to impersonate. -func (c *Client) SetSudo(sudo string) { - c.sudo = sudo -} - -func (c *Client) doRequest(method, path string, header http.Header, body io.Reader) (*http.Response, error) { - req, err := http.NewRequest(method, c.url+"/api/v1"+path, body) - if err != nil { - return nil, err - } - if len(c.accessToken) != 0 { - req.Header.Set("Authorization", "token "+c.accessToken) - } - if c.sudo != "" { - req.Header.Set("Sudo", c.sudo) - } - for k, v := range header { - req.Header[k] = v - } - - return c.client.Do(req) -} - -func (c *Client) getResponse(method, path string, header http.Header, body io.Reader) ([]byte, error) { - resp, err := c.doRequest(method, path, header, body) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - data, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - - switch resp.StatusCode { - case 403: - return nil, errors.New("403 Forbidden") - case 404: - return nil, errors.New("404 Not Found") - case 409: - return nil, errors.New("409 Conflict") - case 422: - return nil, fmt.Errorf("422 Unprocessable Entity: %s", string(data)) - } - - if resp.StatusCode/100 != 2 { - errMap := make(map[string]interface{}) - if err = json.Unmarshal(data, &errMap); err != nil { - // when the JSON can't be parsed, data was probably empty or a plain string, - // so we try to return a helpful error anyway - return nil, fmt.Errorf("Unknown API Error: %d %s", resp.StatusCode, string(data)) - } - return nil, errors.New(errMap["message"].(string)) - } - - return data, nil -} - -func (c *Client) getParsedResponse(method, path string, header http.Header, body io.Reader, obj interface{}) error { - data, err := c.getResponse(method, path, header, body) - if err != nil { - return err - } - return json.Unmarshal(data, obj) -} - -func (c *Client) getStatusCode(method, path string, header http.Header, body io.Reader) (int, error) { - resp, err := c.doRequest(method, path, header, body) - if err != nil { - return -1, err - } - defer resp.Body.Close() - - return resp.StatusCode, nil -} diff --git a/vendor/code.gitea.io/sdk/gitea/issue_comment.go b/vendor/code.gitea.io/sdk/gitea/issue_comment.go deleted file mode 100644 index 2c8127c60..000000000 --- a/vendor/code.gitea.io/sdk/gitea/issue_comment.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// Comment represents a comment on a commit or issue -type Comment struct { - ID int64 `json:"id"` - HTMLURL string `json:"html_url"` - PRURL string `json:"pull_request_url"` - IssueURL string `json:"issue_url"` - Poster *User `json:"user"` - Body string `json:"body"` - // swagger:strfmt date-time - Created time.Time `json:"created_at"` - // swagger:strfmt date-time - Updated time.Time `json:"updated_at"` -} - -// ListIssueComments list comments on an issue. -func (c *Client) ListIssueComments(owner, repo string, index int64) ([]*Comment, error) { - comments := make([]*Comment, 0, 10) - return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), nil, nil, &comments) -} - -// ListRepoIssueComments list comments for a given repo. -func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error) { - comments := make([]*Comment, 0, 10) - return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments) -} - -// CreateIssueCommentOption options for creating a comment on an issue -type CreateIssueCommentOption struct { - // required:true - Body string `json:"body" binding:"Required"` -} - -// CreateIssueComment create comment on an issue. -func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateIssueCommentOption) (*Comment, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - comment := new(Comment) - return comment, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), jsonHeader, bytes.NewReader(body), comment) -} - -// EditIssueCommentOption options for editing a comment -type EditIssueCommentOption struct { - // required: true - Body string `json:"body" binding:"Required"` -} - -// EditIssueComment edits an issue comment. -func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, opt EditIssueCommentOption) (*Comment, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - comment := new(Comment) - return comment, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/:%s/:%s/issues/%d/comments/%d", owner, repo, index, commentID), jsonHeader, bytes.NewReader(body), comment) -} - -// DeleteIssueComment deletes an issue comment. -func (c *Client) DeleteIssueComment(owner, repo string, index, commentID int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/comments/%d", owner, repo, index, commentID), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/issue_label.go b/vendor/code.gitea.io/sdk/gitea/issue_label.go deleted file mode 100644 index 47d1b8221..000000000 --- a/vendor/code.gitea.io/sdk/gitea/issue_label.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// Label a label to an issue or a pr -// swagger:model -type Label struct { - ID int64 `json:"id"` - Name string `json:"name"` - // example: 00aabb - Color string `json:"color"` - URL string `json:"url"` -} - -// ListRepoLabels list labels of one repository -func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) { - labels := make([]*Label, 0, 10) - return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels) -} - -// GetRepoLabel get one label of repository by repo it -// TODO: maybe we need get a label by name -func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) { - label := new(Label) - return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label) -} - -// CreateLabelOption options for creating a label -type CreateLabelOption struct { - // required:true - Name string `json:"name" binding:"Required"` - // required:true - // example: #00aabb - Color string `json:"color" binding:"Required;Size(7)"` -} - -// CreateLabel create one label of repository -func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - label := new(Label) - return label, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), - jsonHeader, bytes.NewReader(body), label) -} - -// EditLabelOption options for editing a label -type EditLabelOption struct { - Name *string `json:"name"` - Color *string `json:"color"` -} - -// EditLabel modify one label with options -func (c *Client) EditLabel(owner, repo string, id int64, opt EditLabelOption) (*Label, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - label := new(Label) - return label, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), jsonHeader, bytes.NewReader(body), label) -} - -// DeleteLabel delete one label of repository by id -// TODO: maybe we need delete by name -func (c *Client) DeleteLabel(owner, repo string, id int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil) - return err -} - -// IssueLabelsOption a collection of labels -type IssueLabelsOption struct { - // list of label IDs - Labels []int64 `json:"labels"` -} - -// GetIssueLabels get labels of one issue via issue id -func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, error) { - labels := make([]*Label, 0, 5) - return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil, &labels) -} - -// AddIssueLabels add one or more labels to one issue -func (c *Client) AddIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - var labels []*Label - return labels, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), jsonHeader, bytes.NewReader(body), &labels) -} - -// ReplaceIssueLabels replace old labels of issue with new labels -func (c *Client) ReplaceIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - var labels []*Label - return labels, c.getParsedResponse("PUT", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), jsonHeader, bytes.NewReader(body), &labels) -} - -// DeleteIssueLabel delete one label of one issue by issue id and label id -// TODO: maybe we need delete by label name and issue id -func (c *Client) DeleteIssueLabel(owner, repo string, index, label int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/labels/%d", owner, repo, index, label), nil, nil) - return err -} - -// ClearIssueLabels delete all the labels of one issue. -func (c *Client) ClearIssueLabels(owner, repo string, index int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/issue_milestone.go b/vendor/code.gitea.io/sdk/gitea/issue_milestone.go deleted file mode 100644 index 775a6a911..000000000 --- a/vendor/code.gitea.io/sdk/gitea/issue_milestone.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// Milestone milestone is a collection of issues on one repository -type Milestone struct { - ID int64 `json:"id"` - Title string `json:"title"` - Description string `json:"description"` - State StateType `json:"state"` - OpenIssues int `json:"open_issues"` - ClosedIssues int `json:"closed_issues"` - // swagger:strfmt date-time - Closed *time.Time `json:"closed_at"` - // swagger:strfmt date-time - Deadline *time.Time `json:"due_on"` -} - -// ListRepoMilestones list all the milestones of one repository -func (c *Client) ListRepoMilestones(owner, repo string) ([]*Milestone, error) { - milestones := make([]*Milestone, 0, 10) - return milestones, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), nil, nil, &milestones) -} - -// GetMilestone get one milestone by repo name and milestone id -func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, error) { - milestone := new(Milestone) - return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone) -} - -// CreateMilestoneOption options for creating a milestone -type CreateMilestoneOption struct { - Title string `json:"title"` - Description string `json:"description"` - // swagger:strfmt date-time - Deadline *time.Time `json:"due_on"` -} - -// CreateMilestone create one milestone with options -func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption) (*Milestone, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - milestone := new(Milestone) - return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), jsonHeader, bytes.NewReader(body), milestone) -} - -// EditMilestoneOption options for editing a milestone -type EditMilestoneOption struct { - Title string `json:"title"` - Description *string `json:"description"` - State *string `json:"state"` - Deadline *time.Time `json:"due_on"` -} - -// EditMilestone modify milestone with options -func (c *Client) EditMilestone(owner, repo string, id int64, opt EditMilestoneOption) (*Milestone, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - milestone := new(Milestone) - return milestone, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), jsonHeader, bytes.NewReader(body), milestone) -} - -// DeleteMilestone delete one milestone by milestone id -func (c *Client) DeleteMilestone(owner, repo string, id int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go b/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go deleted file mode 100644 index 7f4b64cbb..000000000 --- a/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2017 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// TrackedTime worked time for an issue / pr -type TrackedTime struct { - ID int64 `json:"id"` - // swagger:strfmt date-time - Created time.Time `json:"created"` - // Time in seconds - Time int64 `json:"time"` - UserID int64 `json:"user_id"` - IssueID int64 `json:"issue_id"` -} - -// TrackedTimes represent a list of tracked times -type TrackedTimes []*TrackedTime - -// GetUserTrackedTimes list tracked times of a user -func (c *Client) GetUserTrackedTimes(owner, repo, user string) (TrackedTimes, error) { - times := make(TrackedTimes, 0, 10) - return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times/%s", owner, repo, user), nil, nil, ×) -} - -// GetRepoTrackedTimes list tracked times of a repository -func (c *Client) GetRepoTrackedTimes(owner, repo string) (TrackedTimes, error) { - times := make(TrackedTimes, 0, 10) - return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times", owner, repo), nil, nil, ×) -} - -// GetMyTrackedTimes list tracked times of the current user -func (c *Client) GetMyTrackedTimes() (TrackedTimes, error) { - times := make(TrackedTimes, 0, 10) - return times, c.getParsedResponse("GET", "/user/times", nil, nil, ×) -} - -// AddTimeOption options for adding time to an issue -type AddTimeOption struct { - // time in seconds - // required: true - Time int64 `json:"time" binding:"Required"` -} - -// AddTime adds time to issue with the given index -func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*TrackedTime, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - t := new(TrackedTime) - return t, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), - jsonHeader, bytes.NewReader(body), t) -} - -// ListTrackedTimes get tracked times of one issue via issue id -func (c *Client) ListTrackedTimes(owner, repo string, index int64) (TrackedTimes, error) { - times := make(TrackedTimes, 0, 5) - return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil, ×) -} diff --git a/vendor/code.gitea.io/sdk/gitea/org_member.go b/vendor/code.gitea.io/sdk/gitea/org_member.go deleted file mode 100644 index 9bb95af3e..000000000 --- a/vendor/code.gitea.io/sdk/gitea/org_member.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// AddOrgMembershipOption add user to organization options -type AddOrgMembershipOption struct { - Role string `json:"role" binding:"Required"` -} - -// AddOrgMembership add some one to an organization's member -func (c *Client) AddOrgMembership(org, user string, opt AddOrgMembershipOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PUT", fmt.Sprintf("/orgs/%s/membership/%s", org, user), jsonHeader, bytes.NewReader(body)) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/org_type.go b/vendor/code.gitea.io/sdk/gitea/org_type.go deleted file mode 100644 index 778ec3b0a..000000000 --- a/vendor/code.gitea.io/sdk/gitea/org_type.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -// VisibleType defines the visibility (Organization only) -type VisibleType int - -const ( - // VisibleTypePublic Visible for everyone - VisibleTypePublic VisibleType = iota - - // VisibleTypeLimited Visible for every connected user - VisibleTypeLimited - - // VisibleTypePrivate Visible only for organization's members - VisibleTypePrivate -) - -// VisibilityModes is a map of org Visibility types -var VisibilityModes = map[string]VisibleType{ - "public": VisibleTypePublic, - "limited": VisibleTypeLimited, - "private": VisibleTypePrivate, -} - -// IsPublic returns true if VisibleType is public -func (vt VisibleType) IsPublic() bool { - return vt == VisibleTypePublic -} - -// IsLimited returns true if VisibleType is limited -func (vt VisibleType) IsLimited() bool { - return vt == VisibleTypeLimited -} - -// IsPrivate returns true if VisibleType is private -func (vt VisibleType) IsPrivate() bool { - return vt == VisibleTypePrivate -} - -// ExtractKeysFromMapString provides a slice of keys from map -func ExtractKeysFromMapString(in map[string]VisibleType) (keys []string) { - for k := range in { - keys = append(keys, k) - } - return -} diff --git a/vendor/code.gitea.io/sdk/gitea/release.go b/vendor/code.gitea.io/sdk/gitea/release.go deleted file mode 100644 index 396251dca..000000000 --- a/vendor/code.gitea.io/sdk/gitea/release.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2016 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// Release represents a repository release -type Release struct { - ID int64 `json:"id"` - TagName string `json:"tag_name"` - Target string `json:"target_commitish"` - Title string `json:"name"` - Note string `json:"body"` - URL string `json:"url"` - TarURL string `json:"tarball_url"` - ZipURL string `json:"zipball_url"` - IsDraft bool `json:"draft"` - IsPrerelease bool `json:"prerelease"` - // swagger:strfmt date-time - CreatedAt time.Time `json:"created_at"` - // swagger:strfmt date-time - PublishedAt time.Time `json:"published_at"` - Publisher *User `json:"author"` - Attachments []*Attachment `json:"assets"` -} - -// ListReleases list releases of a repository -func (c *Client) ListReleases(user, repo string) ([]*Release, error) { - releases := make([]*Release, 0, 10) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/releases", user, repo), - nil, nil, &releases) - return releases, err -} - -// GetRelease get a release of a repository -func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) { - r := new(Release) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id), - nil, nil, &r) - return r, err -} - -// CreateReleaseOption options when creating a release -type CreateReleaseOption struct { - // required: true - TagName string `json:"tag_name" binding:"Required"` - Target string `json:"target_commitish"` - Title string `json:"name"` - Note string `json:"body"` - IsDraft bool `json:"draft"` - IsPrerelease bool `json:"prerelease"` -} - -// CreateRelease create a release -func (c *Client) CreateRelease(user, repo string, form CreateReleaseOption) (*Release, error) { - body, err := json.Marshal(form) - if err != nil { - return nil, err - } - r := new(Release) - err = c.getParsedResponse("POST", - fmt.Sprintf("/repos/%s/%s/releases", user, repo), - jsonHeader, bytes.NewReader(body), r) - return r, err -} - -// EditReleaseOption options when editing a release -type EditReleaseOption struct { - TagName string `json:"tag_name"` - Target string `json:"target_commitish"` - Title string `json:"name"` - Note string `json:"body"` - IsDraft *bool `json:"draft"` - IsPrerelease *bool `json:"prerelease"` -} - -// EditRelease edit a release -func (c *Client) EditRelease(user, repo string, id int64, form EditReleaseOption) (*Release, error) { - body, err := json.Marshal(form) - if err != nil { - return nil, err - } - r := new(Release) - err = c.getParsedResponse("PATCH", - fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id), - jsonHeader, bytes.NewReader(body), r) - return r, err -} - -// DeleteRelease delete a release from a repository -func (c *Client) DeleteRelease(user, repo string, id int64) error { - _, err := c.getResponse("DELETE", - fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id), - nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_branch.go b/vendor/code.gitea.io/sdk/gitea/repo_branch.go deleted file mode 100644 index 481fc3386..000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_branch.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "fmt" -) - -// Branch represents a repository branch -type Branch struct { - Name string `json:"name"` - Commit *PayloadCommit `json:"commit"` -} - -// ListRepoBranches list all the branches of one repository -func (c *Client) ListRepoBranches(user, repo string) ([]*Branch, error) { - branches := make([]*Branch, 0, 10) - return branches, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches", user, repo), nil, nil, &branches) -} - -// GetRepoBranch get one branch's information of one repository -func (c *Client) GetRepoBranch(user, repo, branch string) (*Branch, error) { - b := new(Branch) - return b, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches/%s", user, repo, branch), nil, nil, &b) -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_collaborator.go b/vendor/code.gitea.io/sdk/gitea/repo_collaborator.go deleted file mode 100644 index bd61a22ce..000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_collaborator.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// ListCollaborators list a repository's collaborators -func (c *Client) ListCollaborators(user, repo string) ([]*User, error) { - collaborators := make([]*User, 0, 10) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/collaborators", user, repo), - nil, nil, &collaborators) - return collaborators, err -} - -// IsCollaborator check if a user is a collaborator of a repository -func (c *Client) IsCollaborator(user, repo, collaborator string) (bool, error) { - status, err := c.getStatusCode("GET", - fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), - nil, nil) - if err != nil { - return false, err - } - if status == 204 { - return true, nil - } - return false, nil -} - -// AddCollaboratorOption options when adding a user as a collaborator of a repository -type AddCollaboratorOption struct { - Permission *string `json:"permission"` -} - -// AddCollaborator add some user as a collaborator of a repository -func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollaboratorOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, bytes.NewReader(body)) - return err -} - -// DeleteCollaborator remove a collaborator from a repository -func (c *Client) DeleteCollaborator(user, repo, collaborator string) error { - _, err := c.getResponse("DELETE", - fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), - nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_key.go b/vendor/code.gitea.io/sdk/gitea/repo_key.go deleted file mode 100644 index a1ae4584e..000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_key.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// DeployKey a deploy key -type DeployKey struct { - ID int64 `json:"id"` - KeyID int64 `json:"key_id"` - Key string `json:"key"` - URL string `json:"url"` - Title string `json:"title"` - Fingerprint string `json:"fingerprint"` - // swagger:strfmt date-time - Created time.Time `json:"created_at"` - ReadOnly bool `json:"read_only"` - Repository *Repository `json:"repository,omitempty"` -} - -// ListDeployKeys list all the deploy keys of one repository -func (c *Client) ListDeployKeys(user, repo string) ([]*DeployKey, error) { - keys := make([]*DeployKey, 0, 10) - return keys, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys", user, repo), nil, nil, &keys) -} - -// GetDeployKey get one deploy key with key id -func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, error) { - key := new(DeployKey) - return key, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys/%d", user, repo, keyID), nil, nil, &key) -} - -// CreateKeyOption options when creating a key -type CreateKeyOption struct { - // Title of the key to add - // - // required: true - // unique: true - Title string `json:"title" binding:"Required"` - // An armored SSH key to add - // - // required: true - // unique: true - Key string `json:"key" binding:"Required"` - // Describe if the key has only read access or read/write - // - // required: false - ReadOnly bool `json:"read_only"` -} - -// CreateDeployKey options when create one deploy key -func (c *Client) CreateDeployKey(user, repo string, opt CreateKeyOption) (*DeployKey, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - key := new(DeployKey) - return key, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/keys", user, repo), jsonHeader, bytes.NewReader(body), key) -} - -// DeleteDeployKey delete deploy key with key id -func (c *Client) DeleteDeployKey(owner, repo string, keyID int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/keys/%d", owner, repo, keyID), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_refs.go b/vendor/code.gitea.io/sdk/gitea/repo_refs.go deleted file mode 100644 index b946a1002..000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_refs.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2018 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "encoding/json" - "errors" - "fmt" - "strings" -) - -// Reference represents a Git reference. -type Reference struct { - Ref string `json:"ref"` - URL string `json:"url"` - Object *GitObject `json:"object"` -} - -// GitObject represents a Git object. -type GitObject struct { - Type string `json:"type"` - SHA string `json:"sha"` - URL string `json:"url"` -} - -// GetRepoRef get one ref's information of one repository -func (c *Client) GetRepoRef(user, repo, ref string) (*Reference, error) { - ref = strings.TrimPrefix(ref, "refs/") - r := new(Reference) - err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/refs/%s", user, repo, ref), nil, nil, &r) - if _, ok := err.(*json.UnmarshalTypeError); ok { - // Multiple refs - return nil, errors.New("no exact match found for this ref") - } else if err != nil { - return nil, err - } - - return r, nil -} - -// GetRepoRefs get list of ref's information of one repository -func (c *Client) GetRepoRefs(user, repo, ref string) ([]*Reference, error) { - ref = strings.TrimPrefix(ref, "refs/") - resp, err := c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/git/refs/%s", user, repo, ref), nil, nil) - if err != nil { - return nil, err - } - - // Attempt to unmarshal single returned ref. - r := new(Reference) - refErr := json.Unmarshal(resp, r) - if refErr == nil { - return []*Reference{r}, nil - } - - // Attempt to unmarshal multiple refs. - var rs []*Reference - refsErr := json.Unmarshal(resp, &rs) - if refsErr == nil { - if len(rs) == 0 { - return nil, errors.New("unexpected response: an array of refs with length 0") - } - return rs, nil - } - - return nil, fmt.Errorf("unmarshalling failed for both single and multiple refs: %s and %s", refErr, refsErr) -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_watch.go b/vendor/code.gitea.io/sdk/gitea/repo_watch.go deleted file mode 100644 index 1005f9fbd..000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_watch.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "fmt" - "net/http" - "time" -) - -// WatchInfo represents an API watch status of one repository -type WatchInfo struct { - Subscribed bool `json:"subscribed"` - Ignored bool `json:"ignored"` - Reason interface{} `json:"reason"` - CreatedAt time.Time `json:"created_at"` - URL string `json:"url"` - RepositoryURL string `json:"repository_url"` -} - -// GetWatchedRepos list all the watched repos of user -func (c *Client) GetWatchedRepos(user, pass string) ([]*Repository, error) { - repos := make([]*Repository, 0, 10) - return repos, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/subscriptions", user), - http.Header{"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, nil, &repos) -} - -// WatchRepo start to watch a repository -func (c *Client) WatchRepo(user, pass, repoUser, repoName string) (*WatchInfo, error) { - i := new(WatchInfo) - return i, c.getParsedResponse("PUT", fmt.Sprintf("/repos/%s/%s/subscription", repoUser, repoName), - http.Header{"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, nil, i) -} - -// UnWatchRepo start to watch a repository -func (c *Client) UnWatchRepo(user, pass, repoUser, repoName string) (int, error) { - return c.getStatusCode("DELETE", fmt.Sprintf("/repos/%s/%s/subscription", repoUser, repoName), - http.Header{"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, nil) -} diff --git a/vendor/code.gitea.io/sdk/gitea/user_app.go b/vendor/code.gitea.io/sdk/gitea/user_app.go deleted file mode 100644 index c5367be5c..000000000 --- a/vendor/code.gitea.io/sdk/gitea/user_app.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2014 The Gogs Authors. All rights reserved. -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/base64" - "encoding/json" - "fmt" - "net/http" -) - -// BasicAuthEncode generate base64 of basic auth head -func BasicAuthEncode(user, pass string) string { - return base64.StdEncoding.EncodeToString([]byte(user + ":" + pass)) -} - -// AccessToken represents an API access token. -// swagger:response AccessToken -type AccessToken struct { - ID int64 `json:"id"` - Name string `json:"name"` - Token string `json:"sha1"` - TokenLastEight string `json:"token_last_eight"` -} - -// AccessTokenList represents a list of API access token. -// swagger:response AccessTokenList -type AccessTokenList []*AccessToken - -// ListAccessTokens lista all the access tokens of user -func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) { - tokens := make([]*AccessToken, 0, 10) - return tokens, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/tokens", user), - http.Header{"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, nil, &tokens) -} - -// CreateAccessTokenOption options when create access token -// swagger:parameters userCreateToken -type CreateAccessTokenOption struct { - Name string `json:"name" binding:"Required"` -} - -// CreateAccessToken create one access token with options -func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOption) (*AccessToken, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - t := new(AccessToken) - return t, c.getParsedResponse("POST", fmt.Sprintf("/users/%s/tokens", user), - http.Header{ - "content-type": []string{"application/json"}, - "Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, - bytes.NewReader(body), t) -} - -// DeleteAccessToken delete token with key id -func (c *Client) DeleteAccessToken(user string, keyID int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/user/%s/tokens/%d", user, keyID), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/user_email.go b/vendor/code.gitea.io/sdk/gitea/user_email.go deleted file mode 100644 index 721f52144..000000000 --- a/vendor/code.gitea.io/sdk/gitea/user_email.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" -) - -// Email an email address belonging to a user -type Email struct { - // swagger:strfmt email - Email string `json:"email"` - Verified bool `json:"verified"` - Primary bool `json:"primary"` -} - -// ListEmails all the email addresses of user -func (c *Client) ListEmails() ([]*Email, error) { - emails := make([]*Email, 0, 3) - return emails, c.getParsedResponse("GET", "/user/emails", nil, nil, &emails) -} - -// CreateEmailOption options when creating email addresses -type CreateEmailOption struct { - // email addresses to add - Emails []string `json:"emails"` -} - -// AddEmail add one email to current user with options -func (c *Client) AddEmail(opt CreateEmailOption) ([]*Email, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - emails := make([]*Email, 0, 3) - return emails, c.getParsedResponse("POST", "/user/emails", jsonHeader, bytes.NewReader(body), emails) -} - -// DeleteEmailOption options when deleting email addresses -type DeleteEmailOption struct { - // email addresses to delete - Emails []string `json:"emails"` -} - -// DeleteEmail delete one email of current users' -func (c *Client) DeleteEmail(opt DeleteEmailOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("DELETE", "/user/emails", jsonHeader, bytes.NewReader(body)) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/user_follow.go b/vendor/code.gitea.io/sdk/gitea/user_follow.go deleted file mode 100644 index a197a7f18..000000000 --- a/vendor/code.gitea.io/sdk/gitea/user_follow.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import "fmt" - -// ListMyFollowers list all the followers of current user -func (c *Client) ListMyFollowers(page int) ([]*User, error) { - users := make([]*User, 0, 10) - return users, c.getParsedResponse("GET", fmt.Sprintf("/user/followers?page=%d", page), nil, nil, &users) -} - -// ListFollowers list all the followers of one user -func (c *Client) ListFollowers(user string, page int) ([]*User, error) { - users := make([]*User, 0, 10) - return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/followers?page=%d", user, page), nil, nil, &users) -} - -// ListMyFollowing list all the users current user followed -func (c *Client) ListMyFollowing(page int) ([]*User, error) { - users := make([]*User, 0, 10) - return users, c.getParsedResponse("GET", fmt.Sprintf("/user/following?page=%d", page), nil, nil, &users) -} - -// ListFollowing list all the users the user followed -func (c *Client) ListFollowing(user string, page int) ([]*User, error) { - users := make([]*User, 0, 10) - return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/following?page=%d", user, page), nil, nil, &users) -} - -// IsFollowing if current user followed the target -func (c *Client) IsFollowing(target string) bool { - _, err := c.getResponse("GET", fmt.Sprintf("/user/following/%s", target), nil, nil) - return err == nil -} - -// IsUserFollowing if the user followed the target -func (c *Client) IsUserFollowing(user, target string) bool { - _, err := c.getResponse("GET", fmt.Sprintf("/users/%s/following/%s", user, target), nil, nil) - return err == nil -} - -// Follow set current user follow the target -func (c *Client) Follow(target string) error { - _, err := c.getResponse("PUT", fmt.Sprintf("/user/following/%s", target), nil, nil) - return err -} - -// Unfollow set current user unfollow the target -func (c *Client) Unfollow(target string) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/user/following/%s", target), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/user_key.go b/vendor/code.gitea.io/sdk/gitea/user_key.go deleted file mode 100644 index cccaa65db..000000000 --- a/vendor/code.gitea.io/sdk/gitea/user_key.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// PublicKey publickey is a user key to push code to repository -type PublicKey struct { - ID int64 `json:"id"` - Key string `json:"key"` - URL string `json:"url,omitempty"` - Title string `json:"title,omitempty"` - Fingerprint string `json:"fingerprint,omitempty"` - // swagger:strfmt date-time - Created time.Time `json:"created_at,omitempty"` - Owner *User `json:"user,omitempty"` - ReadOnly bool `json:"read_only,omitempty"` - KeyType string `json:"key_type,omitempty"` -} - -// ListPublicKeys list all the public keys of the user -func (c *Client) ListPublicKeys(user string) ([]*PublicKey, error) { - keys := make([]*PublicKey, 0, 10) - return keys, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/keys", user), nil, nil, &keys) -} - -// ListMyPublicKeys list all the public keys of current user -func (c *Client) ListMyPublicKeys() ([]*PublicKey, error) { - keys := make([]*PublicKey, 0, 10) - return keys, c.getParsedResponse("GET", "/user/keys", nil, nil, &keys) -} - -// GetPublicKey get current user's public key by key id -func (c *Client) GetPublicKey(keyID int64) (*PublicKey, error) { - key := new(PublicKey) - return key, c.getParsedResponse("GET", fmt.Sprintf("/user/keys/%d", keyID), nil, nil, &key) -} - -// CreatePublicKey create public key with options -func (c *Client) CreatePublicKey(opt CreateKeyOption) (*PublicKey, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - key := new(PublicKey) - return key, c.getParsedResponse("POST", "/user/keys", jsonHeader, bytes.NewReader(body), key) -} - -// DeletePublicKey delete public key with key id -func (c *Client) DeletePublicKey(keyID int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/user/keys/%d", keyID), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/user_search.go b/vendor/code.gitea.io/sdk/gitea/user_search.go deleted file mode 100644 index 65ab980d6..000000000 --- a/vendor/code.gitea.io/sdk/gitea/user_search.go +++ /dev/null @@ -1,14 +0,0 @@ -package gitea - -import "fmt" - -type searchUsersResponse struct { - Users []*User `json:"data"` -} - -// SearchUsers finds users by query -func (c *Client) SearchUsers(query string, limit int) ([]*User, error) { - resp := new(searchUsersResponse) - err := c.getParsedResponse("GET", fmt.Sprintf("/users/search?q=%s&limit=%d", query, limit), nil, nil, &resp) - return resp.Users, err -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 715f20a13..4d427e5a7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,5 +1,3 @@ -# code.gitea.io/sdk v0.0.0-20190510041517-9251befd3702 -code.gitea.io/sdk/gitea # github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml # github.com/PuerkitoBio/goquery v0.0.0-20170324135448-ed7d758e9a34