Browse Source

Move sdk structs to modules/structs (#6905)

* move sdk structs to moduels/structs

* fix tests

* fix fmt

* fix swagger

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

+ 0
- 1
go.mod View File

@ -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

+ 0
- 4
go.sum View File

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

+ 1
- 1
integrations/api_admin_test.go View File

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

+ 1
- 1
integrations/api_branch_test.go View File

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

+ 1
- 1
integrations/api_comment_test.go View File

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

+ 1
- 1
integrations/api_fork_test.go View File

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

+ 1
- 1
integrations/api_gpg_keys_test.go View File

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

+ 1
- 1
integrations/api_helper_for_declarative_test.go View File

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

+ 1
- 1
integrations/api_issue_label_test.go View File

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

+ 1
- 1
integrations/api_issue_test.go View File

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

+ 1
- 1
integrations/api_keys_test.go View File

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

+ 1
- 1
integrations/api_org_test.go View File

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

+ 1
- 1
integrations/api_pull_test.go View File

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

+ 1
- 1
integrations/api_releases_test.go View File

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

+ 1
- 1
integrations/api_repo_file_content_test.go View File

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

+ 1
- 1
integrations/api_repo_file_create_test.go View File

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

+ 1
- 1
integrations/api_repo_file_delete_test.go View File

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

+ 1
- 1
integrations/api_repo_file_helpers.go View File

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

+ 1
- 1
integrations/api_repo_file_update_test.go View File

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

+ 1
- 1
integrations/api_repo_git_blobs_test.go View File

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

+ 1
- 1
integrations/api_repo_git_hook_test.go View File

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

+ 1
- 1
integrations/api_repo_lfs_locks_test.go View File

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

+ 1
- 1
integrations/api_repo_tags_test.go View File

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

+ 1
- 1
integrations/api_repo_test.go View File

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

+ 1
- 1
integrations/api_team_test.go View File

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

+ 1
- 1
integrations/api_token_test.go View File

@ -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

+ 1
- 1
integrations/api_user_orgs_test.go View File

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

+ 1
- 1
integrations/api_user_search_test.go View File

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

+ 1
- 1
integrations/benchmarks_test.go View File

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

+ 1
- 1
integrations/links_test.go View File

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

+ 1
- 1
integrations/pull_status_test.go View File

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

+ 1
- 1
integrations/repo_commits_test.go View File

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

+ 1
- 1
integrations/ssh_key_test.go View File

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

+ 2
- 2
integrations/version_test.go View File

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

+ 1
- 1
models/action.go View File

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

+ 1
- 1
models/attachment.go View File

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

+ 1
- 1
models/issue.go View File

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

+ 1
- 1
models/issue_assignees.go View File

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

+ 1
- 1
models/issue_comment.go View File

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

+ 1
- 1
models/issue_label.go View File

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

+ 1
- 1
models/issue_label_test.go View File

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

+ 1
- 1
models/issue_milestone.go View File

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

+ 1
- 1
models/issue_milestone_test.go View File

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

+ 1
- 1
models/issue_tracked_time.go View File

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

+ 1
- 1
models/lfs_lock.go View File

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

+ 1
- 1
models/pull.go View File

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

+ 1
- 1
models/release.go View File

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

+ 1
- 1
models/repo.go View File

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

+ 1
- 1
models/review.go View File

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

+ 1
- 1
models/status.go View File

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

+ 1
- 1
models/user.go View File

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

+ 1
- 1
models/webhook.go View File

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

+ 1
- 1
models/webhook_dingtalk.go View File

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

+ 1
- 1
models/webhook_discord.go View File

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

+ 1
- 1
models/webhook_msteams.go View File

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

+ 1
- 1
models/webhook_slack.go View File

@ -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

+ 1
- 1
models/webhook_telegram.go View File

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

+ 1
- 1
models/webhook_test.go View File

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

+ 1
- 1
modules/lfs/locks.go View File

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

+ 1
- 1
modules/repofiles/blob.go View File

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

+ 1
- 1
modules/repofiles/blob_test.go View File

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

+ 1
- 1
modules/repofiles/content.go View File

@ -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

+ 3
- 3
modules/repofiles/content_test.go View File

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

+ 1
- 1
modules/repofiles/delete.go View File

@ -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

+ 1
- 1
modules/repofiles/delete_test.go View File

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

+ 1
- 1
modules/repofiles/file.go View File

@ -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

+ 1
- 1
modules/repofiles/file_test.go View File

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

+ 1
- 1
modules/repofiles/tree.go View File

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

+ 1
- 1
modules/repofiles/tree_test.go View File

@ -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
- 2
modules/repofiles/update.go View File

@ -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

+ 1
- 1
modules/repofiles/update_test.go View File

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

+ 3
- 3
modules/repofiles/verification.go View File

@ -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

vendor/code.gitea.io/sdk/gitea/admin_user.go → modules/structs/admin_user.go View File

@ -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
- 0
modules/structs/attachment.go View File

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

vendor/code.gitea.io/sdk/gitea/doc.go → modules/structs/doc.go View File

@ -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
- 0
modules/structs/fork.go View File

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

vendor/code.gitea.io/sdk/gitea/git_blob.go → modules/structs/git_blob.go View File

@ -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
- 0
modules/structs/git_hook.go View File

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

vendor/code.gitea.io/sdk/gitea/hook.go → modules/structs/hook.go View File

@ -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)

vendor/code.gitea.io/sdk/gitea/issue.go → modules/structs/issue.go View File

@ -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
- 0
modules/structs/issue_comment.go View File

@ -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
- 0
modules/structs/issue_label.go View File

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

+ 39
- 0
modules/structs/issue_milestone.go View File

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

+ 30
- 0
modules/structs/issue_tracked_time.go View File

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

vendor/code.gitea.io/sdk/gitea/lfs_lock.go → modules/structs/lfs_lock.go View File

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

vendor/code.gitea.io/sdk/gitea/miscellaneous.go → modules/structs/miscellaneous.go View File

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

vendor/code.gitea.io/sdk/gitea/org.go → modules/structs/org.go View File

@ -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
}

+ 10
- 0
modules/structs/org_member.go View File

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

vendor/code.gitea.io/sdk/gitea/org_team.go → modules/structs/org_team.go View File

@ -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 {

vendor/code.gitea.io/sdk/gitea/pull.go → modules/structs/pull.go View File

@ -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
}

+ 50
- 0
modules/structs/release.go View File

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

vendor/code.gitea.io/sdk/gitea/repo.go → modules/structs/repo.go View File

@ -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
}

+ 11
- 0
modules/structs/repo_branch.go View File

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

+ 10
- 0
modules/structs/repo_collaborator.go View File

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

vendor/code.gitea.io/sdk/gitea/repo_commit.go → modules/structs/repo_commit.go View File

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

vendor/code.gitea.io/sdk/gitea/repo_file.go → modules/structs/repo_file.go View File

@ -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 {

+ 41
- 0
modules/structs/repo_key.go View File

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

+ 19
- 0
modules/structs/repo_refs.go View File

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

vendor/code.gitea.io/sdk/gitea/repo_tag.go → modules/structs/repo_tag.go View File

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

vendor/code.gitea.io/sdk/gitea/repo_tree.go → modules/structs/repo_tree.go View File

@ -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
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save