githubapi

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 4 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 APIDefaultBranch

func APIDefaultBranch(owner, repo string) string

func APIRaw

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

func APIRepoTree

func APIRepoTree(owner, repo, branch string) string

Types

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, headres *Headres) (string, error)

func (*GitHubAPI) GetRepoTree

func (gh *GitHubAPI) GetRepoTree(owner, repo, branch string, headres *Headres) (*Tree, error)

type Headres

type Headres struct {
	Token string
}

func (*Headres) ToMap

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

ToMap convert headser to map[string]string

type IGitHubAPI

type IGitHubAPI interface {
	GetRepoTree(owner, repo, branch string, headres *Headres) (*Tree, error)
	GetDefaultBranchName(owner, repo string, headres *Headres) (string, 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, headres *Headres) (string, error)

func (*MockGitHubAPI) GetRepoTree

func (gh *MockGitHubAPI) GetRepoTree(owner, repo, branch string, headres *Headres) (*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