Documentation
¶
Overview ¶
Package tencentcode implements the Tencent 工蜂 Provider for the git-platform-sdk.
Tencent 工蜂 exposes a GitLab-compatible REST API with some platform- specific extensions (native code reviews, branch protection, repository tree/blob). This package implements the cross-platform provider.Provider interface and additionally exposes a TencentCodeExtras interface for the platform-specific capabilities. All Provider methods are split across the per-responsibility files in this package:
- tencentcode.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 (MRs): Create/Get/List/Close/Merge/Reopen/Update/Comments/Commits
- webhooks.go: webhook CRUD + signature validation + event parsing
- branches.go: ListBranches, CreateBranch, DeleteBranch
- diffs.go: GetCRDiff, GetCRFiles, CreateNote/DeleteNote, CreateDiscussion
- commits.go: GetCommit, ListCommits, CompareCommits, CreateCommitStatus
- files.go: GetFileContent, CreateFile, UpdateFile, DeleteFile
- releases.go: ListTags, ListReleases, CreateRelease, GetReleaseByTag, UpdateRelease, DeleteRelease, GetArchive
- milestones.go: repository milestone CRUD (MilestoneManager)
- extras.go: TencentCodeExtras (native code reviews, commit comments, repository tree, branch protection)
- types.go: gongfeng model -> provider model conversions
Index ¶
- func New(cfg provider.Config) (provider.Provider, error)
- type CodeReview
- type CommitComment
- type CommitDiffOptions
- type CommitRefType
- type CommitRefs
- type CreateCodeReviewOptions
- type CreateCommitCommentOptions
- type InviteReviewerOptions
- type ListCodeReviewsOptions
- type MRReview
- type ProtectBranchOptions
- type ProtectedBranchMember
- type ProtectedBranchMemberOptions
- type Provider
- func (t *Provider) AddProtectedBranchMember(ctx context.Context, owner, repo, branch string, ...) error
- func (t *Provider) CancelMRReview(ctx context.Context, owner, repo string, mrNumber int) error
- func (p *Provider) Capabilities() provider.CapabilitySet
- func (p *Provider) CloseCR(ctx context.Context, owner, repo, number string) (*provider.ChangeRequest, 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 (t *Provider) CreateCodeReview(ctx context.Context, owner, repo string, opts CreateCodeReviewOptions) (*CodeReview, error)
- func (t *Provider) CreateCommitComment(ctx context.Context, owner, repo, sha string, opts CreateCommitCommentOptions) (*CommitComment, error)
- func (p *Provider) CreateCommitStatus(ctx context.Context, owner, repo, sha string, ...) error
- func (p *Provider) CreateDiscussion(ctx context.Context, owner, repo, number string, ...) (string, error)
- func (p *Provider) CreateFile(ctx context.Context, owner, repo string, opts provider.FileOptions) (*provider.FileResult, error)
- func (p *Provider) CreateMilestone(ctx context.Context, owner, repo string, opts provider.CreateMilestoneOptions) (*provider.Milestone, error)
- func (p *Provider) CreateNote(ctx context.Context, owner, repo, number, 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) 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) DeleteMilestone(ctx context.Context, owner, repo, number string) error
- func (p *Provider) DeleteNote(ctx context.Context, owner, repo, number, noteID string) error
- func (p *Provider) DeleteRelease(ctx context.Context, owner, repo, tag 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 (t *Provider) GetBlob(ctx context.Context, owner, repo, sha string) ([]byte, error)
- func (p *Provider) GetCR(ctx context.Context, owner, repo, number string) (*provider.ChangeRequest, error)
- func (p *Provider) GetCRDiff(ctx context.Context, owner, repo, number string) (*provider.MergeDiff, error)
- func (p *Provider) GetCRFiles(ctx context.Context, owner, repo, number string) ([]*provider.ChangedFile, error)
- func (t *Provider) GetCodeReview(ctx context.Context, owner, repo string, reviewID int) (*CodeReview, error)
- func (t *Provider) GetCodeReviewChangedFiles(ctx context.Context, owner, repo string, reviewID int) ([]*provider.ChangedFile, error)
- func (p *Provider) GetCommit(ctx context.Context, owner, repo, sha string) (*provider.CommitInfo, error)
- func (t *Provider) GetCommitDiff(ctx context.Context, owner, repo, sha string, opts CommitDiffOptions) ([]*provider.ChangedFile, error)
- func (t *Provider) GetCommitRefs(ctx context.Context, owner, repo, sha string, refType CommitRefType) (*CommitRefs, error)
- func (p *Provider) GetFileContent(ctx context.Context, owner, repo, path, ref string) (string, error)
- func (t *Provider) GetMRReview(ctx context.Context, owner, repo string, mrNumber int) (*MRReview, error)
- func (p *Provider) GetMilestone(ctx context.Context, owner, repo, number string) (*provider.Milestone, error)
- func (p *Provider) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*provider.ReleaseInfo, error)
- func (p *Provider) GetRepo(ctx context.Context, owner, repo string) (*provider.PlatformRepo, error)
- func (t *Provider) GetRepoTree(ctx context.Context, owner, repo, path, ref string, recursive bool) ([]*TreeEntryNode, error)
- func (t *Provider) InviteCodeReviewer(ctx context.Context, owner, repo string, reviewID int, ...) error
- func (t *Provider) InviteMRReviewer(ctx context.Context, owner, repo string, mrNumber int, ...) error
- func (p *Provider) ListBranches(ctx context.Context, owner, repo string) ([]*provider.PlatformBranch, error)
- func (p *Provider) ListCRComments(ctx context.Context, owner, repo, number string) ([]*provider.CRComment, error)
- func (p *Provider) ListCRCommits(ctx context.Context, owner, repo, number string) ([]*provider.CRCommit, error)
- func (p *Provider) ListCRs(ctx context.Context, opts provider.ListCROptions) ([]*provider.ChangeRequest, int, error)
- func (t *Provider) ListCodeReviews(ctx context.Context, owner, repo string, opts ListCodeReviewsOptions) ([]*CodeReview, error)
- func (t *Provider) ListCommitComments(ctx context.Context, owner, repo, sha string, page, perPage int) ([]*CommitComment, error)
- func (p *Provider) ListCommits(ctx context.Context, owner, repo string, opts provider.ListCommitsOptions) ([]*provider.CommitInfo, error)
- func (p *Provider) ListMilestones(ctx context.Context, owner, repo string, opts provider.ListMilestonesOptions) ([]provider.Milestone, error)
- func (t *Provider) ListProtectedBranchMembers(ctx context.Context, owner, repo, branch string) ([]*ProtectedBranchMember, 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, number string, opts provider.MergeCROptions) (*provider.ChangeRequest, error)
- func (p *Provider) ParseWebhookEvent(r *http.Request, secret string) (*provider.NormalizedEvent, error)
- func (p *Provider) Platform() provider.Platform
- func (t *Provider) ProtectBranch(ctx context.Context, owner, repo, branch string, opts ProtectBranchOptions) error
- func (t *Provider) RemoveCodeReviewer(ctx context.Context, owner, repo string, reviewID int, reviewerID string) error
- func (t *Provider) RemoveMRReviewer(ctx context.Context, owner, repo string, mrNumber int, reviewerID int) error
- func (t *Provider) RemoveProtectedBranchMember(ctx context.Context, owner, repo, branch string, userID int) error
- func (p *Provider) ReopenCR(ctx context.Context, owner, repo, number string) (*provider.ChangeRequest, error)
- func (t *Provider) ReopenCodeReview(ctx context.Context, owner, repo string, reviewID int) error
- func (t *Provider) ReopenMRReview(ctx context.Context, owner, repo string, mrNumber int) error
- func (t *Provider) SubmitCodeReview(ctx context.Context, owner, repo string, reviewID int, ...) error
- func (t *Provider) SubmitMRReview(ctx context.Context, owner, repo string, mrNumber int, ...) error
- func (p *Provider) TestConnection(ctx context.Context) (*provider.TestConnectionResult, error)
- func (t *Provider) UnprotectBranch(ctx context.Context, owner, repo, branch string) error
- func (p *Provider) UpdateCR(ctx context.Context, owner, repo, number string, opts provider.UpdateCROptions) (*provider.ChangeRequest, error)
- func (p *Provider) UpdateCRLabels(ctx context.Context, owner, repo, number string, labels []string) error
- func (t *Provider) UpdateCodeReview(ctx context.Context, owner, repo string, reviewID int, ...) (*CodeReview, error)
- func (p *Provider) UpdateFile(ctx context.Context, owner, repo string, opts provider.FileOptions) (*provider.FileResult, error)
- func (p *Provider) UpdateMilestone(ctx context.Context, owner, repo, number string, ...) (*provider.Milestone, error)
- func (t *Provider) UpdateProtectedBranchMember(ctx context.Context, owner, repo, branch string, userID int, ...) error
- func (p *Provider) UpdateRelease(ctx context.Context, owner, repo, tag string, ...) (*provider.ReleaseInfo, 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
- type ReviewerEvent
- type SubmitReviewOptions
- type TencentCodeExtras
- type TreeEntryNode
- type UpdateCodeReviewOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CodeReview ¶
type CodeReview struct {
ID int `json:"id"`
IID int `json:"iid"`
ProjectID int `json:"project_id"`
Title string `json:"title"`
Description string `json:"description"`
State string `json:"state"`
SourceBranch string `json:"source_branch"`
TargetBranch string `json:"target_branch"`
SourceCommit string `json:"source_commit"`
TargetCommit string `json:"target_commit"`
Author *provider.CRUser `json:"author"`
Reviewers []string `json:"reviewers"`
WebURL string `json:"web_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
CodeReview represents a Tencent 工蜂 native code review.
type CommitComment ¶
type CommitComment struct {
ID int `json:"id"`
Body string `json:"body"`
Author *provider.CRUser `json:"author"`
Path string `json:"path"`
Line int `json:"line"`
LineType string `json:"line_type"`
CreatedAt string `json:"created_at"`
}
CommitComment represents a comment on a commit.
type CommitDiffOptions ¶
CommitDiffOptions controls a single-commit diff.
type CommitRefType ¶
type CommitRefType string
CommitRefType selects which refs to return for a commit.
const ( CommitRefAll CommitRefType = "all" CommitRefBranch CommitRefType = "branch" CommitRefTag CommitRefType = "tag" )
type CommitRefs ¶
CommitRefs lists branches and tags containing a commit.
type CreateCodeReviewOptions ¶
type CreateCodeReviewOptions struct {
Title string
SourceBranch string
TargetBranch string
SourceCommit string
TargetCommit string
Description string
ReviewerIDs string // comma-separated reviewer user IDs
NecessaryReviewerIDs string // comma-separated necessary reviewer user IDs
ApproverRule int // -1 = all approve, 1 = single, 2+ = N approve
NecessaryApproverRule int
}
CreateCodeReviewOptions creates a native code review.
type CreateCommitCommentOptions ¶
type CreateCommitCommentOptions struct {
Note string
Path string
Line int
LineType string // "old" or "new"
}
CreateCommitCommentOptions creates a comment on a commit.
type InviteReviewerOptions ¶
type InviteReviewerOptions struct {
ReviewerID string // comma-separated user IDs (code review)
NecessaryReviewerID string // comma-separated necessary user IDs (code review)
}
InviteReviewerOptions invites one or more reviewers.
type ListCodeReviewsOptions ¶
type ListCodeReviewsOptions struct {
State string // approving, change_required, closed
AuthorID int
OrderBy string // created_at, updated_at
Sort string // asc, desc
Page int
PerPage int
}
ListCodeReviewsOptions filters the code review list.
type MRReview ¶
type MRReview struct {
ID int `json:"id"`
IID int `json:"iid"`
ProjectID int `json:"project_id"`
State string `json:"state"`
Title string `json:"title"`
Description string `json:"description"`
Author *provider.CRUser `json:"author"`
SourceBranch string `json:"source_branch"`
TargetBranch string `json:"target_branch"`
WebURL string `json:"web_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
MRReview represents the review state of a merge request.
type ProtectBranchOptions ¶
type ProtectBranchOptions struct {
MergeAccessLevel int `json:"merge_access_level,omitempty"`
PushAccessLevel int `json:"push_access_level,omitempty"`
AllowForcePush bool `json:"allow_force_push,omitempty"`
CodeOwnerApprovalRequired bool `json:"code_owner_approval_required,omitempty"`
}
ProtectBranchOptions configures branch protection rules on Tencent Code (工蜂).
type ProtectedBranchMember ¶
type ProtectedBranchMember struct {
UserID int `json:"user_id"`
Username string `json:"username"`
Name string `json:"name"`
AccessLevel int `json:"access_level"`
}
ProtectedBranchMember represents a member granted access to a protected branch.
type ProtectedBranchMemberOptions ¶
ProtectedBranchMemberOptions adds/updates a protected branch member.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the Tencent 工蜂 implementation of provider.Provider.
func (*Provider) AddProtectedBranchMember ¶
func (*Provider) CancelMRReview ¶
func (*Provider) Capabilities ¶ added in v0.38.0
func (p *Provider) Capabilities() provider.CapabilitySet
Capabilities implements provider.Provider. The backend declares the optional capability interfaces it implements; flip fields here as capability backends land (currently only Milestones).
func (*Provider) CloseCR ¶
func (p *Provider) CloseCR(ctx context.Context, owner, repo, number string) (*provider.ChangeRequest, error)
CloseCR implements provider.ChangeRequestManager.
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) CreateCodeReview ¶
func (t *Provider) CreateCodeReview(ctx context.Context, owner, repo string, opts CreateCodeReviewOptions) (*CodeReview, error)
func (*Provider) CreateCommitComment ¶
func (t *Provider) CreateCommitComment(ctx context.Context, owner, repo, sha string, opts CreateCommitCommentOptions) (*CommitComment, error)
func (*Provider) CreateCommitStatus ¶
func (p *Provider) CreateCommitStatus(ctx context.Context, owner, repo, sha string, opts provider.CommitStatusOptions) error
CreateCommitStatus implements provider.CommitManager.
func (*Provider) CreateDiscussion ¶
func (p *Provider) CreateDiscussion(ctx context.Context, owner, repo, number string, opts provider.DiscussionOptions) (string, error)
CreateDiscussion implements provider.DiffManager. The gongfeng SDK does not expose a discussions endpoint, so we use the SDK client's NewRequest/Do for a raw API call.
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) CreateMilestone ¶ added in v0.41.0
func (p *Provider) CreateMilestone(ctx context.Context, owner, repo string, opts provider.CreateMilestoneOptions) (*provider.Milestone, error)
CreateMilestone implements provider.MilestoneManager.
func (*Provider) CreateNote ¶
func (p *Provider) CreateNote(ctx context.Context, owner, repo, number, 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) 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) DeleteMilestone ¶ added in v0.41.0
DeleteMilestone implements provider.MilestoneManager.
func (*Provider) DeleteNote ¶
DeleteNote implements provider.DiffManager. The gongfeng SDK does not expose a delete-note endpoint, so we use the SDK client's NewRequest/Do for a raw API call.
func (*Provider) DeleteRelease ¶ added in v0.40.0
DeleteRelease implements provider.ReleaseManager via Gongfeng's tag-addressed delete.
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.
func (*Provider) GetCR ¶
func (p *Provider) GetCR(ctx context.Context, owner, repo, number string) (*provider.ChangeRequest, error)
GetCR implements provider.ChangeRequestManager.
func (*Provider) GetCRDiff ¶
func (p *Provider) GetCRDiff(ctx context.Context, owner, repo, number string) (*provider.MergeDiff, error)
GetCRDiff implements provider.DiffManager.
func (*Provider) GetCRFiles ¶
func (p *Provider) GetCRFiles(ctx context.Context, owner, repo, number string) ([]*provider.ChangedFile, error)
GetCRFiles implements provider.DiffManager.
func (*Provider) GetCodeReview ¶
func (*Provider) GetCodeReviewChangedFiles ¶
func (*Provider) GetCommit ¶
func (p *Provider) GetCommit(ctx context.Context, owner, repo, sha string) (*provider.CommitInfo, error)
GetCommit implements provider.CommitManager.
func (*Provider) GetCommitDiff ¶
func (t *Provider) GetCommitDiff(ctx context.Context, owner, repo, sha string, opts CommitDiffOptions) ([]*provider.ChangedFile, error)
func (*Provider) GetCommitRefs ¶
func (t *Provider) GetCommitRefs(ctx context.Context, owner, repo, sha string, refType CommitRefType) (*CommitRefs, error)
func (*Provider) GetFileContent ¶
func (p *Provider) GetFileContent(ctx context.Context, owner, repo, path, ref string) (string, error)
GetFileContent implements provider.FileManager.
func (*Provider) GetMRReview ¶
func (*Provider) GetMilestone ¶ added in v0.41.0
func (p *Provider) GetMilestone(ctx context.Context, owner, repo, number string) (*provider.Milestone, error)
GetMilestone implements provider.MilestoneManager.
func (*Provider) GetReleaseByTag ¶ added in v0.40.0
func (p *Provider) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*provider.ReleaseInfo, error)
GetReleaseByTag implements provider.ReleaseManager. Gongfeng's release endpoints are tag-addressed natively.
func (*Provider) GetRepoTree ¶
func (*Provider) InviteCodeReviewer ¶
func (*Provider) InviteMRReviewer ¶
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, number string) ([]*provider.CRComment, error)
ListCRComments implements provider.ChangeRequestManager.
func (*Provider) ListCRCommits ¶
func (p *Provider) ListCRCommits(ctx context.Context, owner, repo, number string) ([]*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) ListCodeReviews ¶
func (t *Provider) ListCodeReviews(ctx context.Context, owner, repo string, opts ListCodeReviewsOptions) ([]*CodeReview, error)
func (*Provider) ListCommitComments ¶
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) ListMilestones ¶ added in v0.41.0
func (p *Provider) ListMilestones(ctx context.Context, owner, repo string, opts provider.ListMilestonesOptions) ([]provider.Milestone, error)
ListMilestones implements provider.MilestoneManager.
func (*Provider) ListProtectedBranchMembers ¶
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, number string, 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) ProtectBranch ¶
func (*Provider) RemoveCodeReviewer ¶
func (*Provider) RemoveMRReviewer ¶
func (*Provider) RemoveProtectedBranchMember ¶
func (*Provider) ReopenCR ¶
func (p *Provider) ReopenCR(ctx context.Context, owner, repo, number string) (*provider.ChangeRequest, error)
ReopenCR implements provider.ChangeRequestManager.
func (*Provider) ReopenCodeReview ¶
func (*Provider) ReopenMRReview ¶
func (*Provider) SubmitCodeReview ¶
func (*Provider) SubmitMRReview ¶
func (*Provider) TestConnection ¶
TestConnection implements provider.Provider.
func (*Provider) UnprotectBranch ¶
func (*Provider) UpdateCR ¶
func (p *Provider) UpdateCR(ctx context.Context, owner, repo, number string, opts provider.UpdateCROptions) (*provider.ChangeRequest, error)
UpdateCR implements provider.ChangeRequestManager.
func (*Provider) UpdateCRLabels ¶
func (p *Provider) UpdateCRLabels(ctx context.Context, owner, repo, number string, labels []string) error
UpdateCRLabels implements provider.ChangeRequestManager.
Tencent Code's API no longer supports setting labels via UpdateMergeRequest.
func (*Provider) UpdateCodeReview ¶
func (t *Provider) UpdateCodeReview(ctx context.Context, owner, repo string, reviewID int, opts UpdateCodeReviewOptions) (*CodeReview, error)
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) UpdateMilestone ¶ added in v0.41.0
func (p *Provider) UpdateMilestone(ctx context.Context, owner, repo, number string, opts provider.UpdateMilestoneOptions) (*provider.Milestone, error)
UpdateMilestone implements provider.MilestoneManager. Nil fields in opts stay absent from the PUT body, leaving the milestone unchanged; state changes travel as gongfeng's state_event verb.
func (*Provider) UpdateProtectedBranchMember ¶
func (*Provider) UpdateRelease ¶ added in v0.40.0
func (p *Provider) UpdateRelease(ctx context.Context, owner, repo, tag string, opts provider.UpdateReleaseOptions) (*provider.ReleaseInfo, error)
UpdateRelease implements provider.ReleaseManager via Gongfeng's tag-addressed update (PUT). Registration: the platform's update surface accepts only a description, so UpdateReleaseOptions.Name, .Draft, and .Prerelease are ignored on this platform — only Body is carried. An update carrying nothing (Body nil, the only field forwarded) short- circuits to the GetReleaseByTag result instead of PUTting an empty update body.
func (*Provider) UpdateRepo ¶
func (p *Provider) UpdateRepo(ctx context.Context, owner, repo string, opts provider.UpdateRepoOptions) (*provider.PlatformRepo, error)
UpdateRepo implements provider.RepoManager.
type ReviewerEvent ¶
type ReviewerEvent string
ReviewerEvent is the verdict a reviewer submits for a code review or MR review.
const ( ReviewEventComment ReviewerEvent = "comment" ReviewEventApprove ReviewerEvent = "approve" ReviewEventRequireChange ReviewerEvent = "require_change" ReviewEventDeny ReviewerEvent = "deny" )
type SubmitReviewOptions ¶
type SubmitReviewOptions struct {
Event ReviewerEvent
Summary string
}
SubmitReviewOptions submits a reviewer verdict with a summary.
type TencentCodeExtras ¶
type TencentCodeExtras interface {
// --- Native code review (/review) ---
CreateCodeReview(ctx context.Context, owner, repo string, opts CreateCodeReviewOptions) (*CodeReview, error)
ListCodeReviews(ctx context.Context, owner, repo string, opts ListCodeReviewsOptions) ([]*CodeReview, error)
GetCodeReview(ctx context.Context, owner, repo string, reviewID int) (*CodeReview, error)
UpdateCodeReview(ctx context.Context, owner, repo string, reviewID int, opts UpdateCodeReviewOptions) (*CodeReview, error)
InviteCodeReviewer(ctx context.Context, owner, repo string, reviewID int, opts InviteReviewerOptions) error
RemoveCodeReviewer(ctx context.Context, owner, repo string, reviewID int, reviewerID string) error
SubmitCodeReview(ctx context.Context, owner, repo string, reviewID int, opts SubmitReviewOptions) error
ReopenCodeReview(ctx context.Context, owner, repo string, reviewID int) error
GetCodeReviewChangedFiles(ctx context.Context, owner, repo string, reviewID int) ([]*provider.ChangedFile, error)
// --- MR review workflow (/merge_request/{iid}/review*) ---
GetMRReview(ctx context.Context, owner, repo string, mrNumber int) (*MRReview, error)
InviteMRReviewer(ctx context.Context, owner, repo string, mrNumber int, opts InviteReviewerOptions) error
RemoveMRReviewer(ctx context.Context, owner, repo string, mrNumber int, reviewerID int) error
CancelMRReview(ctx context.Context, owner, repo string, mrNumber int) error
SubmitMRReview(ctx context.Context, owner, repo string, mrNumber int, opts SubmitReviewOptions) error
ReopenMRReview(ctx context.Context, owner, repo string, mrNumber int) error
// --- Commit-level ops (/repository/commits/{sha}) ---
GetCommitDiff(ctx context.Context, owner, repo, sha string, opts CommitDiffOptions) ([]*provider.ChangedFile, error)
ListCommitComments(ctx context.Context, owner, repo, sha string, page, perPage int) ([]*CommitComment, error)
CreateCommitComment(ctx context.Context, owner, repo, sha string, opts CreateCommitCommentOptions) (*CommitComment, error)
GetCommitRefs(ctx context.Context, owner, repo, sha string, refType CommitRefType) (*CommitRefs, error)
// --- Repository tree & blob ---
GetRepoTree(ctx context.Context, owner, repo, path, ref string, recursive bool) ([]*TreeEntryNode, error)
GetBlob(ctx context.Context, owner, repo, sha string) ([]byte, error)
// --- Branch protection ---
ProtectBranch(ctx context.Context, owner, repo, branch string, opts ProtectBranchOptions) error
UnprotectBranch(ctx context.Context, owner, repo, branch string) error
ListProtectedBranchMembers(ctx context.Context, owner, repo, branch string) ([]*ProtectedBranchMember, error)
AddProtectedBranchMember(ctx context.Context, owner, repo, branch string, opts ProtectedBranchMemberOptions) error
UpdateProtectedBranchMember(ctx context.Context, owner, repo, branch string, userID int, opts ProtectedBranchMemberOptions) error
RemoveProtectedBranchMember(ctx context.Context, owner, repo, branch string, userID int) error
}
TencentCodeExtras exposes Tencent 工蜂-specific capabilities that are not part of the cross-platform Provider interface (native code reviews, MR review workflow, commit-level comments/diff, repository tree/blob and branch protection). Obtain it via type assertion:
p, _ := provider.NewProvider(provider.Config{Platform: provider.PlatformTencentCode, Token: t})
if tc, ok := p.(provider.TencentCodeExtras); ok {
tc.SubmitCodeReview(ctx, owner, repo, reviewID, opts)
}
type TreeEntryNode ¶
type TreeEntryNode struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"` // "tree" or "blob"
Mode string `json:"mode"`
Path string `json:"path"`
}
TreeEntryNode represents a single entry in a repository tree listing.
type UpdateCodeReviewOptions ¶
UpdateCodeReviewOptions updates a code review's title/description.