tencentcode

package
v0.44.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 17 Imported by: 0

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)
  • labels.go: repository label CRUD (LabelManager)
  • issues.go: issue CRUD, state transitions, comments (via notes), and issue-label writes (IssueManager)
  • reviews.go: code reviews over native review notes, reviewer requests (registered ignore), and dismissals (registered stub) (ReviewManager)
  • extras.go: TencentCodeExtras (native code reviews, commit comments, repository tree, branch protection)
  • types.go: gongfeng model -> provider model conversions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New builds a Tencent Code Provider from the given config.

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

type CommitDiffOptions struct {
	Path             string
	IgnoreWhiteSpace bool
}

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

type CommitRefs struct {
	Branches []string `json:"branches"`
	Tags     []string `json:"tags"`
}

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

type ProtectedBranchMemberOptions struct {
	UserID      int
	AccessLevel int
}

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) AddIssueLabels added in v0.42.0

func (p *Provider) AddIssueLabels(ctx context.Context, owner, repo, number string, labels []string) error

AddIssueLabels implements provider.IssueManager. 工蜂's update surface takes the full label set only (no add_labels), so the current set is fetched, unioned with the adds, and rewritten.

func (*Provider) AddProtectedBranchMember

func (t *Provider) AddProtectedBranchMember(ctx context.Context, owner, repo, branch string, opts ProtectedBranchMemberOptions) error

func (*Provider) CancelMRReview

func (t *Provider) CancelMRReview(ctx context.Context, owner, repo string, mrNumber int) error

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 (currently Labels, Milestones, Issues, and Reviews).

func (*Provider) CloseCR

func (p *Provider) CloseCR(ctx context.Context, owner, repo, number string) (*provider.ChangeRequest, error)

CloseCR implements provider.ChangeRequestManager.

func (*Provider) CloseIssue added in v0.42.0

func (p *Provider) CloseIssue(ctx context.Context, owner, repo, number string) (*provider.Issue, error)

CloseIssue implements provider.IssueManager via the state_event API.

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

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) CreateIssue added in v0.42.0

func (p *Provider) CreateIssue(ctx context.Context, opts provider.CreateIssueOptions) (*provider.Issue, error)

CreateIssue implements provider.IssueManager. opts.Assignees is ignored: 工蜂's create surface takes assignee IDs, and resolving usernames to IDs requires the Users API (a future UserManager round).

func (*Provider) CreateIssueComment added in v0.42.0

func (p *Provider) CreateIssueComment(ctx context.Context, owner, repo, number, body string) (*provider.IssueComment, error)

CreateIssueComment implements provider.IssueManager via the notes API.

func (*Provider) CreateLabel added in v0.42.0

func (p *Provider) CreateLabel(ctx context.Context, owner, repo string, opts provider.CreateLabelOptions) (*provider.Label, error)

CreateLabel implements provider.LabelManager. 工蜂 requires colors with a leading '#'.

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

func (p *Provider) CreateReview(ctx context.Context, owner, repo, number string, opts provider.CreateReviewOptions) (*provider.ReviewResult, error)

CreateReview implements provider.ReviewManager by posting a merge-request note: the body becomes the note text and the event maps to the note's reviewer_state verdict verb (same vocabulary the reviews/{id} commit-note surface uses — the gongfeng SDK's bundled docs/api/notes.md). See the file doc for the registered unmapped fields (Comments, CommitID) and the verdict vocabulary.

func (*Provider) CreateWebhook

CreateWebhook implements provider.WebhookManager.

func (*Provider) DeleteBranch

func (p *Provider) DeleteBranch(ctx context.Context, owner, repo, branch string) error

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

func (p *Provider) DeleteLabel(ctx context.Context, owner, repo, name string) error

DeleteLabel implements provider.LabelManager. The label name travels in the delete body as 工蜂's addressing key.

func (*Provider) DeleteMilestone added in v0.41.0

func (p *Provider) DeleteMilestone(ctx context.Context, owner, repo, number string) error

DeleteMilestone implements provider.MilestoneManager.

func (*Provider) DeleteNote

func (p *Provider) DeleteNote(ctx context.Context, owner, repo, number, noteID string) error

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

func (p *Provider) DeleteRelease(ctx context.Context, owner, repo, tag string) error

DeleteRelease implements provider.ReleaseManager via Gongfeng's tag-addressed delete.

func (*Provider) DeleteRepo

func (p *Provider) DeleteRepo(ctx context.Context, owner, repo string) error

DeleteRepo implements provider.RepoManager.

func (*Provider) DeleteWebhook

func (p *Provider) DeleteWebhook(ctx context.Context, owner, repo string, webhookID int64) error

DeleteWebhook implements provider.WebhookManager.

func (*Provider) DismissReview added in v0.42.0

func (p *Provider) DismissReview(ctx context.Context, owner, repo, number string, reviewID int64, message string) error

DismissReview implements provider.ReviewManager as a registered stub — the only registered stub among the optional-capability interfaces (the SDK's other stubs, e.g. ChangeRequestManager.UpdateCRLabels, live on core interfaces).

Registered mapping: STUB. 工蜂's review surface has no dismissal verb: review notes can be created, listed, fetched, and edited (UpdateReviewNote rewrites the body or reviewer_state), but no endpoint removes or voids a review, and the dismissal message has no 工蜂 equivalent. The call fails fast with a platform error wrapping provider.ErrNotImplemented.

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

func (p *Provider) GetArchive(ctx context.Context, owner, repo, ref, format string) ([]byte, error)

GetArchive implements provider.ReleaseManager.

func (*Provider) GetBlob

func (t *Provider) GetBlob(ctx context.Context, owner, repo, sha string) ([]byte, error)

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 (t *Provider) GetCodeReview(ctx context.Context, owner, repo string, reviewID int) (*CodeReview, error)

func (*Provider) GetCodeReviewChangedFiles

func (t *Provider) GetCodeReviewChangedFiles(ctx context.Context, owner, repo string, reviewID int) ([]*provider.ChangedFile, error)

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) GetIssue added in v0.42.0

func (p *Provider) GetIssue(ctx context.Context, owner, repo, number string) (*provider.Issue, error)

GetIssue implements provider.IssueManager. 工蜂 addresses issues by IID.

func (*Provider) GetMRReview

func (t *Provider) GetMRReview(ctx context.Context, owner, repo string, mrNumber int) (*MRReview, error)

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

func (p *Provider) GetRepo(ctx context.Context, owner, repo string) (*provider.PlatformRepo, error)

GetRepo implements provider.RepoManager.

func (*Provider) GetRepoTree

func (t *Provider) GetRepoTree(ctx context.Context, owner, repo, path, ref string, recursive bool) ([]*TreeEntryNode, error)

func (*Provider) GetReview added in v0.42.0

func (p *Provider) GetReview(ctx context.Context, owner, repo, number string, reviewID int64) (*provider.Review, error)

GetReview implements provider.ReviewManager by fetching the single merge-request note backing the review: reviewID is the note ID — the same identifier CreateReview returns as ReviewResult.ID, so created reviews round-trip through this call.

func (*Provider) InviteCodeReviewer

func (t *Provider) InviteCodeReviewer(ctx context.Context, owner, repo string, reviewID int, opts InviteReviewerOptions) error

func (*Provider) InviteMRReviewer

func (t *Provider) InviteMRReviewer(ctx context.Context, owner, repo string, mrNumber int, opts InviteReviewerOptions) error

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

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 (t *Provider) ListCommitComments(ctx context.Context, owner, repo, sha string, page, perPage int) ([]*CommitComment, error)

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 added in v0.42.0

func (p *Provider) ListIssueComments(ctx context.Context, owner, repo, number string) ([]*provider.IssueComment, error)

ListIssueComments implements provider.IssueManager. 工蜂 models issue comments as notes.

func (*Provider) ListIssueLabels added in v0.42.0

func (p *Provider) ListIssueLabels(ctx context.Context, owner, repo string) ([]*provider.IssueLabel, error)

ListIssueLabels implements provider.IssueManager: repository-level labels (labels.go owns the model conversion; IDs stay zero because the gongfeng Label model has none).

func (*Provider) ListIssues added in v0.42.0

func (p *Provider) ListIssues(ctx context.Context, opts provider.ListIssuesOptions) ([]*provider.Issue, int, error)

ListIssues implements provider.IssueManager. State and the Labels csv pass through as filters (open→opened per 工蜂's vocabulary; inbound convertIssue maps back); the Assignee filter is not carried (registered above).

func (*Provider) ListLabels added in v0.42.0

func (p *Provider) ListLabels(ctx context.Context, owner, repo string, opts provider.ListLabelsOptions) ([]*provider.Label, error)

ListLabels implements provider.LabelManager.

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 (t *Provider) ListProtectedBranchMembers(ctx context.Context, owner, repo, branch string) ([]*ProtectedBranchMember, error)

func (*Provider) ListReleases

func (p *Provider) ListReleases(ctx context.Context, owner, repo string) ([]*provider.ReleaseInfo, error)

ListReleases implements provider.ReleaseManager.

func (*Provider) ListRepos

ListRepos implements provider.RepoManager.

func (*Provider) ListReviews added in v0.42.0

func (p *Provider) ListReviews(ctx context.Context, owner, repo, number string) ([]provider.Review, error)

ListReviews implements provider.ReviewManager by listing the change request's merge-request notes. The collection can mix in 工蜂's system bookkeeping notes ("milestone removed" and the like); those are not reviews and are filtered out.

func (*Provider) ListTags

func (p *Provider) ListTags(ctx context.Context, owner, repo string) ([]*provider.TagInfo, error)

ListTags implements provider.ReleaseManager.

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

func (p *Provider) Platform() provider.Platform

Platform implements provider.Provider.

func (*Provider) ProtectBranch

func (t *Provider) ProtectBranch(ctx context.Context, owner, repo, branch string, opts ProtectBranchOptions) error

func (*Provider) RemoveCodeReviewer

func (t *Provider) RemoveCodeReviewer(ctx context.Context, owner, repo string, reviewID int, reviewerID string) error

func (*Provider) RemoveIssueLabel added in v0.42.0

func (p *Provider) RemoveIssueLabel(ctx context.Context, owner, repo, number, name string) error

RemoveIssueLabel implements provider.IssueManager. 工蜂's update surface takes the full label set only (no remove_labels), so the current set is fetched, the name filtered out, and the remainder rewritten. Registered limitation: removing the issue's only label yields an empty csv that omitempty drops from the PUT body, so the update is a no-op and the label stays.

func (*Provider) RemoveMRReviewer

func (t *Provider) RemoveMRReviewer(ctx context.Context, owner, repo string, mrNumber int, reviewerID int) error

func (*Provider) RemoveProtectedBranchMember

func (t *Provider) RemoveProtectedBranchMember(ctx context.Context, owner, repo, branch string, userID int) error

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 (t *Provider) ReopenCodeReview(ctx context.Context, owner, repo string, reviewID int) error

func (*Provider) ReopenIssue added in v0.42.0

func (p *Provider) ReopenIssue(ctx context.Context, owner, repo, number string) (*provider.Issue, error)

ReopenIssue implements provider.IssueManager via the state_event API.

func (*Provider) ReopenMRReview

func (t *Provider) ReopenMRReview(ctx context.Context, owner, repo string, mrNumber int) error

func (*Provider) RequestReviewers added in v0.42.0

func (p *Provider) RequestReviewers(ctx context.Context, owner, repo, number string, reviewers []string) error

RequestReviewers implements provider.ReviewManager as a registered ignore.

Registered mapping: IGNORED. 工蜂's merge-request update surface cannot add reviewers (gongfeng's UpdateMergeRequestOptions carries no reviewer field), and the native invite endpoint addresses reviewers by numeric user ID (InviteMRReviewer's reviewer_id) while the SDK's callers supply usernames — the Users API offers no by-username lookup to bridge them (the same class of limitation as CreateIssue's ignored Assignees). The call therefore succeeds without effect and touches no wire.

func (*Provider) SubmitCodeReview

func (t *Provider) SubmitCodeReview(ctx context.Context, owner, repo string, reviewID int, opts SubmitReviewOptions) error

func (*Provider) SubmitMRReview

func (t *Provider) SubmitMRReview(ctx context.Context, owner, repo string, mrNumber int, opts SubmitReviewOptions) error

func (*Provider) TestConnection

func (p *Provider) TestConnection(ctx context.Context) (*provider.TestConnectionResult, error)

TestConnection implements provider.Provider.

func (*Provider) UnprotectBranch

func (t *Provider) UnprotectBranch(ctx context.Context, owner, repo, branch string) error

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) UpdateIssue added in v0.42.0

func (p *Provider) UpdateIssue(ctx context.Context, owner, repo, number string, opts provider.UpdateIssueOptions) (*provider.Issue, error)

UpdateIssue implements provider.IssueManager. Empty option fields stay absent from the PUT body, leaving the issue unchanged; state changes travel as 工蜂's state_event verbs. opts.Assignees is ignored (see CreateIssue).

func (*Provider) UpdateLabel added in v0.42.0

func (p *Provider) UpdateLabel(ctx context.Context, owner, repo, name string, opts provider.UpdateLabelOptions) (*provider.Label, error)

UpdateLabel implements provider.LabelManager. The current name travels in the update body as 工蜂's addressing key; nil fields in opts stay absent from the PUT body, leaving the label unchanged.

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 (t *Provider) UpdateProtectedBranchMember(ctx context.Context, owner, repo, branch string, userID int, opts ProtectedBranchMemberOptions) error

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.

func (*Provider) ValidateWebhookSignature

func (p *Provider) ValidateWebhookSignature(r *http.Request, secret string) error

ValidateWebhookSignature implements provider.WebhookManager. Tencent 工蜂 uses a static token comparison against the X-Token header.

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

type UpdateCodeReviewOptions struct {
	Title       string
	Description string
}

UpdateCodeReviewOptions updates a code review's title/description.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL