Browse Source

Move sdk structs to modules/structs (#6905)

* move sdk structs to moduels/structs

* fix tests

* fix fmt

* fix swagger

* fix vendor
release/v1.9
Lunny Xiao 3 years ago
committed by GitHub
parent
commit
34eee25bd4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      go.mod
  2. 4
      go.sum
  3. 2
      integrations/api_admin_test.go
  4. 2
      integrations/api_branch_test.go
  5. 2
      integrations/api_comment_test.go
  6. 2
      integrations/api_fork_test.go
  7. 2
      integrations/api_gpg_keys_test.go
  8. 2
      integrations/api_helper_for_declarative_test.go
  9. 2
      integrations/api_issue_label_test.go
  10. 2
      integrations/api_issue_test.go
  11. 2
      integrations/api_keys_test.go
  12. 2
      integrations/api_org_test.go
  13. 2
      integrations/api_pull_test.go
  14. 2
      integrations/api_releases_test.go
  15. 2
      integrations/api_repo_file_content_test.go
  16. 2
      integrations/api_repo_file_create_test.go
  17. 2
      integrations/api_repo_file_delete_test.go
  18. 2
      integrations/api_repo_file_helpers.go
  19. 2
      integrations/api_repo_file_update_test.go
  20. 2
      integrations/api_repo_git_blobs_test.go
  21. 2
      integrations/api_repo_git_hook_test.go
  22. 2
      integrations/api_repo_lfs_locks_test.go
  23. 2
      integrations/api_repo_tags_test.go
  24. 2
      integrations/api_repo_test.go
  25. 2
      integrations/api_team_test.go
  26. 2
      integrations/api_token_test.go
  27. 2
      integrations/api_user_orgs_test.go
  28. 2
      integrations/api_user_search_test.go
  29. 2
      integrations/benchmarks_test.go
  30. 2
      integrations/links_test.go
  31. 2
      integrations/pull_status_test.go
  32. 2
      integrations/repo_commits_test.go
  33. 2
      integrations/ssh_key_test.go
  34. 4
      integrations/version_test.go
  35. 2
      models/action.go
  36. 2
      models/attachment.go
  37. 2
      models/issue.go
  38. 2
      models/issue_assignees.go
  39. 2
      models/issue_comment.go
  40. 2
      models/issue_label.go
  41. 2
      models/issue_label_test.go
  42. 2
      models/issue_milestone.go
  43. 2
      models/issue_milestone_test.go
  44. 2
      models/issue_tracked_time.go
  45. 2
      models/lfs_lock.go
  46. 2
      models/pull.go
  47. 2
      models/release.go
  48. 2
      models/repo.go
  49. 2
      models/review.go
  50. 2
      models/status.go
  51. 2
      models/user.go
  52. 2
      models/webhook.go
  53. 2
      models/webhook_dingtalk.go
  54. 2
      models/webhook_discord.go
  55. 2
      models/webhook_msteams.go
  56. 2
      models/webhook_slack.go
  57. 2
      models/webhook_telegram.go
  58. 2
      models/webhook_test.go
  59. 2
      modules/lfs/locks.go
  60. 2
      modules/repofiles/blob.go
  61. 2
      modules/repofiles/blob_test.go
  62. 2
      modules/repofiles/content.go
  63. 6
      modules/repofiles/content_test.go
  64. 2
      modules/repofiles/delete.go
  65. 2
      modules/repofiles/delete_test.go
  66. 2
      modules/repofiles/file.go
  67. 2
      modules/repofiles/file_test.go
  68. 2
      modules/repofiles/tree.go
  69. 2
      modules/repofiles/tree_test.go
  70. 4
      modules/repofiles/update.go
  71. 2
      modules/repofiles/update_test.go
  72. 6
      modules/repofiles/verification.go
  73. 44
      modules/structs/admin_user.go
  74. 27
      modules/structs/attachment.go
  75. 2
      modules/structs/doc.go
  76. 11
      modules/structs/fork.go
  77. 2
      modules/structs/git_blob.go
  78. 20
      modules/structs/git_hook.go
  79. 80
      modules/structs/hook.go
  80. 67
      modules/structs/issue.go
  81. 35
      modules/structs/issue_comment.go
  82. 36
      modules/structs/issue_label.go
  83. 39
      modules/structs/issue_milestone.go
  84. 30
      modules/structs/issue_tracked_time.go
  85. 2
      modules/structs/lfs_lock.go
  86. 8
      modules/structs/miscellaneous.go
  87. 36
      modules/structs/org.go
  88. 10
      modules/structs/org_member.go
  89. 2
      modules/structs/org_team.go
  90. 61
      modules/structs/pull.go
  91. 50
      modules/structs/release.go
  92. 109
      modules/structs/repo.go
  93. 11
      modules/structs/repo_branch.go
  94. 10
      modules/structs/repo_collaborator.go
  95. 12
      modules/structs/repo_commit.go
  96. 12
      modules/structs/repo_file.go
  97. 41
      modules/structs/repo_key.go
  98. 19
      modules/structs/repo_refs.go
  99. 12
      modules/structs/repo_tag.go
  100. 18
      modules/structs/repo_tree.go

1
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

4
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=

2
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"
)

2
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"
)

2
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"
)

2
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) {

2
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"
)

2
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"
)

2
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"
)

2
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"
)

2
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) {

2
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"
)

2
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"
)

2
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"
)

2
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"
)

2
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"
)

2
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"
)

2
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) {

2
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"
)

2
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"
)

2
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"
)

2
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"
)

2
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"
)

2
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"
)

2
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"
)

2
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

2
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"
)

2
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"
)

2
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) {

2
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"
)

2
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"
)

2
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"
)

2
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"
)

4
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))
}

2
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"

2
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"

2
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"

2
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"
)

2
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"

2
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})")

2
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"
)

2
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"
)

2
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"
)

2
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"

2
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"
)

2
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"

2
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"
)

2
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"

2
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"

2
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"
)

2
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"

2
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"
)

2
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"
)

2
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 (

2
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 (

2
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

2
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 (

2
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"
)

2
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.

2
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.

2
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"
)

2
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

6
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",

2
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

2
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"
)

2
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

2
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"
)

2
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.

2
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"
)

4
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

2
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"
)

6
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

44
vendor/code.gitea.io/sdk/gitea/admin_user.go → 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)
}

27
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"`
}

2
vendor/code.gitea.io/sdk/gitea/doc.go → 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

11
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"`
}

2
vendor/code.gitea.io/sdk/gitea/git_blob.go → 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 {

20
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"`
}

80
vendor/code.gitea.io/sdk/gitea/hook.go → 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)

67
vendor/code.gitea.io/sdk/gitea/issue.go → 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

35
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"`
}

36
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