api

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: ISC Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger sets the package-wide logger. Any calls to this function must be made before a server is created and used (it is not concurrent safe).

Types

type Author

type Author struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Date  string `json:"date"`
}

Author has basic information about the creator of a commit.

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client contains the http client that communicates with the Github servers, mutexes and api rate limiting rules.

func NewClient

func NewClient(token string) *Client

NewClient creates a new instance of Client that contains a authorized client with the provided token argument.

func (*Client) FetchCommit

func (a *Client) FetchCommit(org, repo string, sha string) (*PullRequestCommit, error)

FetchCommit requests a given commit based on organization, repo and hash

func (*Client) FetchOrgRepos

func (a *Client) FetchOrgRepos(org string) ([]*Repository, error)

FetchOrgRepos requests all repos that are underneath the given organization.

func (*Client) FetchPullRequest

func (a *Client) FetchPullRequest(org, repo string, prNum int) (*PullRequest, error)

FetchPullRequest requests information about a given pull request based on organization, repo and pull request number.

func (*Client) FetchPullRequestCommitSHAs

func (a *Client) FetchPullRequestCommitSHAs(org, repo string, prNum int) ([]string, error)

FetchPullRequestCommits requests all of the commit hashes under a given pull request based on the organization, repo, and pull request number.

func (*Client) FetchPullRequestCommits

func (a *Client) FetchPullRequestCommits(org, repo string, hashes []string) ([]*PullRequestCommit, error)

FetchPullRequestCommits returns a list of parsed commits based on org, repo and a list of hashes provided in the arguments.

func (*Client) FetchPullRequestReviews

func (a *Client) FetchPullRequestReviews(org, repo string, prNum int) ([]PullRequestReview, error)

FetchPullRequestReviews requests all of the reviews from a given pull request based on organization, repository, pull request number and time.

func (*Client) FetchPullsRequest

func (a *Client) FetchPullsRequest(org, repo string) ([]PullsRequest, error)

FetchPullsRequest requests all of the pull requests from a given repo under an organization.

func (*Client) RateLimit

func (a *Client) RateLimit() (RateLimitRule, error)

RateLimit determines if the current rate limit for the client is about to be tripped. If so, it will go to sleep for a given perioud of time.

type Commit

type Commit struct {
	Author    Author `json:"author"`
	Committer Author `json:"committer"`
	Message   string `json:"message"`
}

Commit holds basic information about a given commit, but no details about the actual changes.

type CommitParent

type CommitParent struct {
	SHA string `json:"sha"`
	URL string `json:"url"`
}

CommitParent has information about a commit's parent commit.

type CommitStats

type CommitStats struct {
	Additions int `json:"additions"`
	Deletions int `json:"deletions"`
	Total     int `json:"total"`
}

CommitStats contains basic LOC information about a given commit.

type PullRequest

type PullRequest struct {
	URL       string `json:"url"`
	Number    int    `json:"number"`
	User      User   `json:"user"`
	UpdatedAt string `json:"updated_at"`
	ClosedAt  string `json:"closed_at"`
	MergedAt  string `json:"merged_at"`
	Merged    bool   `json:"merged"`
	State     string `json:"state"`
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
	MergedBy  User   `json:"merged_by"`
}

PullRequest contains all the information about a submitted pull request.

type PullRequestCommit

type PullRequestCommit struct {
	SHA       string         `json:"sha"`
	URL       string         `json:"url"`
	Parents   []CommitParent `json:"parents"`
	Stats     CommitStats    `json:"stats"`
	Commit    Commit         `json:"commit"`
	Author    User           `json:"author"`
	Committer User           `json:"committer"`

	// local change
	Discarded bool `json:"discarded"`
}

PullRequestCommit contains information about commits underneath a given Pull request.

type PullRequestReview

type PullRequestReview struct {
	ID          int64  `json:"id"`
	User        User   `json:"user"`
	State       string `json:"state"`
	SubmittedAt string `json:"submitted_at"`
	CommitID    string `json:"commit_id"`
}

PullRequestReview contains information about any review that has been submitted for a given pull request.

type PullsRequest

type PullsRequest struct {
	URL            string `json:"url"`
	Number         int    `json:"number"`
	State          string `json:"state"`
	Title          string `json:"title"`
	User           User   `json:"user"`
	UpdatedAt      string `json:"updated_at"`
	MergedAt       string `json:"merged_at"`
	MergeCommitSHA string `json:"merge_commit_sha"`
	CommitsURL     string `json:"commits_url"`
}

PullsRequest contains all high level information returned from the PullsRequest request.

type RateLimit

type RateLimit struct {
	Resources RateLimitResource `json:"resources"`
	Rate      RateLimitRule     `json:"rate"`
}

RateLimit contains resource and rate information that is used to determine whether or not to limit request submission.

type RateLimitResource

type RateLimitResource struct {
	Core                RateLimitRule `json:"core"`
	Search              RateLimitRule `json:"search"`
	GraphQL             RateLimitRule `json:"graphql"`
	IntegrationManifest RateLimitRule `json:"integration_manifest"`
}

RateLimitResource contains various RateLimitRule information.

type RateLimitRule

type RateLimitRule struct {
	Limit     int   `json:"limit"`
	Remaining int   `json:"remaining"`
	Reset     int64 `json:"reset"`
}

RateLimitRule has the limit, the number of requests remaining and the time to reset.

type Repository

type Repository struct {
	Name     string `json:"name"`
	FullName string `json:"full_name"`
	Private  bool   `json:"private"`
	Owner    User   `json:"owner"`
	Fork     bool   `json:"fork"`
	URL      string `json:"url"`
}

Repository contains all the information of a repo underneath an organization.

type User

type User struct {
	ID        int64  `json:"id"`
	NodeID    string `json:"node_id"`
	Login     string `json:"login"`
	URL       string `json:"url"`
	HTMLURL   string `json:"htmlurl"`
	Type      string `json:"type"`
	SiteAdmin bool   `json:"site_admin"`
}

User contains all the information about a given User connected to a Pull Request, Review or Commit.

Jump to

Keyboard shortcuts

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