Documentation
¶
Overview ¶
Package gitcode implements the GitCode Provider for the git-platform-sdk.
It builds on top of the yi-nology/gitcode_api client SDK and adds transport-layer cross-cutting behavior (auth, retry, hooks, logging) provided by the parent project's transport package. All Provider methods are split across the per-responsibility files in this package:
- gitcode.go: constructor + identity (Platform, TestConnection, Capabilities)
- init.go: provider registration with the global registry
- repos.go: ListRepos, GetRepo, CreateRepo, DeleteRepo, UpdateRepo, ForkRepo
- crs.go: Change requests (PRs): Create/Get/List/Merge/Close/Reopen/Update/UpdateLabels/Comments/Commits
- webhooks.go: webhook CRUD + signature validation + event parsing
- branches.go: ListBranches, CreateBranch, DeleteBranch
- diffs.go: GetCRDiff, GetCRFiles, CreateNote/DeleteNote, CreateDiscussion, CreateReview
- commits.go: GetCommit, ListCommits, CompareCommits, CreateCommitStatus
- files.go: GetFileContent, CreateFile, UpdateFile, DeleteFile
- releases.go: ListTags, ListReleases, CreateRelease, GetArchive
- issues.go: IssueManager: issue CRUD, comments, issue-scoped label ops
- search.go: SearchManager: SearchRepos, SearchIssues, SearchUsers
- labels.go: repository label CRUD (LabelManager)
Index ¶
- func New(cfg provider.Config) (provider.Provider, error)
- type Provider
- func (p *Provider) AddIssueLabels(ctx context.Context, owner, repo string, number int, labels []string) error
- func (p *Provider) Capabilities() provider.CapabilitySet
- func (p *Provider) CloseCR(ctx context.Context, owner, repo string, number int) (*provider.ChangeRequest, error)
- func (p *Provider) CloseIssue(ctx context.Context, owner, repo string, number int) (*provider.Issue, error)
- func (p *Provider) CompareCommits(ctx context.Context, owner, repo, base, head string) (*provider.CompareResult, error)
- func (p *Provider) CreateBranch(ctx context.Context, owner, repo, branch, ref string) (*provider.PlatformBranch, error)
- func (p *Provider) CreateCR(ctx context.Context, opts provider.CreateCROptions) (*provider.ChangeRequest, error)
- func (p *Provider) CreateCommitStatus(ctx context.Context, owner, repo, sha string, ...) error
- func (p *Provider) CreateDiscussion(ctx context.Context, owner, repo string, number int, ...) (string, error)
- func (p *Provider) CreateFile(ctx context.Context, owner, repo string, opts provider.FileOptions) (*provider.FileResult, error)
- func (p *Provider) CreateIssue(ctx context.Context, opts provider.CreateIssueOptions) (*provider.Issue, error)
- func (p *Provider) CreateIssueComment(ctx context.Context, owner, repo string, number int, body string) (*provider.IssueComment, error)
- func (p *Provider) CreateLabel(ctx context.Context, owner, repo string, opts provider.CreateLabelOptions) (*provider.Label, error)
- func (p *Provider) CreateNote(ctx context.Context, owner, repo string, number int, body string) (string, error)
- func (p *Provider) CreateRelease(ctx context.Context, owner, repo string, opts provider.CreateReleaseOptions) (*provider.ReleaseInfo, error)
- func (p *Provider) CreateRepo(ctx context.Context, owner string, opts provider.CreateRepoOptions) (*provider.PlatformRepo, error)
- func (p *Provider) CreateReview(ctx context.Context, owner, repo string, number int, ...) (*provider.ReviewResult, error)
- func (p *Provider) CreateWebhook(ctx context.Context, opts provider.CreateWebhookOptions) (*provider.PlatformWebhook, error)
- func (p *Provider) DeleteBranch(ctx context.Context, owner, repo, branch string) error
- func (p *Provider) DeleteFile(ctx context.Context, owner, repo string, opts provider.FileDeleteOptions) (*provider.FileResult, error)
- func (p *Provider) DeleteLabel(ctx context.Context, owner, repo, name string) error
- func (p *Provider) DeleteNote(ctx context.Context, owner, repo string, number int, noteID string) error
- func (p *Provider) DeleteRepo(ctx context.Context, owner, repo string) error
- func (p *Provider) DeleteWebhook(ctx context.Context, owner, repo string, webhookID int64) error
- func (p *Provider) ForkRepo(ctx context.Context, owner, repo string, opts provider.ForkRepoOptions) (*provider.PlatformRepo, error)
- func (p *Provider) GetArchive(ctx context.Context, owner, repo, ref, format string) ([]byte, error)
- func (p *Provider) GetCR(ctx context.Context, owner, repo string, number int) (*provider.ChangeRequest, error)
- func (p *Provider) GetCRDiff(ctx context.Context, owner, repo string, number int) (*provider.MergeDiff, error)
- func (p *Provider) GetCRFiles(ctx context.Context, owner, repo string, number int) ([]*provider.ChangedFile, error)
- func (p *Provider) GetCommit(ctx context.Context, owner, repo, sha string) (*provider.CommitInfo, error)
- func (p *Provider) GetFileContent(ctx context.Context, owner, repo, path, ref string) (string, error)
- func (p *Provider) GetIssue(ctx context.Context, owner, repo string, number int) (*provider.Issue, error)
- func (p *Provider) GetRepo(ctx context.Context, owner, repo string) (*provider.PlatformRepo, error)
- func (p *Provider) ListBranches(ctx context.Context, owner, repo string) ([]*provider.PlatformBranch, error)
- func (p *Provider) ListCRComments(ctx context.Context, owner, repo string, number int) ([]*provider.CRComment, error)
- func (p *Provider) ListCRCommits(ctx context.Context, owner, repo string, number int) ([]*provider.CRCommit, error)
- func (p *Provider) ListCRs(ctx context.Context, opts provider.ListCROptions) ([]*provider.ChangeRequest, int, error)
- func (p *Provider) ListCommits(ctx context.Context, owner, repo string, opts provider.ListCommitsOptions) ([]*provider.CommitInfo, error)
- func (p *Provider) ListIssueComments(ctx context.Context, owner, repo string, number int) ([]*provider.IssueComment, error)
- func (p *Provider) ListIssueLabels(ctx context.Context, owner, repo string) ([]*provider.IssueLabel, error)
- func (p *Provider) ListIssues(ctx context.Context, opts provider.ListIssuesOptions) ([]*provider.Issue, int, error)
- func (p *Provider) ListLabels(ctx context.Context, owner, repo string, opts provider.ListLabelsOptions) ([]*provider.Label, error)
- func (p *Provider) ListReleases(ctx context.Context, owner, repo string) ([]*provider.ReleaseInfo, error)
- func (p *Provider) ListRepos(ctx context.Context, opts provider.ListRepoOptions) ([]*provider.PlatformRepo, error)
- func (p *Provider) ListTags(ctx context.Context, owner, repo string) ([]*provider.TagInfo, error)
- func (p *Provider) ListWebhooks(ctx context.Context, owner, repo string) ([]*provider.PlatformWebhook, error)
- func (p *Provider) MergeCR(ctx context.Context, owner, repo string, number int, ...) (*provider.ChangeRequest, error)
- func (p *Provider) ParseWebhookEvent(r *http.Request, secret string) (*provider.NormalizedEvent, error)
- func (p *Provider) Platform() provider.Platform
- func (p *Provider) RemoveIssueLabel(ctx context.Context, owner, repo string, number int, name string) error
- func (p *Provider) ReopenCR(ctx context.Context, owner, repo string, number int) (*provider.ChangeRequest, error)
- func (p *Provider) ReopenIssue(ctx context.Context, owner, repo string, number int) (*provider.Issue, error)
- func (p *Provider) SearchIssues(ctx context.Context, opts provider.SearchIssuesOptions) ([]*provider.SearchIssueResult, int, error)
- func (p *Provider) SearchRepos(ctx context.Context, opts provider.SearchReposOptions) ([]*provider.SearchRepoResult, int, error)
- func (p *Provider) SearchUsers(ctx context.Context, opts provider.SearchUsersOptions) ([]*provider.SearchUserResult, int, error)
- func (p *Provider) TestConnection(ctx context.Context) (*provider.TestConnectionResult, error)
- func (p *Provider) UpdateCR(ctx context.Context, owner, repo string, number int, ...) (*provider.ChangeRequest, error)
- func (p *Provider) UpdateCRLabels(ctx context.Context, owner, repo string, number int, labels []string) error
- func (p *Provider) UpdateFile(ctx context.Context, owner, repo string, opts provider.FileOptions) (*provider.FileResult, error)
- func (p *Provider) UpdateIssue(ctx context.Context, owner, repo string, number int, ...) (*provider.Issue, error)
- func (p *Provider) UpdateLabel(ctx context.Context, owner, repo, name string, ...) (*provider.Label, error)
- func (p *Provider) UpdateRepo(ctx context.Context, owner, repo string, opts provider.UpdateRepoOptions) (*provider.PlatformRepo, error)
- func (p *Provider) ValidateWebhookSignature(r *http.Request, secret string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the GitCode implementation of provider.Provider.
func (*Provider) AddIssueLabels ¶
func (p *Provider) AddIssueLabels(ctx context.Context, owner, repo string, number int, labels []string) error
AddIssueLabels implements provider.IssueManager.
func (*Provider) Capabilities ¶ added in v0.38.0
func (p *Provider) Capabilities() provider.CapabilitySet
Capabilities implements provider.Provider. GitCode implements the optional IssueManager, SearchManager, and LabelManager interfaces (see issues.go, search.go, labels.go).
func (*Provider) CloseCR ¶
func (p *Provider) CloseCR(ctx context.Context, owner, repo string, number int) (*provider.ChangeRequest, error)
CloseCR implements provider.ChangeRequestManager.
func (*Provider) CloseIssue ¶
func (p *Provider) CloseIssue(ctx context.Context, owner, repo string, number int) (*provider.Issue, error)
CloseIssue implements provider.IssueManager.
func (*Provider) CompareCommits ¶
func (p *Provider) CompareCommits(ctx context.Context, owner, repo, base, head string) (*provider.CompareResult, error)
CompareCommits implements provider.CommitManager.
func (*Provider) CreateBranch ¶
func (p *Provider) CreateBranch(ctx context.Context, owner, repo, branch, ref string) (*provider.PlatformBranch, error)
CreateBranch implements provider.BranchManager.
func (*Provider) CreateCR ¶
func (p *Provider) CreateCR(ctx context.Context, opts provider.CreateCROptions) (*provider.ChangeRequest, error)
CreateCR implements provider.ChangeRequestManager.
func (*Provider) CreateCommitStatus ¶
func (p *Provider) CreateCommitStatus(ctx context.Context, owner, repo, sha string, opts provider.CommitStatusOptions) error
CreateCommitStatus implements provider.CommitManager.
The GitCode platform API (/api/v5) does not expose a commit-status endpoint (equivalent to GitHub's POST /repos/{owner}/{repo}/statuses/{sha}). This is a platform-level limitation, not an SDK gap. If GitCode adds commit-status support in the future, this method should be implemented using the SDK's doRequest helper or raw HTTP.
func (*Provider) CreateDiscussion ¶
func (p *Provider) CreateDiscussion(ctx context.Context, owner, repo string, number int, opts provider.DiscussionOptions) (string, error)
CreateDiscussion implements provider.DiffManager.
func (*Provider) CreateFile ¶
func (p *Provider) CreateFile(ctx context.Context, owner, repo string, opts provider.FileOptions) (*provider.FileResult, error)
CreateFile implements provider.FileManager.
func (*Provider) CreateIssue ¶
func (p *Provider) CreateIssue(ctx context.Context, opts provider.CreateIssueOptions) (*provider.Issue, error)
CreateIssue implements provider.IssueManager.
func (*Provider) CreateIssueComment ¶
func (p *Provider) CreateIssueComment(ctx context.Context, owner, repo string, number int, body string) (*provider.IssueComment, error)
CreateIssueComment implements provider.IssueManager.
func (*Provider) CreateLabel ¶ added in v0.38.0
func (p *Provider) CreateLabel(ctx context.Context, owner, repo string, opts provider.CreateLabelOptions) (*provider.Label, error)
CreateLabel implements provider.LabelManager. GitCode's label API has no description field; opts.Description is ignored.
func (*Provider) CreateNote ¶
func (p *Provider) CreateNote(ctx context.Context, owner, repo string, number int, body string) (string, error)
CreateNote implements provider.DiffManager.
func (*Provider) CreateRelease ¶
func (p *Provider) CreateRelease(ctx context.Context, owner, repo string, opts provider.CreateReleaseOptions) (*provider.ReleaseInfo, error)
CreateRelease implements provider.ReleaseManager.
func (*Provider) CreateRepo ¶
func (p *Provider) CreateRepo(ctx context.Context, owner string, opts provider.CreateRepoOptions) (*provider.PlatformRepo, error)
CreateRepo implements provider.RepoManager.
func (*Provider) CreateReview ¶
func (p *Provider) CreateReview(ctx context.Context, owner, repo string, number int, opts provider.CreateReviewOptions) (*provider.ReviewResult, error)
CreateReview implements provider.DiffManager.
func (*Provider) CreateWebhook ¶
func (p *Provider) CreateWebhook(ctx context.Context, opts provider.CreateWebhookOptions) (*provider.PlatformWebhook, error)
CreateWebhook implements provider.WebhookManager.
func (*Provider) DeleteBranch ¶
DeleteBranch implements provider.BranchManager.
func (*Provider) DeleteFile ¶
func (p *Provider) DeleteFile(ctx context.Context, owner, repo string, opts provider.FileDeleteOptions) (*provider.FileResult, error)
DeleteFile implements provider.FileManager.
func (*Provider) DeleteLabel ¶ added in v0.38.0
DeleteLabel implements provider.LabelManager.
func (*Provider) DeleteNote ¶
func (p *Provider) DeleteNote(ctx context.Context, owner, repo string, number int, noteID string) error
DeleteNote implements provider.DiffManager.
func (*Provider) DeleteRepo ¶
DeleteRepo implements provider.RepoManager.
func (*Provider) DeleteWebhook ¶
DeleteWebhook implements provider.WebhookManager.
func (*Provider) ForkRepo ¶
func (p *Provider) ForkRepo(ctx context.Context, owner, repo string, opts provider.ForkRepoOptions) (*provider.PlatformRepo, error)
ForkRepo implements provider.RepoManager.
func (*Provider) GetArchive ¶
GetArchive implements provider.ReleaseManager.
The GitCode platform API (/api/v5) does not expose an archive download endpoint (equivalent to GitHub's GET /repos/{owner}/{repo}/archive/{ref}.{format}). The SDK does offer ArchiveRepository/GetArchiveStatus for toggling a repo's archived flag, but those manage repository state, not downloadable tarballs. This is a platform-level limitation. If GitCode adds archive downloads in the future, this method should be implemented using raw HTTP to handle the binary response body.
func (*Provider) GetCR ¶
func (p *Provider) GetCR(ctx context.Context, owner, repo string, number int) (*provider.ChangeRequest, error)
GetCR implements provider.ChangeRequestManager.
func (*Provider) GetCRDiff ¶
func (p *Provider) GetCRDiff(ctx context.Context, owner, repo string, number int) (*provider.MergeDiff, error)
GetCRDiff implements provider.DiffManager.
func (*Provider) GetCRFiles ¶
func (p *Provider) GetCRFiles(ctx context.Context, owner, repo string, number int) ([]*provider.ChangedFile, error)
GetCRFiles implements provider.DiffManager.
func (*Provider) GetCommit ¶
func (p *Provider) GetCommit(ctx context.Context, owner, repo, sha string) (*provider.CommitInfo, error)
GetCommit implements provider.CommitManager.
func (*Provider) GetFileContent ¶
func (p *Provider) GetFileContent(ctx context.Context, owner, repo, path, ref string) (string, error)
GetFileContent implements provider.FileManager.
func (*Provider) GetIssue ¶
func (p *Provider) GetIssue(ctx context.Context, owner, repo string, number int) (*provider.Issue, error)
GetIssue implements provider.IssueManager.
func (*Provider) ListBranches ¶
func (p *Provider) ListBranches(ctx context.Context, owner, repo string) ([]*provider.PlatformBranch, error)
ListBranches implements provider.BranchManager.
func (*Provider) ListCRComments ¶
func (p *Provider) ListCRComments(ctx context.Context, owner, repo string, number int) ([]*provider.CRComment, error)
ListCRComments implements provider.ChangeRequestManager.
func (*Provider) ListCRCommits ¶
func (p *Provider) ListCRCommits(ctx context.Context, owner, repo string, number int) ([]*provider.CRCommit, error)
ListCRCommits implements provider.ChangeRequestManager.
func (*Provider) ListCRs ¶
func (p *Provider) ListCRs(ctx context.Context, opts provider.ListCROptions) ([]*provider.ChangeRequest, int, error)
ListCRs implements provider.ChangeRequestManager.
func (*Provider) ListCommits ¶
func (p *Provider) ListCommits(ctx context.Context, owner, repo string, opts provider.ListCommitsOptions) ([]*provider.CommitInfo, error)
ListCommits implements provider.CommitManager.
func (*Provider) ListIssueComments ¶
func (p *Provider) ListIssueComments(ctx context.Context, owner, repo string, number int) ([]*provider.IssueComment, error)
ListIssueComments implements provider.IssueManager.
func (*Provider) ListIssueLabels ¶
func (p *Provider) ListIssueLabels(ctx context.Context, owner, repo string) ([]*provider.IssueLabel, error)
ListIssueLabels implements provider.IssueManager.
func (*Provider) ListIssues ¶
func (p *Provider) ListIssues(ctx context.Context, opts provider.ListIssuesOptions) ([]*provider.Issue, int, error)
ListIssues implements provider.IssueManager.
func (*Provider) ListLabels ¶ added in v0.38.0
func (p *Provider) ListLabels(ctx context.Context, owner, repo string, opts provider.ListLabelsOptions) ([]*provider.Label, error)
ListLabels implements provider.LabelManager. GitCode's list endpoint does not paginate, so opts are accepted but ignored.
func (*Provider) ListReleases ¶
func (p *Provider) ListReleases(ctx context.Context, owner, repo string) ([]*provider.ReleaseInfo, error)
ListReleases implements provider.ReleaseManager.
func (*Provider) ListRepos ¶
func (p *Provider) ListRepos(ctx context.Context, opts provider.ListRepoOptions) ([]*provider.PlatformRepo, error)
ListRepos implements provider.RepoManager.
func (*Provider) ListWebhooks ¶
func (p *Provider) ListWebhooks(ctx context.Context, owner, repo string) ([]*provider.PlatformWebhook, error)
ListWebhooks implements provider.WebhookManager.
func (*Provider) MergeCR ¶
func (p *Provider) MergeCR(ctx context.Context, owner, repo string, number int, opts provider.MergeCROptions) (*provider.ChangeRequest, error)
MergeCR implements provider.ChangeRequestManager.
func (*Provider) ParseWebhookEvent ¶
func (p *Provider) ParseWebhookEvent(r *http.Request, secret string) (*provider.NormalizedEvent, error)
ParseWebhookEvent implements provider.WebhookManager.
func (*Provider) RemoveIssueLabel ¶
func (p *Provider) RemoveIssueLabel(ctx context.Context, owner, repo string, number int, name string) error
RemoveIssueLabel implements provider.IssueManager.
func (*Provider) ReopenCR ¶
func (p *Provider) ReopenCR(ctx context.Context, owner, repo string, number int) (*provider.ChangeRequest, error)
ReopenCR implements provider.ChangeRequestManager.
func (*Provider) ReopenIssue ¶
func (p *Provider) ReopenIssue(ctx context.Context, owner, repo string, number int) (*provider.Issue, error)
ReopenIssue implements provider.IssueManager.
func (*Provider) SearchIssues ¶
func (p *Provider) SearchIssues(ctx context.Context, opts provider.SearchIssuesOptions) ([]*provider.SearchIssueResult, int, error)
SearchIssues implements provider.SearchManager.
func (*Provider) SearchRepos ¶
func (p *Provider) SearchRepos(ctx context.Context, opts provider.SearchReposOptions) ([]*provider.SearchRepoResult, int, error)
SearchRepos implements provider.SearchManager.
func (*Provider) SearchUsers ¶
func (p *Provider) SearchUsers(ctx context.Context, opts provider.SearchUsersOptions) ([]*provider.SearchUserResult, int, error)
SearchUsers implements provider.SearchManager.
func (*Provider) TestConnection ¶
TestConnection implements provider.Provider.
func (*Provider) UpdateCR ¶
func (p *Provider) UpdateCR(ctx context.Context, owner, repo string, number int, opts provider.UpdateCROptions) (*provider.ChangeRequest, error)
UpdateCR implements provider.ChangeRequestManager.
func (*Provider) UpdateCRLabels ¶
func (p *Provider) UpdateCRLabels(ctx context.Context, owner, repo string, number int, labels []string) error
UpdateCRLabels implements provider.ChangeRequestManager.
func (*Provider) UpdateFile ¶
func (p *Provider) UpdateFile(ctx context.Context, owner, repo string, opts provider.FileOptions) (*provider.FileResult, error)
UpdateFile implements provider.FileManager.
func (*Provider) UpdateIssue ¶
func (p *Provider) UpdateIssue(ctx context.Context, owner, repo string, number int, opts provider.UpdateIssueOptions) (*provider.Issue, error)
UpdateIssue implements provider.IssueManager.
func (*Provider) UpdateLabel ¶ added in v0.38.0
func (p *Provider) UpdateLabel(ctx context.Context, owner, repo, name string, opts provider.UpdateLabelOptions) (*provider.Label, error)
UpdateLabel implements provider.LabelManager. GitCode addresses labels by name natively. Its label API has no description field; opts.Description is ignored.
func (*Provider) UpdateRepo ¶
func (p *Provider) UpdateRepo(ctx context.Context, owner, repo string, opts provider.UpdateRepoOptions) (*provider.PlatformRepo, error)
UpdateRepo implements provider.RepoManager.