Documentation
¶
Overview ¶
Package api provides GitCode API client
Index ¶
- Constants
- Variables
- func BuildURL(base string, params map[string]string) string
- func ClearIssueLabels(client *Client, owner, repo string, number int) error
- func DefaultHTTPClient() *http.Client
- func DeleteIssueComment(client *Client, owner, repo string, commentID int64) error
- func DeleteLabel(client *Client, owner, repo, name string) error
- func DeleteMilestone(client *Client, owner, repo string, number int) error
- func DeleteRelease(client *Client, owner, repo string, id int64) error
- func DeleteReleaseAsset(client *Client, owner, repo string, assetID int64) error
- func DeleteReleaseByTag(client *Client, owner, repo, tag string) error
- func DeleteRepo(client *Client, owner, name string) error
- func GetCommitDiff(client *Client, owner, repo, sha string) (string, error)
- func GetCommitPatch(client *Client, owner, repo, sha string) (string, error)
- func RemoveIssueLabel(client *Client, owner, repo string, number int, label string) error
- func RemoveLabelFromIssue(client *Client, owner, repo string, number int, label string) error
- func ResolvePRComment(client *Client, owner, repo string, number int, discussionID string, ...) error
- func ResolveUserIDs(client *Client, usernames []string) ([]string, error)
- func ReviewPR(client *Client, owner, repo string, number int, opts *ReviewPROptions) error
- func TestPR(client *Client, owner, repo string, number int, opts *TestPROptions) error
- func UploadReleaseAssetByTag(client *Client, owner, repo, tag, filename string, content []byte, ...) error
- type APIError
- type AssetUploadURL
- type Client
- func (c *Client) Delete(path string) error
- func (c *Client) Get(path string, response interface{}) error
- func (c *Client) GetText(path string) (string, error)
- func (c *Client) Host() string
- func (c *Client) Patch(path string, body interface{}, response interface{}) error
- func (c *Client) PatchForm(path string, formValues url.Values, response interface{}) error
- func (c *Client) Post(path string, body interface{}, response interface{}) error
- func (c *Client) PostForm(path string, formValues url.Values, response interface{}) error
- func (c *Client) Put(path string, body interface{}, response interface{}) error
- func (c *Client) REST(method, path string, body interface{}, response interface{}) error
- func (c *Client) SetHost(host string)
- func (c *Client) SetToken(token, source string)
- func (c *Client) Token() string
- func (c *Client) UploadAsset(path, filename string, content []byte, contentType string) (*ReleaseAsset, error)
- func (c *Client) UploadToURL(uploadURL, filename string, content []byte, contentType string, ...) error
- type Commit
- type CommitAuthor
- type CommitComment
- func CreateCommitComment(client *Client, owner, repo, sha, body string) (*CommitComment, error)
- func GetCommitComment(client *Client, owner, repo, id string) (*CommitComment, error)
- func ListCommentsForCommit(client *Client, owner, repo, sha string, opts *ListOptions) ([]CommitComment, error)
- func ListCommitComments(client *Client, owner, repo string, opts *ListOptions) ([]CommitComment, error)
- func UpdateCommitComment(client *Client, owner, repo, id string, body string) (*CommitComment, error)
- type CommitCommentsBySHAOptions
- type CommitFile
- type CommitInfo
- type CommitStatItem
- type CommitStatistics
- type CommitStats
- type CommitStatsOptions
- type CreateCommentOptions
- type CreateIssueOptions
- type CreateLabelOptions
- type CreateMilestoneOptions
- type CreatePRCommentOptions
- type CreatePROptions
- type CreatePRReviewOptions
- type CreateReleaseOptions
- type CreateRepoOptions
- type EditPRCommentOptions
- type FlexibleTime
- type Issue
- func CloseIssue(client *Client, owner, repo string, number int) (*Issue, error)
- func CreateIssue(client *Client, owner, repo string, opts *CreateIssueOptions) (*Issue, error)
- func GetIssue(client *Client, owner, repo string, number int) (*Issue, error)
- func ListRepoIssues(client *Client, owner, repo string, opts *IssueListOptions) ([]Issue, error)
- func ReopenIssue(client *Client, owner, repo string, number int) (*Issue, error)
- func UpdateIssue(client *Client, owner, repo string, number int, opts *UpdateIssueOptions) (*Issue, error)
- type IssueComment
- func CreateIssueComment(client *Client, owner, repo string, number int, opts *CreateCommentOptions) (*IssueComment, error)
- func ListIssueComments(client *Client, owner, repo string, number int, opts *IssueCommentListOptions) ([]IssueComment, error)
- func UpdateIssueComment(client *Client, owner, repo string, commentID string, ...) (*IssueComment, error)
- type IssueCommentListOptions
- type IssueListOptions
- type IssuePR
- type Label
- func AddIssueLabels(client *Client, owner, repo string, number int, labels []string) ([]*Label, error)
- func AddLabelsToIssue(client *Client, owner, repo string, number int, labels []string) ([]Label, error)
- func CreateLabel(client *Client, owner, repo string, opts *CreateLabelOptions) (*Label, error)
- func GetLabel(client *Client, owner, repo, name string) (*Label, error)
- func ListRepoLabels(client *Client, owner, repo string) ([]Label, error)
- func SetIssueLabels(client *Client, owner, repo string, number int, labels []string) ([]Label, error)
- func UpdateLabel(client *Client, owner, repo, name string, opts *UpdateLabelOptions) (*Label, error)
- type ListOptions
- type MergePROptions
- type Milestone
- func CloseMilestone(client *Client, owner, repo string, number int) (*Milestone, error)
- func CreateMilestone(client *Client, owner, repo string, opts *CreateMilestoneOptions) (*Milestone, error)
- func GetMilestone(client *Client, owner, repo string, number int) (*Milestone, error)
- func ListRepoMilestones(client *Client, owner, repo string) ([]Milestone, error)
- func OpenMilestone(client *Client, owner, repo string, number int) (*Milestone, error)
- func UpdateMilestone(client *Client, owner, repo string, number int, opts *UpdateMilestoneOptions) (*Milestone, error)
- type PRBranch
- type PRComment
- func CreatePRComment(client *Client, owner, repo string, number int, opts *CreatePRCommentOptions) (*PRComment, error)
- func EditPRComment(client *Client, owner, repo string, commentID int, opts *EditPRCommentOptions) (*PRComment, error)
- func ListPRComments(client *Client, owner, repo string, number int) ([]PRComment, error)
- type PRDiff
- type PRDiffContent
- type PRDiffHead
- type PRDiffLine
- type PRDiffRefs
- type PRFilesResponse
- type PRListOptions
- type PRReview
- type PRReviewComment
- type PRStatistic
- type PullRequest
- func ClosePullRequest(client *Client, owner, repo string, number int) (*PullRequest, error)
- func CreatePullRequest(client *Client, owner, repo string, opts *CreatePROptions) (*PullRequest, error)
- func EditPR(client *Client, owner, repo string, number int, opts *UpdatePROptions) (*PullRequest, error)
- func GetPullRequest(client *Client, owner, repo string, number int) (*PullRequest, error)
- func ListPullRequests(client *Client, owner, repo string, opts *PRListOptions) ([]PullRequest, error)
- func MergePullRequest(client *Client, owner, repo string, number int, opts *MergePROptions) (*PullRequest, error)
- func ReopenPullRequest(client *Client, owner, repo string, number int) (*PullRequest, error)
- func UpdatePullRequest(client *Client, owner, repo string, number int, opts *UpdatePROptions) (*PullRequest, error)
- type Release
- func CreateRelease(client *Client, owner, repo string, opts *CreateReleaseOptions) (*Release, error)
- func GetLatestRelease(client *Client, owner, repo string) (*Release, error)
- func GetRelease(client *Client, owner, repo, tag string) (*Release, error)
- func GetReleaseByID(client *Client, owner, repo string, id int64) (*Release, error)
- func ListReleases(client *Client, owner, repo string, opts *ReleaseListOptions) ([]Release, error)
- func UpdateRelease(client *Client, owner, repo string, id int64, opts *UpdateReleaseOptions) (*Release, error)
- func UpdateReleaseByTag(client *Client, owner, repo, tag string, opts *UpdateReleaseOptions) (*Release, error)
- type ReleaseAsset
- func GetReleaseAsset(client *Client, owner, repo string, assetID int64) (*ReleaseAsset, error)
- func ListReleaseAssets(client *Client, owner, repo string, releaseID int64) ([]ReleaseAsset, error)
- func UploadReleaseAsset(client *Client, owner, repo string, releaseID int64, filename string, ...) (*ReleaseAsset, error)
- type ReleaseListOptions
- type ReplyPRCommentOptions
- type ReplyPRCommentReply
- type RepoListOptions
- type Repository
- func CreateOrgRepo(client *Client, org string, opts *CreateRepoOptions) (*Repository, error)
- func CreateRepo(client *Client, opts *CreateRepoOptions) (*Repository, error)
- func ForkRepo(client *Client, owner, name string) (*Repository, error)
- func GetRepo(client *Client, owner, name string) (*Repository, error)
- func ListUserRepos(client *Client, opts *RepoListOptions) ([]Repository, error)
- type RepositoryCommit
- type ResolvePRCommentOptions
- type ReviewPROptions
- type StatItem
- type TestPROptions
- type UpdateCommentOptions
- type UpdateIssueOptions
- type UpdateLabelOptions
- type UpdateMilestoneOptions
- type UpdatePROptions
- type UpdateReleaseOptions
- type User
Constants ¶
const ( // DefaultHost is the default GitCode host DefaultHost = "api.gitcode.com" // DefaultAPIVersion is the default API version DefaultAPIVersion = "v5" )
Variables ¶
var ErrInvalidReleaseID = fmtError("invalid release ID")
ErrInvalidReleaseID is returned when release ID is invalid
var ErrNoReleaseID = fmtError("release id was not returned by GitCode API")
ErrNoReleaseID is returned when the GitCode API omits release IDs.
Functions ¶
func BuildURL ¶
BuildURL builds a URL with path parameters
func ClearIssueLabels ¶
ClearIssueLabels removes all labels from an issue
func DefaultHTTPClient ¶
DefaultHTTPClient returns the default HTTP client
func DeleteIssueComment ¶
DeleteIssueComment deletes a comment on an issue
func DeleteLabel ¶
DeleteLabel deletes a label
func DeleteMilestone ¶
DeleteMilestone deletes a milestone
func DeleteRelease ¶
DeleteRelease deletes a release by ID
func DeleteReleaseAsset ¶
DeleteReleaseAsset deletes a release asset
func DeleteReleaseByTag ¶
DeleteReleaseByTag deletes a release by tag name
func DeleteRepo ¶
DeleteRepo deletes a repository
func GetCommitDiff ¶ added in v0.3.0
GetCommitDiff fetches the diff of a commit
func GetCommitPatch ¶ added in v0.3.0
GetCommitPatch fetches the patch of a commit
func RemoveIssueLabel ¶ added in v0.2.4
RemoveIssueLabel removes a label from an issue by updating the issue
func RemoveLabelFromIssue ¶
RemoveLabelFromIssue removes a label from an issue
func ResolvePRComment ¶ added in v0.2.5
func ResolvePRComment(client *Client, owner, repo string, number int, discussionID string, opts *ResolvePRCommentOptions) error
ResolvePRComment updates the resolution status of a PR comment
func ResolveUserIDs ¶ added in v0.3.7
ResolveUserIDs resolves usernames to GitCode user IDs.
func ReviewPR ¶ added in v0.2.5
func ReviewPR(client *Client, owner, repo string, number int, opts *ReviewPROptions) error
ReviewPR handles PR review (approve/force pass)
Types ¶
type APIError ¶
type APIError struct {
StatusCode int `json:"-"`
Message string `json:"message"`
ErrorMessage string `json:"error_message"`
ErrorName string `json:"error"`
ErrorCodeName string `json:"error_code_name"`
}
APIError represents an API error
type AssetUploadURL ¶
AssetUploadURL represents the response from getting upload URL
func GetReleaseUploadURL ¶
func GetReleaseUploadURL(client *Client, owner, repo, tag, filename string) (*AssetUploadURL, error)
GetReleaseUploadURL fetches the upload URL for a release asset
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a GitCode API client
func ClientFromToken ¶
ClientFromToken creates a client with the given token
func ClientFromTokenAndHost ¶
ClientFromTokenAndHost creates a client with the given token and host
func NewClient ¶
NewClient creates a new API client
func NewClientFromHTTP ¶
NewClientFromHTTP creates a client from an existing HTTP client
func (*Client) Get ¶
Get performs a GET request
func (*Client) GetText ¶ added in v0.3.7
GetText performs a GET request and returns the raw response body as text.
func (*Client) Patch ¶
Patch performs a PATCH request
func (*Client) PatchForm ¶ added in v0.2.4
PatchForm performs a PATCH request with form data
func (*Client) Post ¶
Post performs a POST request
func (*Client) PostForm ¶ added in v0.3.7
PostForm performs a POST request with form data.
func (*Client) Put ¶
Put performs a PUT request
func (*Client) REST ¶
REST performs a REST API call
func (*Client) SetToken ¶
SetToken sets the authentication token
type Commit ¶
type Commit struct {
SHA string `json:"sha"`
Message string `json:"message"`
Author *User `json:"author"`
Committer *User `json:"committer"`
}
Commit represents a Git commit
type CommitAuthor ¶ added in v0.3.0
type CommitAuthor struct {
Name string `json:"name"`
Email string `json:"email"`
Date FlexibleTime `json:"date"`
}
CommitAuthor represents commit author info
type CommitComment ¶ added in v0.3.0
type CommitComment struct {
ID interface{} `json:"id"`
Body string `json:"body"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
User *User `json:"user"`
Target *Commit `json:"target"`
}
CommitComment represents a commit comment
func CreateCommitComment ¶ added in v0.3.0
func CreateCommitComment(client *Client, owner, repo, sha, body string) (*CommitComment, error)
CreateCommitComment creates a comment on a commit
func GetCommitComment ¶ added in v0.3.0
func GetCommitComment(client *Client, owner, repo, id string) (*CommitComment, error)
GetCommitComment fetches a single commit comment
func ListCommentsForCommit ¶ added in v0.3.0
func ListCommentsForCommit(client *Client, owner, repo, sha string, opts *ListOptions) ([]CommitComment, error)
ListCommentsForCommit lists comments for a specific commit
func ListCommitComments ¶ added in v0.3.0
func ListCommitComments(client *Client, owner, repo string, opts *ListOptions) ([]CommitComment, error)
ListCommitComments lists all commit comments in a repository
type CommitCommentsBySHAOptions ¶ added in v0.3.0
CommitCommentsBySHAOptions represents options for listing comments by SHA
type CommitFile ¶ added in v0.3.0
type CommitFile struct {
Filename string `json:"filename"`
Status string `json:"status"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
Changes int `json:"changes"`
}
CommitFile represents a file in a commit
type CommitInfo ¶ added in v0.3.0
type CommitInfo struct {
Author *CommitAuthor `json:"author"`
Committer *CommitAuthor `json:"committer"`
Message string `json:"message"`
}
CommitInfo represents the commit details
type CommitStatItem ¶ added in v0.3.0
CommitStatItem represents a single commit stat item
type CommitStatistics ¶ added in v0.3.0
type CommitStatistics struct {
Commits []CommitStatItem `json:"commits"`
Statistics []StatItem `json:"statistics"`
Total int `json:"total"`
}
CommitStatistics represents code contribution statistics
func GetCommitStatistics ¶ added in v0.3.0
func GetCommitStatistics(client *Client, owner, repo string, opts *CommitStatsOptions) (*CommitStatistics, error)
GetCommitStatistics gets code contribution statistics for a repository
type CommitStats ¶ added in v0.3.0
type CommitStats struct {
Additions int `json:"additions"`
Deletions int `json:"deletions"`
Total int `json:"total"`
}
CommitStats represents commit statistics
type CommitStatsOptions ¶ added in v0.3.0
type CommitStatsOptions struct {
BranchName string `url:"branch_name,omitempty"`
Author string `url:"author,omitempty"`
OnlySelf bool `url:"only_self,omitempty"`
Since string `url:"since,omitempty"`
Until string `url:"until,omitempty"`
}
CommitStatsOptions represents options for getting commit statistics
type CreateCommentOptions ¶
type CreateCommentOptions struct {
Body string `json:"body"`
}
CreateCommentOptions represents options for creating a comment
type CreateIssueOptions ¶
type CreateIssueOptions struct {
Title string `json:"title"`
Body string `json:"body,omitempty"`
AssigneeIDs []string `json:"assignee_ids,omitempty"`
Labels []string `json:"labels,omitempty"`
Milestone int `json:"milestone,omitempty"`
}
CreateIssueOptions represents options for creating an issue
type CreateLabelOptions ¶
type CreateLabelOptions struct {
Name string `json:"name"`
Color string `json:"color,omitempty"`
Description string `json:"description,omitempty"`
}
CreateLabelOptions represents options for creating a label
type CreateMilestoneOptions ¶
type CreateMilestoneOptions struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
State string `json:"state,omitempty"`
DueOn string `json:"due_on,omitempty"`
}
CreateMilestoneOptions represents options for creating a milestone
type CreatePRCommentOptions ¶
type CreatePRCommentOptions struct {
Body string `json:"body"`
Path string `json:"path,omitempty"`
Position int `json:"position,omitempty"`
}
CreatePRCommentOptions represents options for creating a PR comment
type CreatePROptions ¶
type CreatePROptions struct {
Title string `json:"title"`
Body string `json:"body,omitempty"`
Head string `json:"head"`
Base string `json:"base"`
Draft bool `json:"draft,omitempty"`
ForkPath string `json:"fork_path,omitempty"` // 跨仓库 PR:fork 项目路径【owner/repo】
}
CreatePROptions represents options for creating a PR
type CreatePRReviewOptions ¶
type CreatePRReviewOptions struct {
Body string `json:"body,omitempty"`
Event string `json:"event"`
Comments []PRReviewComment `json:"comments,omitempty"`
}
CreatePRReviewOptions represents options for creating a PR review
type CreateReleaseOptions ¶
type CreateReleaseOptions struct {
TagName string `json:"tag_name"`
Name string `json:"name,omitempty"`
Body string `json:"body,omitempty"`
Draft bool `json:"draft,omitempty"`
Prerelease bool `json:"prerelease,omitempty"`
TargetCommitish string `json:"target_commitish,omitempty"`
}
CreateReleaseOptions represents options for creating a release
type CreateRepoOptions ¶
type CreateRepoOptions struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Private bool `json:"private"`
AutoInit bool `json:"auto_init,omitempty"`
GitignoreTemplate string `json:"gitignore_template,omitempty"`
LicenseTemplate string `json:"license_template,omitempty"`
}
CreateRepoOptions represents options for creating a repository
type EditPRCommentOptions ¶ added in v0.2.5
type EditPRCommentOptions struct {
Body string `json:"body"`
}
EditPRCommentOptions represents options for editing a PR comment
type FlexibleTime ¶ added in v0.3.3
FlexibleTime is a custom time type that can parse multiple time formats returned by GitCode API.
func (FlexibleTime) Format ¶ added in v0.3.3
func (ft FlexibleTime) Format(layout string) string
Format returns a formatted string representation of the time.
func (FlexibleTime) IsZero ¶ added in v0.3.3
func (ft FlexibleTime) IsZero() bool
IsZero returns true if the time is zero.
func (FlexibleTime) MarshalJSON ¶ added in v0.3.3
func (ft FlexibleTime) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (FlexibleTime) String ¶ added in v0.3.3
func (ft FlexibleTime) String() string
String returns a string representation of the time.
func (*FlexibleTime) UnmarshalJSON ¶ added in v0.3.3
func (ft *FlexibleTime) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface. It tries multiple time formats to parse the input.
type Issue ¶
type Issue struct {
ID interface{} `json:"id"`
Number string `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
HTMLURL string `json:"html_url"`
User *User `json:"user"`
Assignees []*User `json:"assignees"`
Labels []*Label `json:"labels"`
Milestone *Milestone `json:"milestone"`
CreatedAt FlexibleTime `json:"created_at"`
UpdatedAt FlexibleTime `json:"updated_at"`
ClosedAt *FlexibleTime `json:"closed_at"`
Comments int `json:"comments"`
}
Issue represents a GitCode issue
func CloseIssue ¶
CloseIssue closes an issue
func CreateIssue ¶
func CreateIssue(client *Client, owner, repo string, opts *CreateIssueOptions) (*Issue, error)
CreateIssue creates a new issue
func GetIssue ¶
GetIssue fetches an issue by number
func ListRepoIssues ¶
func ListRepoIssues(client *Client, owner, repo string, opts *IssueListOptions) ([]Issue, error)
ListRepoIssues lists issues for a repository
func ReopenIssue ¶
ReopenIssue reopens a closed issue
type IssueComment ¶
type IssueComment struct {
ID interface{} `json:"id"`
Body string `json:"body"`
User *User `json:"user"`
CreatedAt FlexibleTime `json:"created_at"`
UpdatedAt FlexibleTime `json:"updated_at"`
}
IssueComment represents a comment on an issue
func CreateIssueComment ¶
func CreateIssueComment(client *Client, owner, repo string, number int, opts *CreateCommentOptions) (*IssueComment, error)
CreateIssueComment creates a comment on an issue
func ListIssueComments ¶
func ListIssueComments(client *Client, owner, repo string, number int, opts *IssueCommentListOptions) ([]IssueComment, error)
ListIssueComments lists comments on an issue
func UpdateIssueComment ¶ added in v0.3.7
func UpdateIssueComment(client *Client, owner, repo string, commentID string, opts *UpdateCommentOptions) (*IssueComment, error)
UpdateIssueComment updates a comment on an issue.
type IssueCommentListOptions ¶ added in v0.3.7
IssueCommentListOptions represents options for listing issue comments.
type IssueListOptions ¶
type IssueListOptions struct {
State string `url:"state,omitempty"`
Labels string `url:"labels,omitempty"`
Sort string `url:"sort,omitempty"`
Direction string `url:"direction,omitempty"`
Since string `url:"since,omitempty"`
PerPage int `url:"per_page,omitempty"`
Page int `url:"page,omitempty"`
Milestone string `url:"milestone,omitempty"`
Assignee string `url:"assignee,omitempty"`
Creator string `url:"creator,omitempty"`
CreatedAfter string `url:"created_after,omitempty"`
CreatedBefore string `url:"created_before,omitempty"`
UpdatedAfter string `url:"updated_after,omitempty"`
UpdatedBefore string `url:"updated_before,omitempty"`
Search string `url:"search,omitempty"`
}
IssueListOptions represents options for listing issues
type IssuePR ¶ added in v0.2.11
type IssuePR struct {
ID interface{} `json:"id"`
HTMLURL string `json:"html_url"`
DiffURL string `json:"diff_url"`
Number int `json:"number"`
State string `json:"state"`
Title string `json:"title"`
Body string `json:"body"`
Labels []*Label `json:"labels"`
User *User `json:"user"`
Head *PRBranch `json:"head"`
Base *PRBranch `json:"base"`
Assignees []*User `json:"assignees"`
Testers []*User `json:"testers"`
CreatedAt FlexibleTime `json:"created_at"`
UpdatedAt FlexibleTime `json:"updated_at"`
MergedAt *FlexibleTime `json:"merged_at"`
ClosedAt *FlexibleTime `json:"closed_at"`
CanMergeCheck bool `json:"can_merge_check"`
}
IssuePR represents a Pull Request associated with an issue
type Label ¶
type Label struct {
ID interface{} `json:"id"`
Name string `json:"name"`
Color string `json:"color"`
Description string `json:"description"`
}
Label represents a GitCode label
func AddIssueLabels ¶ added in v0.2.4
func AddIssueLabels(client *Client, owner, repo string, number int, labels []string) ([]*Label, error)
AddIssueLabels adds labels to an issue by updating the issue
func AddLabelsToIssue ¶
func AddLabelsToIssue(client *Client, owner, repo string, number int, labels []string) ([]Label, error)
AddLabelsToIssue adds labels to an issue
func CreateLabel ¶
func CreateLabel(client *Client, owner, repo string, opts *CreateLabelOptions) (*Label, error)
CreateLabel creates a new label in a repository
func GetLabel ¶
GetLabel fetches a label by name
func ListRepoLabels ¶
ListRepoLabels lists labels for a repository
type ListOptions ¶ added in v0.3.0
ListOptions represents common list options
type MergePROptions ¶
type MergePROptions struct {
CommitTitle string `json:"commit_title,omitempty"`
CommitMessage string `json:"commit_message,omitempty"`
SHA string `json:"sha,omitempty"`
MergeMethod string `json:"merge_method,omitempty"`
}
MergePROptions represents options for merging a PR
type Milestone ¶
type Milestone struct {
ID interface{} `json:"id"`
Number int `json:"number"`
Title string `json:"title"`
Description string `json:"description"`
State string `json:"state"`
DueOn string `json:"due_on"`
}
Milestone represents a GitCode milestone
func CloseMilestone ¶
CloseMilestone closes a milestone
func CreateMilestone ¶
func CreateMilestone(client *Client, owner, repo string, opts *CreateMilestoneOptions) (*Milestone, error)
CreateMilestone creates a new milestone
func GetMilestone ¶
GetMilestone fetches a milestone by number
func ListRepoMilestones ¶
ListRepoMilestones lists milestones for a repository
func OpenMilestone ¶
OpenMilestone reopens a milestone
type PRBranch ¶
type PRBranch struct {
Label string `json:"label"`
Ref string `json:"ref"`
SHA string `json:"sha"`
Repo *Repository `json:"repo"`
}
PRBranch represents a branch in a PR
type PRComment ¶
type PRComment struct {
ID interface{} `json:"id"`
DiscussionID string `json:"discussion_id"`
Body string `json:"body"`
User *User `json:"user"`
CreatedAt FlexibleTime `json:"created_at"`
UpdatedAt FlexibleTime `json:"updated_at"`
CommentType string `json:"comment_type"`
Resolved bool `json:"resolved"`
DiffFile string `json:"diff_file"`
DiffPosition interface{} `json:"diff_position"`
}
PRComment represents a comment on a PR
func CreatePRComment ¶
func CreatePRComment(client *Client, owner, repo string, number int, opts *CreatePRCommentOptions) (*PRComment, error)
CreatePRComment creates a comment on a PR
type PRDiff ¶ added in v0.2.2
type PRDiff struct {
NewBlobID string `json:"new_blob_id"`
Statistic *PRStatistic `json:"statistic"`
Type string `json:"type"`
Path string `json:"path"`
OldPath string `json:"old_path"`
NewPath string `json:"new_path"`
View int `json:"view"`
Head *PRDiffHead `json:"head"`
Content *PRDiffContent `json:"content"`
}
PRDiff represents a single file diff
type PRDiffContent ¶ added in v0.2.2
type PRDiffContent struct {
Text []*PRDiffLine `json:"text"`
}
PRDiffContent represents diff content
type PRDiffHead ¶ added in v0.2.2
type PRDiffHead struct {
URL string `json:"url"`
CommitID string `json:"commit_id"`
Additions int `json:"added_lines"`
Deletions int `json:"remove_lines"`
}
PRDiffHead represents diff head info
type PRDiffLine ¶ added in v0.2.2
type PRDiffLine struct {
LineContent string `json:"line_content"`
OldLine interface{} `json:"old_line"` // can be string "..." or object
NewLine interface{} `json:"new_line"` // can be string "..." or object
Type string `json:"type"`
}
PRDiffLine represents a single diff line
type PRDiffRefs ¶ added in v0.2.2
type PRDiffRefs struct {
BaseSHA string `json:"base_sha"`
StartSHA string `json:"start_sha"`
HeadSHA string `json:"head_sha"`
}
PRDiffRefs represents diff references
type PRFilesResponse ¶ added in v0.2.2
type PRFilesResponse struct {
Code int `json:"code"`
AddedLines int `json:"added_lines"`
RemoveLines int `json:"remove_lines"`
Count int `json:"count"`
DiffRefs *PRDiffRefs `json:"diff_refs"`
Diffs []*PRDiff `json:"diffs"`
}
PRFilesResponse represents the response from PR files API
type PRListOptions ¶
type PRListOptions struct {
State string `url:"state,omitempty"`
Head string `url:"head,omitempty"`
Base string `url:"base,omitempty"`
Sort string `url:"sort,omitempty"`
Direction string `url:"direction,omitempty"`
PerPage int `url:"per_page,omitempty"`
Page int `url:"page,omitempty"`
}
PRListOptions represents options for listing PRs
type PRReview ¶
type PRReview struct {
ID interface{} `json:"id"`
User *User `json:"user"`
Body string `json:"body"`
State string `json:"state"`
SubmittedAt FlexibleTime `json:"submitted_at"`
}
PRReview represents a review on a PR
type PRReviewComment ¶
type PRReviewComment struct {
Path string `json:"path"`
Position int `json:"position"`
Body string `json:"body"`
}
PRReviewComment represents a comment in a review
type PRStatistic ¶ added in v0.2.2
PRStatistic represents file change statistics
type PullRequest ¶
type PullRequest struct {
ID interface{} `json:"id"`
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
HTMLURL string `json:"html_url"`
DiffURL string `json:"diff_url"`
PatchURL string `json:"patch_url"`
User *User `json:"user"`
Head *PRBranch `json:"head"`
Base *PRBranch `json:"base"`
Merged bool `json:"merged"`
MergedAt *string `json:"merged_at"`
Mergeable *bool `json:"mergeable"`
MergeState interface{} `json:"mergeable_state"`
Draft bool `json:"draft"`
CreatedAt FlexibleTime `json:"created_at"`
UpdatedAt FlexibleTime `json:"updated_at"`
ClosedAt *string `json:"closed_at"`
Comments int `json:"comments"`
Commits int `json:"commits"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
ChangedFiles int `json:"changed_files"`
Labels []*Label `json:"labels"`
Assignees []*User `json:"assignees"`
Reviewers []*User `json:"requested_reviewers"`
}
PullRequest represents a GitCode pull request
func ClosePullRequest ¶
func ClosePullRequest(client *Client, owner, repo string, number int) (*PullRequest, error)
ClosePullRequest closes a PR
func CreatePullRequest ¶
func CreatePullRequest(client *Client, owner, repo string, opts *CreatePROptions) (*PullRequest, error)
CreatePullRequest creates a new PR
func EditPR ¶ added in v0.2.5
func EditPR(client *Client, owner, repo string, number int, opts *UpdatePROptions) (*PullRequest, error)
EditPR updates a PR's information
func GetPullRequest ¶
func GetPullRequest(client *Client, owner, repo string, number int) (*PullRequest, error)
GetPullRequest fetches a PR by number
func ListPullRequests ¶
func ListPullRequests(client *Client, owner, repo string, opts *PRListOptions) ([]PullRequest, error)
ListPullRequests lists pull requests for a repository
func MergePullRequest ¶
func MergePullRequest(client *Client, owner, repo string, number int, opts *MergePROptions) (*PullRequest, error)
MergePullRequest merges a PR
func ReopenPullRequest ¶
func ReopenPullRequest(client *Client, owner, repo string, number int) (*PullRequest, error)
ReopenPullRequest reopens a closed PR
func UpdatePullRequest ¶
func UpdatePullRequest(client *Client, owner, repo string, number int, opts *UpdatePROptions) (*PullRequest, error)
UpdatePullRequest updates an existing PR
type Release ¶
type Release struct {
ID interface{} `json:"id"`
TagName string `json:"tag_name"`
TargetCommitish string `json:"target_commitish"`
Name string `json:"name"`
Body string `json:"body"`
Draft bool `json:"draft"`
Prerelease bool `json:"prerelease"`
HTMLURL string `json:"html_url"`
AssetsURL string `json:"assets_url"`
UploadURL string `json:"upload_url"`
CreatedAt FlexibleTime `json:"created_at"`
PublishedAt *FlexibleTime `json:"published_at"`
Author *User `json:"author"`
Assets []ReleaseAsset `json:"assets"`
}
Release represents a GitCode release
func CreateRelease ¶
func CreateRelease(client *Client, owner, repo string, opts *CreateReleaseOptions) (*Release, error)
CreateRelease creates a new release
func GetLatestRelease ¶
GetLatestRelease fetches the latest release for a repository
func GetRelease ¶
GetRelease fetches a release by tag name
func GetReleaseByID ¶
GetReleaseByID fetches a release by ID
func ListReleases ¶
func ListReleases(client *Client, owner, repo string, opts *ReleaseListOptions) ([]Release, error)
ListReleases lists releases for a repository
func UpdateRelease ¶
func UpdateRelease(client *Client, owner, repo string, id int64, opts *UpdateReleaseOptions) (*Release, error)
UpdateRelease updates an existing release by ID
type ReleaseAsset ¶
type ReleaseAsset struct {
ID int `json:"id"`
Name string `json:"name"`
Label string `json:"label"`
State string `json:"state"`
ContentType string `json:"content_type"`
Size int `json:"size"`
Downloads int `json:"download_count"`
URL string `json:"url"`
BrowserDownloadURL string `json:"browser_download_url"`
CreatedAt FlexibleTime `json:"created_at"`
UpdatedAt FlexibleTime `json:"updated_at"`
}
ReleaseAsset represents an asset in a release
func GetReleaseAsset ¶
func GetReleaseAsset(client *Client, owner, repo string, assetID int64) (*ReleaseAsset, error)
GetReleaseAsset fetches a single release asset
type ReleaseListOptions ¶
type ReleaseListOptions struct {
PerPage int `url:"per_page,omitempty"`
Page int `url:"page,omitempty"`
}
ReleaseListOptions represents options for listing releases
type ReplyPRCommentOptions ¶ added in v0.2.5
type ReplyPRCommentOptions struct {
Body string `json:"body"`
}
ReplyPRCommentOptions represents options for replying to a PR comment
type ReplyPRCommentReply ¶ added in v0.2.5
type ReplyPRCommentReply struct {
ID string `json:"id"`
NoteID int `json:"noteId"`
Body string `json:"body"`
}
ReplyPRCommentReply represents the response from replying to a PR comment
func ReplyPRComment ¶ added in v0.2.5
func ReplyPRComment(client *Client, owner, repo string, number int, discussionID string, opts *ReplyPRCommentOptions) (*ReplyPRCommentReply, error)
ReplyPRComment replies to a PR comment discussion
type RepoListOptions ¶
type RepoListOptions struct {
Visibility string `url:"visibility,omitempty"`
Affiliation string `url:"affiliation,omitempty"`
Type string `url:"type,omitempty"`
Sort string `url:"sort,omitempty"`
Direction string `url:"direction,omitempty"`
PerPage int `url:"per_page,omitempty"`
Page int `url:"page,omitempty"`
}
RepoListOptions represents options for listing repositories
type Repository ¶
type Repository struct {
ID interface{} `json:"id"`
Name string `json:"name"`
FullName string `json:"full_name"`
Description string `json:"description"`
Private bool `json:"private"`
Owner *User `json:"owner"`
HTMLURL string `json:"web_url"`
CloneURL string `json:"http_url_to_repo"`
SSHURL string `json:"ssh_url_to_repo"`
DefaultBranch string `json:"default_branch"`
CreatedAt FlexibleTime `json:"created_at"`
UpdatedAt FlexibleTime `json:"updated_at"`
StargazersCount int `json:"stargazers_count"`
ForksCount int `json:"forks_count"`
OpenIssuesCount int `json:"open_issues_count"`
Language string `json:"language"`
}
Repository represents a GitCode repository
func CreateOrgRepo ¶
func CreateOrgRepo(client *Client, org string, opts *CreateRepoOptions) (*Repository, error)
CreateOrgRepo creates a new repository in an organization
func CreateRepo ¶
func CreateRepo(client *Client, opts *CreateRepoOptions) (*Repository, error)
CreateRepo creates a new repository for the authenticated user
func ForkRepo ¶
func ForkRepo(client *Client, owner, name string) (*Repository, error)
ForkRepo forks a repository
func GetRepo ¶
func GetRepo(client *Client, owner, name string) (*Repository, error)
GetRepo fetches a repository by owner/name
func ListUserRepos ¶
func ListUserRepos(client *Client, opts *RepoListOptions) ([]Repository, error)
ListUserRepos lists repositories for the authenticated user
type RepositoryCommit ¶ added in v0.3.0
type RepositoryCommit struct {
SHA string `json:"sha"`
URL string `json:"url"`
HTMLURL string `json:"html_url"`
CommentsURL string `json:"comments_url"`
Commit *CommitInfo `json:"commit"`
Author *User `json:"author"`
Committer *User `json:"committer"`
Stats *CommitStats `json:"stats"`
Files []CommitFile `json:"files"`
}
RepositoryCommit represents a detailed commit from the commits API
type ResolvePRCommentOptions ¶ added in v0.2.5
type ResolvePRCommentOptions struct {
Resolved bool `json:"resolved"`
}
ResolvePRCommentOptions represents options for resolving a PR comment
type ReviewPROptions ¶ added in v0.2.5
type ReviewPROptions struct {
Force bool `json:"force,omitempty"` // Force approval (admin only)
}
ReviewPROptions represents options for reviewing a PR
type StatItem ¶ added in v0.3.0
type StatItem struct {
Author string `json:"author"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
Total int `json:"total"`
}
StatItem represents a statistics item
type TestPROptions ¶ added in v0.2.5
type TestPROptions struct {
Force bool `json:"force,omitempty"` // Force test pass (admin only)
}
TestPROptions represents options for PR test
type UpdateCommentOptions ¶ added in v0.3.7
type UpdateCommentOptions struct {
Body string `json:"body"`
}
UpdateCommentOptions represents options for updating an issue comment.
type UpdateIssueOptions ¶
type UpdateIssueOptions struct {
Repo string `json:"repo,omitempty"`
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
State string `json:"state,omitempty"`
AssigneeIDs []string `json:"assignee_ids,omitempty"`
Labels []string `json:"labels,omitempty"`
Milestone int `json:"milestone,omitempty"`
SecurityHole string `json:"security_hole,omitempty"`
}
UpdateIssueOptions represents options for updating an issue
type UpdateLabelOptions ¶
type UpdateLabelOptions struct {
NewName string `json:"new_name,omitempty"`
Color string `json:"color,omitempty"`
Description string `json:"description,omitempty"`
}
UpdateLabelOptions represents options for updating a label
type UpdateMilestoneOptions ¶
type UpdateMilestoneOptions struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
State string `json:"state,omitempty"`
DueOn string `json:"due_on,omitempty"`
}
UpdateMilestoneOptions represents options for updating a milestone
type UpdatePROptions ¶
type UpdatePROptions struct {
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
State string `json:"state,omitempty"`
StateEvent string `json:"state_event,omitempty"`
Base string `json:"base,omitempty"`
Draft *bool `json:"draft,omitempty"`
MilestoneNumber int `json:"milestone_number,omitempty"`
Labels []string `json:"labels,omitempty"`
CloseRelatedIssue *bool `json:"close_related_issue,omitempty"`
}
UpdatePROptions represents options for updating a PR
type UpdateReleaseOptions ¶
type UpdateReleaseOptions struct {
TagName string `json:"tag_name,omitempty"`
TargetCommitish string `json:"target_commitish,omitempty"`
Name string `json:"name,omitempty"`
Body string `json:"body,omitempty"`
Draft *bool `json:"draft,omitempty"`
Prerelease *bool `json:"prerelease,omitempty"`
}
UpdateReleaseOptions represents options for updating a release
type User ¶
type User struct {
ID interface{} `json:"id"`
Login string `json:"login"`
Name string `json:"name"`
Email string `json:"email"`
AvatarURL string `json:"avatar_url"`
HTMLURL string `json:"html_url"`
CreatedAt string `json:"created_at"`
}
User represents a GitCode user
func CurrentUser ¶
CurrentUser fetches the current authenticated user
func GetUser ¶
GetUser fetches a user by username
func VerifyToken ¶
VerifyToken verifies that a token is valid by fetching the current user
Source Files
¶
- client.go
- queries_commit.go
- queries_issue.go
- queries_label_milestone.go
- queries_pr.go
- queries_release.go
- queries_repo.go
- queries_user.go
- time.go