githubapi

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_HOST string = "github.com"
	RAW_HOST     string = "raw.githubusercontent.com"
)

Variables

This section is empty.

Functions

func APILastCommits added in v0.0.5

func APILastCommits(owner, repo string) string

APILastCommits github last commit api

func APILastCommitsOfBranch added in v0.0.5

func APILastCommitsOfBranch(owner, repo, branch string) string

APILastCommitsOfBranch github last commit of specific branch api

func APILastCommitsOfPath added in v0.0.5

func APILastCommitsOfPath(owner, repo, branch, path string) string

APILastCommitsOfPath github last commit of specific branch api

func APIMetadata added in v0.0.5

func APIMetadata(owner, repo string) string

APIDefaultBranch github repo metadata api

func APIRaw

func APIRaw(owner, repo, branch, path string) string

APIRaw github raw file api

func APIRepoTree

func APIRepoTree(owner, repo, branch string) string

APIRepoTree github tree api

Types

type Author added in v0.0.5

type Author struct {
	Login             string `json:"login"`
	ID                int    `json:"id"`
	NodeID            string `json:"node_id"`
	AvatarURL         string `json:"avatar_url"`
	GravatarID        string `json:"gravatar_id"`
	URL               string `json:"url"`
	HtmlURL           string `json:"html_url"`
	FollowersURL      string `json:"followers_url"`
	FollowingURL      string `json:"following_url"`
	GistsURL          string `json:"gists_url"`
	StarredURL        string `json:"starred_url"`
	SubscriptionsURL  string `json:"subscriptions_url"`
	OrganizationsURL  string `json:"organizations_url"`
	ReposURL          string `json:"repos_url"`
	EventsURL         string `json:"events_url"`
	ReceivedEventsURL string `json:"received_events_url"`
	Type              string `json:"type"`
	SiteAdmin         bool   `json:"site_admin"`
}

type Commit added in v0.0.5

type Commit struct {
	SHA         string          `json:"sha"`
	NodeID      string          `json:"node_id"`
	Commit      CommitsMetadata `json:"commit"`
	URL         string          `json:"url"`
	HtmlURL     string          `json:"html_url"`
	CommentsURL string          `json:"comments_url"`
	Author      Author          `json:"author"`
	Committer   Committer       `json:"committer"`
	Parents     []struct {
		SHA     string `json:"sha"`
		URL     string `json:"url"`
		HtmlURL string `json:"html_url"`
	} `json:"parents"`
	Stats struct {
		Total     int `json:"total"`
		Additions int `json:"additions"`
		Deletions int `json:"deletions"`
	} `json:"stats"`
	Files []Files `json:"files"`
}

LatestCommit returned structure

type CommitsMetadata added in v0.0.5

type CommitsMetadata struct {
	Author struct {
		Name  string    `json:"name"`
		Email string    `json:"email"`
		Date  time.Time `json:"date"`
	} `json:"author"`
	Committer struct {
		Name  string    `json:"name"`
		Email string    `json:"email"`
		Date  time.Time `json:"date"`
	} `json:"committer"`
	Message string `json:"message"`
	Tree    struct {
		SHA string `json:"sha"`
		URL string `json:"url"`
	} `json:"tree"`
	URL          string `json:"url"`
	CommentCount int    `json:"comment_count"`
	Verification struct {
		Verified  bool        `json:"verified"`
		Reason    string      `json:"reason"`
		Signature interface{} `json:"signature"`
		Payload   interface{} `json:"payload"`
	} `json:"verification"`
}

type Committer added in v0.0.5

type Committer struct {
	Login             string `json:"login"`
	ID                int    `json:"id"`
	NodeID            string `json:"node_id"`
	AvatarURL         string `json:"avatar_url"`
	GravatarID        string `json:"gravatar_id"`
	URL               string `json:"url"`
	HtmlURL           string `json:"html_url"`
	FollowersURL      string `json:"followers_url"`
	FollowingURL      string `json:"following_url"`
	GistsURL          string `json:"gists_url"`
	StarredURL        string `json:"starred_url"`
	SubscriptionsURL  string `json:"subscriptions_url"`
	OrganizationsURL  string `json:"organizations_url"`
	ReposURL          string `json:"repos_url"`
	EventsURL         string `json:"events_url"`
	ReceivedEventsURL string `json:"received_events_url"`
	Type              string `json:"type"`
	SiteAdmin         bool   `json:"site_admin"`
}

type Files added in v0.0.5

type Files struct {
	SHA         string `json:"sha"`
	Filename    string `json:"filename"`
	Status      string `json:"status"`
	Additions   int    `json:"additions"`
	Deletions   int    `json:"deletions"`
	Changes     int    `json:"changes"`
	BlobURL     string `json:"blob_url"`
	RawURL      string `json:"raw_url"`
	ContentsURL string `json:"contents_url"`
	Patch       string `json:"patch"`
}

type GitHubAPI

type GitHubAPI struct {
	// contains filtered or unexported fields
}

func NewGitHubAPI

func NewGitHubAPI() *GitHubAPI

func (*GitHubAPI) GetDefaultBranchName

func (gh *GitHubAPI) GetDefaultBranchName(owner, repo string, headers *Headers) (string, error)

func (*GitHubAPI) GetFileLatestCommit added in v0.0.5

func (gh *GitHubAPI) GetFileLatestCommit(owner, repo, branch, fullPath string, headers *Headers) ([]Commit, error)

Get latest commit data of path/file

func (*GitHubAPI) GetLatestCommit added in v0.0.5

func (gh *GitHubAPI) GetLatestCommit(owner, repo, branch string, headers *Headers) (*Commit, error)

func (*GitHubAPI) GetRepoTree

func (gh *GitHubAPI) GetRepoTree(owner, repo, branch string, headers *Headers) (*Tree, error)

type Headers added in v0.0.5

type Headers struct {
	Token string
}

func (*Headers) ToMap added in v0.0.5

func (h *Headers) ToMap() map[string]string

ToMap convert headers to map[string]string

type IGitHubAPI

type IGitHubAPI interface {
	GetRepoTree(owner, repo, branch string, headers *Headers) (*Tree, error)
	GetDefaultBranchName(owner, repo string, headers *Headers) (string, error)
	GetLatestCommit(owner, repo, branch string, headers *Headers) (*Commit, error)
}

type InnerTree

type InnerTree struct {
	Path string     `json:"path"`
	Mode string     `json:"mode"`
	SHA  string     `json:"sha"`
	URL  string     `json:"url"`
	Type ObjectType `json:"type"`
}

type MockGitHubAPI

type MockGitHubAPI struct {
}

func NewMockGitHubAPI

func NewMockGitHubAPI() *MockGitHubAPI

func (MockGitHubAPI) GetDefaultBranchName

func (gh MockGitHubAPI) GetDefaultBranchName(owner, repo string, headers *Headers) (string, error)

func (MockGitHubAPI) GetLatestCommit added in v0.0.5

func (gh MockGitHubAPI) GetLatestCommit(owner, repo, branch string, headers *Headers) (*Commit, error)

func (*MockGitHubAPI) GetRepoTree

func (gh *MockGitHubAPI) GetRepoTree(owner, repo, branch string, headers *Headers) (*Tree, error)

type ObjectType

type ObjectType string
const (
	ObjectTypeDir  ObjectType = "tree"
	ObjectTypeFile ObjectType = "blob"
)

type Tree

type Tree struct {
	InnerTrees []InnerTree `json:"tree"`
	SHA        string      `json:"sha"`
	URL        string      `json:"url"`
	Truncated  bool        `json:"truncated"`
}

func (*Tree) ListAll

func (t *Tree) ListAll() []string

ListAll list all file/dir in repo tree

func (*Tree) ListAllDirs

func (t *Tree) ListAllDirs() []string

ListAllDirs list all directories in repo tree

func (*Tree) ListAllFiles

func (t *Tree) ListAllFiles() []string

ListAllFiles list all files in repo tree

Jump to

Keyboard shortcuts

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