123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- package github
- import (
- "context"
- "fmt"
- "time"
- )
- type RepoStatus struct {
- ID *int64 `json:"id,omitempty"`
- URL *string `json:"url,omitempty"`
-
-
- State *string `json:"state,omitempty"`
-
-
- TargetURL *string `json:"target_url,omitempty"`
-
- Description *string `json:"description,omitempty"`
-
- Context *string `json:"context,omitempty"`
- Creator *User `json:"creator,omitempty"`
- CreatedAt *time.Time `json:"created_at,omitempty"`
- UpdatedAt *time.Time `json:"updated_at,omitempty"`
- }
- func (r RepoStatus) String() string {
- return Stringify(r)
- }
- func (s *RepositoriesService) ListStatuses(ctx context.Context, owner, repo, ref string, opt *ListOptions) ([]*RepoStatus, *Response, error) {
- u := fmt.Sprintf("repos/%v/%v/commits/%v/statuses", owner, repo, ref)
- u, err := addOptions(u, opt)
- if err != nil {
- return nil, nil, err
- }
- req, err := s.client.NewRequest("GET", u, nil)
- if err != nil {
- return nil, nil, err
- }
- var statuses []*RepoStatus
- resp, err := s.client.Do(ctx, req, &statuses)
- if err != nil {
- return nil, resp, err
- }
- return statuses, resp, nil
- }
- func (s *RepositoriesService) CreateStatus(ctx context.Context, owner, repo, ref string, status *RepoStatus) (*RepoStatus, *Response, error) {
- u := fmt.Sprintf("repos/%v/%v/statuses/%v", owner, repo, ref)
- req, err := s.client.NewRequest("POST", u, status)
- if err != nil {
- return nil, nil, err
- }
- repoStatus := new(RepoStatus)
- resp, err := s.client.Do(ctx, req, repoStatus)
- if err != nil {
- return nil, resp, err
- }
- return repoStatus, resp, nil
- }
- type CombinedStatus struct {
-
-
- State *string `json:"state,omitempty"`
- Name *string `json:"name,omitempty"`
- SHA *string `json:"sha,omitempty"`
- TotalCount *int `json:"total_count,omitempty"`
- Statuses []RepoStatus `json:"statuses,omitempty"`
- CommitURL *string `json:"commit_url,omitempty"`
- RepositoryURL *string `json:"repository_url,omitempty"`
- }
- func (s CombinedStatus) String() string {
- return Stringify(s)
- }
- func (s *RepositoriesService) GetCombinedStatus(ctx context.Context, owner, repo, ref string, opt *ListOptions) (*CombinedStatus, *Response, error) {
- u := fmt.Sprintf("repos/%v/%v/commits/%v/status", owner, repo, ref)
- u, err := addOptions(u, opt)
- if err != nil {
- return nil, nil, err
- }
- req, err := s.client.NewRequest("GET", u, nil)
- if err != nil {
- return nil, nil, err
- }
- status := new(CombinedStatus)
- resp, err := s.client.Do(ctx, req, status)
- if err != nil {
- return nil, resp, err
- }
- return status, resp, nil
- }
|