From 91d38496fe7ed1219edb9687325d956265af6dda Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 May 2025 07:18:08 -0700 Subject: [PATCH] Bump code.gitea.io/sdk/gitea from 0.20.0 to 0.21.0 (#516) Bumps code.gitea.io/sdk/gitea from 0.20.0 to 0.21.0. --- updated-dependencies: - dependency-name: code.gitea.io/sdk/gitea dependency-version: 0.21.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: gabrie30 --- go.mod | 6 +- go.sum | 12 +- vendor/code.gitea.io/sdk/gitea/attachment.go | 2 +- vendor/code.gitea.io/sdk/gitea/client.go | 2 +- vendor/code.gitea.io/sdk/gitea/hook.go | 18 +-- .../code.gitea.io/sdk/gitea/issue_timeline.go | 44 ++++++ vendor/code.gitea.io/sdk/gitea/repo.go | 130 +++++++++++------- vendor/code.gitea.io/sdk/gitea/repo_file.go | 1 + .../sdk/gitea/repo_tag_protection.go | 125 +++++++++++++++++ vendor/code.gitea.io/sdk/gitea/repo_tree.go | 24 +++- vendor/code.gitea.io/sdk/gitea/version.go | 2 +- vendor/github.com/42wim/httpsig/algorithms.go | 3 + .../hashicorp/go-version/CHANGELOG.md | 19 +++ .../github.com/hashicorp/go-version/LICENSE | 2 + .../github.com/hashicorp/go-version/README.md | 2 +- .../hashicorp/go-version/constraint.go | 6 +- .../hashicorp/go-version/version.go | 46 ++++++- .../go-version/version_collection.go | 3 + vendor/modules.txt | 8 +- 19 files changed, 366 insertions(+), 89 deletions(-) create mode 100644 vendor/code.gitea.io/sdk/gitea/issue_timeline.go create mode 100644 vendor/code.gitea.io/sdk/gitea/repo_tag_protection.go diff --git a/go.mod b/go.mod index 1cb6d97..74311f1 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.1 toolchain go1.24.1 require ( - code.gitea.io/sdk/gitea v0.20.0 + code.gitea.io/sdk/gitea v0.21.0 github.com/MichaelMure/go-term-markdown v0.1.4 github.com/bradleyfalzon/ghinstallation/v2 v2.15.0 github.com/briandowns/spinner v1.23.2 @@ -22,7 +22,7 @@ require ( ) require ( - github.com/42wim/httpsig v1.2.1 // indirect + github.com/42wim/httpsig v1.2.2 // indirect github.com/MichaelMure/go-term-text v0.3.1 // indirect github.com/alecthomas/chroma v0.7.1 // indirect github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect @@ -39,7 +39,7 @@ require ( github.com/google/go-querystring v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-retryablehttp v0.7.7 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/kyokomi/emoji/v2 v2.2.8 // indirect github.com/lucasb-eyer/go-colorful v1.0.3 // indirect diff --git a/go.sum b/go.sum index ee2bb5b..4814070 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= -code.gitea.io/sdk/gitea v0.20.0 h1:Zm/QDwwZK1awoM4AxdjeAQbxolzx2rIP8dDfmKu+KoU= -code.gitea.io/sdk/gitea v0.20.0/go.mod h1:faouBHC/zyx5wLgjmRKR62ydyvMzwWf3QnU0bH7Cw6U= -github.com/42wim/httpsig v1.2.1 h1:oLBxptMe9U4ZmSGtkosT8Dlfg31P3VQnAGq6psXv82Y= -github.com/42wim/httpsig v1.2.1/go.mod h1:P/UYo7ytNBFwc+dg35IubuAUIs8zj5zzFIgUCEl55WY= +code.gitea.io/sdk/gitea v0.21.0 h1:69n6oz6kEVHRo1+APQQyizkhrZrLsTLXey9142pfkD4= +code.gitea.io/sdk/gitea v0.21.0/go.mod h1:tnBjVhuKJCn8ibdyyhvUyxrR1Ca2KHEoTWoukNhXQPA= +github.com/42wim/httpsig v1.2.2 h1:ofAYoHUNs/MJOLqQ8hIxeyz2QxOz8qdSVvp3PX/oPgA= +github.com/42wim/httpsig v1.2.2/go.mod h1:P/UYo7ytNBFwc+dg35IubuAUIs8zj5zzFIgUCEl55WY= github.com/MichaelMure/go-term-markdown v0.1.4 h1:Ir3kBXDUtOX7dEv0EaQV8CNPpH+T7AfTh0eniMOtNcs= github.com/MichaelMure/go-term-markdown v0.1.4/go.mod h1:EhcA3+pKYnlUsxYKBJ5Sn1cTQmmBMjeNlpV8nRb+JxA= github.com/MichaelMure/go-term-text v0.3.1 h1:Kw9kZanyZWiCHOYu9v/8pWEgDQ6UVN9/ix2Vd2zzWf0= @@ -67,8 +67,8 @@ github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB1 github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU= github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= diff --git a/vendor/code.gitea.io/sdk/gitea/attachment.go b/vendor/code.gitea.io/sdk/gitea/attachment.go index f02c721..c19a82c 100644 --- a/vendor/code.gitea.io/sdk/gitea/attachment.go +++ b/vendor/code.gitea.io/sdk/gitea/attachment.go @@ -78,7 +78,7 @@ func (c *Client) CreateReleaseAttachment(user, repo string, release int64, file attachment := new(Attachment) resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/releases/%d/assets", user, repo, release), - http.Header{"Content-Type": {writer.FormDataContentType()}}, body, &attachment) + http.Header{"Content-Type": []string{writer.FormDataContentType()}}, body, &attachment) return attachment, resp, err } diff --git a/vendor/code.gitea.io/sdk/gitea/client.go b/vendor/code.gitea.io/sdk/gitea/client.go index 47c83c4..f45961a 100644 --- a/vendor/code.gitea.io/sdk/gitea/client.go +++ b/vendor/code.gitea.io/sdk/gitea/client.go @@ -18,7 +18,7 @@ import ( "strings" "sync" - "github.com/hashicorp/go-version" + version "github.com/hashicorp/go-version" ) var jsonHeader = http.Header{"content-type": []string{"application/json"}} diff --git a/vendor/code.gitea.io/sdk/gitea/hook.go b/vendor/code.gitea.io/sdk/gitea/hook.go index fe42b7c..f91b60c 100644 --- a/vendor/code.gitea.io/sdk/gitea/hook.go +++ b/vendor/code.gitea.io/sdk/gitea/hook.go @@ -14,14 +14,16 @@ import ( // Hook a hook is a web hook when one repository changed type Hook struct { - ID int64 `json:"id"` - Type string `json:"type"` - URL string `json:"-"` - Config map[string]string `json:"config"` - Events []string `json:"events"` - Active bool `json:"active"` - Updated time.Time `json:"updated_at"` - Created time.Time `json:"created_at"` + ID int64 `json:"id"` + Type string `json:"type"` + URL string `json:"-"` + BranchFilter string `json:"branch_filter"` + Config map[string]string `json:"config"` + Events []string `json:"events"` + AuthorizationHeader string `json:"authorization_header"` + Active bool `json:"active"` + Updated time.Time `json:"updated_at"` + Created time.Time `json:"created_at"` } // HookType represent all webhook types gitea currently offer diff --git a/vendor/code.gitea.io/sdk/gitea/issue_timeline.go b/vendor/code.gitea.io/sdk/gitea/issue_timeline.go new file mode 100644 index 0000000..586087d --- /dev/null +++ b/vendor/code.gitea.io/sdk/gitea/issue_timeline.go @@ -0,0 +1,44 @@ +// Copyright 2025 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package gitea + +import ( + "fmt" + "net/url" + "time" +) + +// Comment represents a comment on a commit or issue +type TimelineComment 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"` + OriginalAuthor string `json:"original_author"` + OriginalAuthorID int64 `json:"original_author_id"` + Body string `json:"body"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` + Type string `json:"type"` + Label []*Label `json:"label"` + NewMilestone *Milestone `json:"milestone"` + OldMilestone *Milestone `json:"old_milestone"` + NewTitle string `json:"new_title"` + OldTitle string `json:"old_title"` +} + +// ListIssueTimeline list timeline on an issue. +func (c *Client) ListIssueTimeline(owner, repo string, index int64, opt ListIssueCommentOptions) ([]*TimelineComment, *Response, error) { + if err := escapeValidatePathSegments(&owner, &repo); err != nil { + return nil, nil, err + } + opt.setDefaults() + link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues/%d/timeline", owner, repo, index)) + link.RawQuery = opt.QueryEncode() + timelineComments := make([]*TimelineComment, 0, opt.PageSize) + resp, err := c.getParsedResponse("GET", link.String(), nil, nil, &timelineComments) + return timelineComments, resp, err +} diff --git a/vendor/code.gitea.io/sdk/gitea/repo.go b/vendor/code.gitea.io/sdk/gitea/repo.go index 79aa52d..b8dba5b 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo.go +++ b/vendor/code.gitea.io/sdk/gitea/repo.go @@ -48,56 +48,72 @@ type ExternalWiki struct { ExternalWikiURL string `json:"external_wiki_url"` } +// ProjectsMode is used specify which kinds of projects to show for a repository +type ProjectsMode string + +const ( + // ProjectsModeRepo only allow repo-level projects + ProjectsModeRepo ProjectsMode = "repo" + // ProjectsModeOwner only allow owner projects + ProjectsModeOwner ProjectsMode = "owner" + // ProjectsModeAll only allow all projects + ProjectsModeAll ProjectsMode = "all" +) + // Repository represents a repository type Repository struct { - ID int64 `json:"id"` - Owner *User `json:"owner"` - Name string `json:"name"` - FullName string `json:"full_name"` - Description string `json:"description"` - Empty bool `json:"empty"` - Private bool `json:"private"` - Fork bool `json:"fork"` - Template bool `json:"template"` - Parent *Repository `json:"parent"` - Mirror bool `json:"mirror"` - Size int `json:"size"` - HTMLURL string `json:"html_url"` - SSHURL string `json:"ssh_url"` - CloneURL string `json:"clone_url"` - OriginalURL string `json:"original_url"` - Website string `json:"website"` - Stars int `json:"stars_count"` - Forks int `json:"forks_count"` - Watchers int `json:"watchers_count"` - OpenIssues int `json:"open_issues_count"` - OpenPulls int `json:"open_pr_counter"` - Releases int `json:"release_counter"` - DefaultBranch string `json:"default_branch"` - Archived bool `json:"archived"` - Created time.Time `json:"created_at"` - Updated time.Time `json:"updated_at"` - Permissions *Permission `json:"permissions,omitempty"` - HasIssues bool `json:"has_issues"` - InternalTracker *InternalTracker `json:"internal_tracker,omitempty"` - ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"` - HasWiki bool `json:"has_wiki"` - ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"` - HasPullRequests bool `json:"has_pull_requests"` - HasProjects bool `json:"has_projects"` - HasReleases bool `json:"has_releases,omitempty"` - HasPackages bool `json:"has_packages,omitempty"` - HasActions bool `json:"has_actions,omitempty"` - IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"` - AllowMerge bool `json:"allow_merge_commits"` - AllowRebase bool `json:"allow_rebase"` - AllowRebaseMerge bool `json:"allow_rebase_explicit"` - AllowSquash bool `json:"allow_squash_merge"` - AvatarURL string `json:"avatar_url"` - Internal bool `json:"internal"` - MirrorInterval string `json:"mirror_interval"` - MirrorUpdated time.Time `json:"mirror_updated,omitempty"` - DefaultMergeStyle MergeStyle `json:"default_merge_style"` + ID int64 `json:"id"` + Owner *User `json:"owner"` + Name string `json:"name"` + FullName string `json:"full_name"` + Description string `json:"description"` + Empty bool `json:"empty"` + Private bool `json:"private"` + Fork bool `json:"fork"` + Template bool `json:"template"` + Parent *Repository `json:"parent"` + Mirror bool `json:"mirror"` + Size int `json:"size"` + HTMLURL string `json:"html_url"` + SSHURL string `json:"ssh_url"` + CloneURL string `json:"clone_url"` + OriginalURL string `json:"original_url"` + Website string `json:"website"` + Stars int `json:"stars_count"` + Forks int `json:"forks_count"` + Watchers int `json:"watchers_count"` + OpenIssues int `json:"open_issues_count"` + OpenPulls int `json:"open_pr_counter"` + Releases int `json:"release_counter"` + DefaultBranch string `json:"default_branch"` + Archived bool `json:"archived"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` + Permissions *Permission `json:"permissions,omitempty"` + HasIssues bool `json:"has_issues"` + InternalTracker *InternalTracker `json:"internal_tracker,omitempty"` + ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"` + HasWiki bool `json:"has_wiki"` + ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"` + HasPullRequests bool `json:"has_pull_requests"` + HasProjects bool `json:"has_projects"` + HasReleases bool `json:"has_releases,omitempty"` + HasPackages bool `json:"has_packages,omitempty"` + HasActions bool `json:"has_actions,omitempty"` + IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"` + AllowFastForwardOnlyMerge bool `json:"allow_fast_forward_only_merge"` + AllowMerge bool `json:"allow_merge_commits"` + AllowRebase bool `json:"allow_rebase"` + AllowRebaseMerge bool `json:"allow_rebase_explicit"` + AllowSquash bool `json:"allow_squash_merge"` + AvatarURL string `json:"avatar_url"` + Internal bool `json:"internal"` + MirrorInterval string `json:"mirror_interval"` + MirrorUpdated time.Time `json:"mirror_updated,omitempty"` + DefaultMergeStyle MergeStyle `json:"default_merge_style"` + ProjectsMode *ProjectsMode `json:"projects_mode"` + DefaultDeleteBranchAfterMerge bool `json:"default_delete_branch_after_merge"` + ObjectFormatName string `json:"object_format_name"` } // RepoType represent repo type @@ -324,6 +340,8 @@ type CreateRepoOption struct { DefaultBranch string `json:"default_branch"` // TrustModel of the repository TrustModel TrustModel `json:"trust_model"` + // ObjectFormatName of the repository, could be sha1 or sha256, depends on Gitea version + ObjectFormatName string `json:"object_format_name"` } // Validate the CreateRepoOption struct @@ -345,6 +363,11 @@ func (opt CreateRepoOption) Validate(c *Client) error { return err } } + if len(opt.ObjectFormatName) != 0 { + if opt.ObjectFormatName != "sha1" && opt.ObjectFormatName != "sha256" { + return fmt.Errorf("object format must be sha1 or sha256") + } + } return nil } @@ -353,6 +376,10 @@ func (c *Client) CreateRepo(opt CreateRepoOption) (*Repository, *Response, error if err := opt.Validate(c); err != nil { return nil, nil, err } + // object_format_name is only supported on gitea >= 1.22.0 + if c.checkServerVersionGreaterThanOrEqual(version1_22_0) != nil { + opt.ObjectFormatName = "" + } body, err := json.Marshal(&opt) if err != nil { return nil, nil, err @@ -434,6 +461,8 @@ type EditRepoOption struct { HasActions *bool `json:"has_actions,omitempty"` // either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. `has_pull_requests` must be `true`. IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace_conflicts,omitempty"` + // either `true` to allow merging pull requests with fast-forward only strategy, or `false` to prevent merging pull requests with a fast-forward only strategy. `has_pull_requests` must be `true`. + AllowFastForwardOnlyMerge *bool `json:"allow_fast_forward_only_merge"` // either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. `has_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. `has_pull_requests` must be `true`. @@ -452,7 +481,10 @@ type EditRepoOption struct { AutodetectManualMerge *bool `json:"autodetect_manual_merge,omitempty"` // set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", or "squash". `has_pull_requests` must be `true`. DefaultMergeStyle *MergeStyle `json:"default_merge_style,omitempty"` - // set to `true` to archive this repository. + // set to a projects mode to be used by this repository, to specify which kinds of projects to show: "repo" to only allow repo-level projects, "owner" to only allow owner projects, "all" to allow all projects. `has_projects` must be `true`. + ProjectsMode *ProjectsMode `json:"projects_mode"` + // set to `true` to delete the pull request branch after merge by default. `has_pull_requests` must be `true`. + DefaultDeleteBranchAfterMerge *bool `json:"default_delete_branch_after_merge"` } // EditRepo edit the properties of a repository diff --git a/vendor/code.gitea.io/sdk/gitea/repo_file.go b/vendor/code.gitea.io/sdk/gitea/repo_file.go index 79bbeb1..9285be2 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_file.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_file.go @@ -90,6 +90,7 @@ type ContentsResponse struct { // `submodule_git_url` is populated when `type` is `submodule`, otherwise null SubmoduleGitURL *string `json:"submodule_git_url"` Links *FileLinksResponse `json:"_links"` + LastCommitSha string `json:"last_commit_sha"` } // FileCommitResponse contains information generated from a Git commit for a repo's file. diff --git a/vendor/code.gitea.io/sdk/gitea/repo_tag_protection.go b/vendor/code.gitea.io/sdk/gitea/repo_tag_protection.go new file mode 100644 index 0000000..02cd372 --- /dev/null +++ b/vendor/code.gitea.io/sdk/gitea/repo_tag_protection.go @@ -0,0 +1,125 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package gitea + +import ( + "bytes" + "encoding/json" + "fmt" + "net/url" + "strconv" + "time" +) + +// TagProtection represents a tag protection for a repository +type TagProtection struct { + Id int64 `json:"id"` + NamePattern string `json:"name_pattern"` + WhitelistUsernames []string `json:"whitelist_usernames"` + WhitelistTeams []string `json:"whitelist_teams"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` +} + +// CreateTagProtectionOption options for creating a tag protection +type CreateTagProtectionOption struct { + NamePattern string `json:"name_pattern"` + WhitelistUsernames []string `json:"whitelist_usernames"` + WhitelistTeams []string `json:"whitelist_teams"` +} + +// EditTagProtectionOption options for editing a tag protection +type EditTagProtectionOption struct { + NamePattern *string `json:"name_pattern"` + WhitelistUsernames []string `json:"whitelist_usernames"` + WhitelistTeams []string `json:"whitelist_teams"` +} + +// ListRepoTagsOptions options for listing a repository's tags +type ListRepoTagProtectionsOptions struct { + ListOptions +} + +// ListTagProtection list tag protections for a repository +func (c *Client) ListTagProtection(owner, repo string, opt ListRepoTagProtectionsOptions) ([]*TagProtection, *Response, error) { + if err := escapeValidatePathSegments(&owner, &repo); err != nil { + return nil, nil, err + } + if err := c.checkServerVersionGreaterThanOrEqual(version1_23_0); err != nil { + return nil, nil, err + } + + tps := make([]*TagProtection, 0, opt.PageSize) + link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/tag_protections", owner, repo)) + link.RawQuery = opt.getURLQuery().Encode() + resp, err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, &tps) + return tps, resp, err +} + +// GetTagProtection gets a tag protection +func (c *Client) GetTagProtection(owner, repo string, id int64) (*TagProtection, *Response, error) { + sid := strconv.FormatInt(id, 10) + if err := escapeValidatePathSegments(&owner, &repo, &sid); err != nil { + return nil, nil, err + } + if err := c.checkServerVersionGreaterThanOrEqual(version1_23_0); err != nil { + return nil, nil, err + } + tp := new(TagProtection) + resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/tag_protections/%d", owner, repo, id), jsonHeader, nil, tp) + return tp, resp, err +} + +// CreateTagProtection creates a tag protection for a repo +func (c *Client) CreateTagProtection(owner, repo string, opt CreateTagProtectionOption) (*TagProtection, *Response, error) { + if err := escapeValidatePathSegments(&owner, &repo); err != nil { + return nil, nil, err + } + if err := c.checkServerVersionGreaterThanOrEqual(version1_23_0); err != nil { + return nil, nil, err + } + + tp := new(TagProtection) + body, err := json.Marshal(&opt) + if err != nil { + return nil, nil, err + } + resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/tag_protections", owner, repo), jsonHeader, bytes.NewReader(body), tp) + return tp, resp, err +} + +// EditTagProtection edits a tag protection for a repo +func (c *Client) EditTagProtection(owner, repo string, id int64, opt EditTagProtectionOption) (*TagProtection, *Response, error) { + sid := strconv.FormatInt(id, 10) + if err := escapeValidatePathSegments(&owner, &repo, &sid); err != nil { + return nil, nil, err + } + if err := c.checkServerVersionGreaterThanOrEqual(version1_23_0); err != nil { + return nil, nil, err + } + + tp := new(TagProtection) + + body, err := json.Marshal(&opt) + if err != nil { + return nil, nil, err + } + resp, err := c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/tag_protections/%d", owner, repo, id), jsonHeader, bytes.NewReader(body), tp) + return tp, resp, err +} + +// DeleteTagProtection deletes a tag protection for a repo +func (c *Client) DeleteTagProtection(owner, repo string, id int64) (*Response, error) { + sid := strconv.FormatInt(id, 10) + if err := escapeValidatePathSegments(&owner, &repo, &sid); err != nil { + return nil, err + } + if err := c.checkServerVersionGreaterThanOrEqual(version1_23_0); err != nil { + return nil, err + } + + _, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/tag_protections/%d", owner, repo, id), jsonHeader, nil) + return resp, err +} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_tree.go b/vendor/code.gitea.io/sdk/gitea/repo_tree.go index c9ffc55..7defbb3 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_tree.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_tree.go @@ -28,16 +28,26 @@ type GitTreeResponse struct { 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, *Response, error) { - if err := escapeValidatePathSegments(&user, &repo, &ref); err != nil { +type ListTreeOptions struct { + ListOptions + // Ref can be branch/tag/commit. required + // e.g.: "master" + Ref string + // Recursive if true will return the tree in a recursive fashion + Recursive bool +} + +// GetTrees get trees of repository, +func (c *Client) GetTrees(user, repo string, opt ListTreeOptions) (*GitTreeResponse, *Response, error) { + if err := escapeValidatePathSegments(&user, &repo, &opt.Ref); err != nil { return nil, nil, err } trees := new(GitTreeResponse) - path := fmt.Sprintf("/repos/%s/%s/git/trees/%s", user, repo, ref) - if recursive { - path += "?recursive=1" + opt.setDefaults() + path := fmt.Sprintf("/repos/%s/%s/git/trees/%s?%s", user, repo, opt.Ref, opt.getURLQuery().Encode()) + + if opt.Recursive { + path += "&recursive=1" } resp, err := c.getParsedResponse("GET", path, nil, nil, trees) return trees, resp, err diff --git a/vendor/code.gitea.io/sdk/gitea/version.go b/vendor/code.gitea.io/sdk/gitea/version.go index a0c18b4..5357e7d 100644 --- a/vendor/code.gitea.io/sdk/gitea/version.go +++ b/vendor/code.gitea.io/sdk/gitea/version.go @@ -8,7 +8,7 @@ import ( "fmt" "strings" - "github.com/hashicorp/go-version" + version "github.com/hashicorp/go-version" ) // ServerVersion returns the version of the server diff --git a/vendor/github.com/42wim/httpsig/algorithms.go b/vendor/github.com/42wim/httpsig/algorithms.go index 8972ddc..4e5e191 100644 --- a/vendor/github.com/42wim/httpsig/algorithms.go +++ b/vendor/github.com/42wim/httpsig/algorithms.go @@ -125,6 +125,9 @@ type hmacAlgorithm struct { func (h *hmacAlgorithm) Sign(sig, key []byte) ([]byte, error) { hs, err := h.fn(key) + if err != nil { + return nil, err + } if err = setSig(hs, sig); err != nil { return nil, err } diff --git a/vendor/github.com/hashicorp/go-version/CHANGELOG.md b/vendor/github.com/hashicorp/go-version/CHANGELOG.md index 5f16dd1..6d48174 100644 --- a/vendor/github.com/hashicorp/go-version/CHANGELOG.md +++ b/vendor/github.com/hashicorp/go-version/CHANGELOG.md @@ -1,3 +1,22 @@ +# 1.7.0 (May 24, 2024) + +ENHANCEMENTS: + +- Remove `reflect` dependency ([#91](https://github.com/hashicorp/go-version/pull/91)) +- Implement the `database/sql.Scanner` and `database/sql/driver.Value` interfaces for `Version` ([#133](https://github.com/hashicorp/go-version/pull/133)) + +INTERNAL: + +- [COMPLIANCE] Add Copyright and License Headers ([#115](https://github.com/hashicorp/go-version/pull/115)) +- [COMPLIANCE] Update MPL-2.0 LICENSE ([#105](https://github.com/hashicorp/go-version/pull/105)) +- Bump actions/cache from 3.0.11 to 3.2.5 ([#116](https://github.com/hashicorp/go-version/pull/116)) +- Bump actions/checkout from 3.2.0 to 3.3.0 ([#111](https://github.com/hashicorp/go-version/pull/111)) +- Bump actions/upload-artifact from 3.1.1 to 3.1.2 ([#112](https://github.com/hashicorp/go-version/pull/112)) +- GHA Migration ([#103](https://github.com/hashicorp/go-version/pull/103)) +- github: Pin external GitHub Actions to hashes ([#107](https://github.com/hashicorp/go-version/pull/107)) +- SEC-090: Automated trusted workflow pinning (2023-04-05) ([#124](https://github.com/hashicorp/go-version/pull/124)) +- update readme ([#104](https://github.com/hashicorp/go-version/pull/104)) + # 1.6.0 (June 28, 2022) FEATURES: diff --git a/vendor/github.com/hashicorp/go-version/LICENSE b/vendor/github.com/hashicorp/go-version/LICENSE index c33dcc7..1409d6a 100644 --- a/vendor/github.com/hashicorp/go-version/LICENSE +++ b/vendor/github.com/hashicorp/go-version/LICENSE @@ -1,3 +1,5 @@ +Copyright (c) 2014 HashiCorp, Inc. + Mozilla Public License, version 2.0 1. Definitions diff --git a/vendor/github.com/hashicorp/go-version/README.md b/vendor/github.com/hashicorp/go-version/README.md index 4d25050..4b7806c 100644 --- a/vendor/github.com/hashicorp/go-version/README.md +++ b/vendor/github.com/hashicorp/go-version/README.md @@ -1,5 +1,5 @@ # Versioning Library for Go -[![Build Status](https://circleci.com/gh/hashicorp/go-version/tree/main.svg?style=svg)](https://circleci.com/gh/hashicorp/go-version/tree/main) +![Build Status](https://github.com/hashicorp/go-version/actions/workflows/go-tests.yml/badge.svg) [![GoDoc](https://godoc.org/github.com/hashicorp/go-version?status.svg)](https://godoc.org/github.com/hashicorp/go-version) go-version is a library for parsing versions and version constraints, diff --git a/vendor/github.com/hashicorp/go-version/constraint.go b/vendor/github.com/hashicorp/go-version/constraint.go index da5d1ac..29bdc4d 100644 --- a/vendor/github.com/hashicorp/go-version/constraint.go +++ b/vendor/github.com/hashicorp/go-version/constraint.go @@ -1,8 +1,10 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package version import ( "fmt" - "reflect" "regexp" "sort" "strings" @@ -199,7 +201,7 @@ func prereleaseCheck(v, c *Version) bool { case cPre && vPre: // A constraint with a pre-release can only match a pre-release version // with the same base segments. - return reflect.DeepEqual(c.Segments64(), v.Segments64()) + return v.equalSegments(c) case !cPre && vPre: // A constraint without a pre-release can only match a version without a diff --git a/vendor/github.com/hashicorp/go-version/version.go b/vendor/github.com/hashicorp/go-version/version.go index e87df69..7c683c2 100644 --- a/vendor/github.com/hashicorp/go-version/version.go +++ b/vendor/github.com/hashicorp/go-version/version.go @@ -1,9 +1,12 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package version import ( "bytes" + "database/sql/driver" "fmt" - "reflect" "regexp" "strconv" "strings" @@ -117,11 +120,8 @@ func (v *Version) Compare(other *Version) int { return 0 } - segmentsSelf := v.Segments64() - segmentsOther := other.Segments64() - // If the segments are the same, we must compare on prerelease info - if reflect.DeepEqual(segmentsSelf, segmentsOther) { + if v.equalSegments(other) { preSelf := v.Prerelease() preOther := other.Prerelease() if preSelf == "" && preOther == "" { @@ -137,6 +137,8 @@ func (v *Version) Compare(other *Version) int { return comparePrereleases(preSelf, preOther) } + segmentsSelf := v.Segments64() + segmentsOther := other.Segments64() // Get the highest specificity (hS), or if they're equal, just use segmentSelf length lenSelf := len(segmentsSelf) lenOther := len(segmentsOther) @@ -160,7 +162,7 @@ func (v *Version) Compare(other *Version) int { // this means Other had the lower specificity // Check to see if the remaining segments in Self are all zeros - if !allZero(segmentsSelf[i:]) { - //if not, it means that Self has to be greater than Other + // if not, it means that Self has to be greater than Other return 1 } break @@ -180,6 +182,21 @@ func (v *Version) Compare(other *Version) int { return 0 } +func (v *Version) equalSegments(other *Version) bool { + segmentsSelf := v.Segments64() + segmentsOther := other.Segments64() + + if len(segmentsSelf) != len(segmentsOther) { + return false + } + for i, v := range segmentsSelf { + if v != segmentsOther[i] { + return false + } + } + return true +} + func allZero(segs []int64) bool { for _, s := range segs { if s != 0 { @@ -405,3 +422,20 @@ func (v *Version) UnmarshalText(b []byte) error { func (v *Version) MarshalText() ([]byte, error) { return []byte(v.String()), nil } + +// Scan implements the sql.Scanner interface. +func (v *Version) Scan(src interface{}) error { + switch src := src.(type) { + case string: + return v.UnmarshalText([]byte(src)) + case nil: + return nil + default: + return fmt.Errorf("cannot scan %T as Version", src) + } +} + +// Value implements the driver.Valuer interface. +func (v *Version) Value() (driver.Value, error) { + return v.String(), nil +} diff --git a/vendor/github.com/hashicorp/go-version/version_collection.go b/vendor/github.com/hashicorp/go-version/version_collection.go index cc888d4..83547fe 100644 --- a/vendor/github.com/hashicorp/go-version/version_collection.go +++ b/vendor/github.com/hashicorp/go-version/version_collection.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package version // Collection is a type that implements the sort.Interface interface diff --git a/vendor/modules.txt b/vendor/modules.txt index 4416443..add1982 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,7 @@ -# code.gitea.io/sdk/gitea v0.20.0 -## explicit; go 1.18 +# code.gitea.io/sdk/gitea v0.21.0 +## explicit; go 1.23 code.gitea.io/sdk/gitea -# github.com/42wim/httpsig v1.2.1 +# github.com/42wim/httpsig v1.2.2 ## explicit; go 1.18 github.com/42wim/httpsig # github.com/MichaelMure/go-term-markdown v0.1.4 @@ -108,7 +108,7 @@ github.com/hashicorp/go-cleanhttp # github.com/hashicorp/go-retryablehttp v0.7.7 ## explicit; go 1.19 github.com/hashicorp/go-retryablehttp -# github.com/hashicorp/go-version v1.6.0 +# github.com/hashicorp/go-version v1.7.0 ## explicit github.com/hashicorp/go-version # github.com/inconshreveable/mousetrap v1.1.0