Documentation ¶
Index ¶
- func ErrNotFound(resource, name string) error
- func GitURL(repository *Repository, authType GitAuthType) string
- func RemoveDuplicates(strs []string) []string
- func ReposToMap(repos []*Repository) map[string]*Repository
- func StringListToMap(strs []string) map[string]string
- func StringsEqual(a, b *string) bool
- type GitAuthType
- type GitClient
- func NewGitAccessTokenClient(accessToken string, timeout time.Duration, debug bool) (*GitClient, error)
- func NewGitPrivateKeysClient(privateKeyFile, keyPassword string, timeout time.Duration, debug bool) (*GitClient, error)
- func NewGitUsernamePasswordClient(username, password string, timeout time.Duration, debug bool) (*GitClient, error)
- func (c *GitClient) Clone(url, path string) error
- func (c *GitClient) CloneOrFetch(url, remoteName, path string) (bool, error)
- func (c *GitClient) CloneOrPull(url, remoteName, path string) (bool, error)
- func (c *GitClient) CreateRemote(urls []string, remoteName, path string) error
- func (c *GitClient) DeleteBranch(branchName, path string, repo *git.Repository) error
- func (c *GitClient) DeleteRemote(remoteName, path string) error
- func (c *GitClient) Fetch(remoteName, path string) error
- func (c *GitClient) Mirror(remoteName, path string, force bool) error
- func (c *GitClient) Pull(remoteName, path string) error
- type GiteeAPI
- func (g *GiteeAPI) CreateOrgRepo(baseRepo *Repository, orgName string) (*Repository, error)
- func (g *GiteeAPI) CreateRepository(baseRepo *Repository, orgName string) (*Repository, error)
- func (g *GiteeAPI) CreateUserRepo(baseRepo *Repository) (*Repository, error)
- func (g *GiteeAPI) GetOrganization(orgName string) (*Organization, error)
- func (g *GiteeAPI) GetRepository(orgName, repoName string) (*Repository, error)
- func (g *GiteeAPI) IsAPIAuthed() bool
- func (g *GiteeAPI) Organizations(user string) ([]*Organization, error)
- func (g *GiteeAPI) Repositories(user string) ([]*Repository, error)
- func (g *GiteeAPI) RepositoriesByOrg(orgName string) ([]*Repository, error)
- func (g *GiteeAPI) UpdateRepository(orgName, repoName string, baseRepo *Repository) (*Repository, error)
- type GithubAPI
- func (g *GithubAPI) CreateRepository(baseRepo *Repository, orgName string) (*Repository, error)
- func (g *GithubAPI) GetOrganization(orgName string) (*Organization, error)
- func (g *GithubAPI) GetRepository(orgName, repoName string) (*Repository, error)
- func (g *GithubAPI) IsAPIAuthed() bool
- func (g *GithubAPI) Organizations(user string) ([]*Organization, error)
- func (g *GithubAPI) Repositories(user string) ([]*Repository, error)
- func (g *GithubAPI) RepositoriesByOrg(orgName string) ([]*Repository, error)
- func (g *GithubAPI) UpdateRepository(orgName, repoName string, baseRepo *Repository) (*Repository, error)
- type IGitAPI
- type IMirror
- type Mirror
- type Organization
- type Repository
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrNotFound ¶
func GitURL ¶
func GitURL(repository *Repository, authType GitAuthType) string
func RemoveDuplicates ¶
func ReposToMap ¶
func ReposToMap(repos []*Repository) map[string]*Repository
ReposToMap convert Repository List to map
func StringListToMap ¶
StringListToMap convert strings list to map
func StringsEqual ¶
StringsEqual compare two string point; if value equal return true; else false
Types ¶
type GitAuthType ¶
type GitAuthType int
const ( GitKeyAuth GitAuthType = iota GitAccessTokenAuth GitUsernamePasswordAuth )
type GitClient ¶
type GitClient struct { Timeout time.Duration GitAuthType GitAuthType // contains filtered or unexported fields }
func NewGitAccessTokenClient ¶
func NewGitAccessTokenClient(accessToken string, timeout time.Duration, debug bool) (*GitClient, error)
NewGitAccessTokenClient access_token auth
func NewGitPrivateKeysClient ¶
func NewGitPrivateKeysClient(privateKeyFile, keyPassword string, timeout time.Duration, debug bool) (*GitClient, error)
NewGitPrivateKeysClient ssh key auth
func NewGitUsernamePasswordClient ¶
func NewGitUsernamePasswordClient(username, password string, timeout time.Duration, debug bool) (*GitClient, error)
NewGitUsernamePasswordClient username password auth
func (*GitClient) CloneOrFetch ¶ added in v0.2.0
CloneOrFetch if path is not exist run git clone, else fetch
func (*GitClient) CloneOrPull ¶
CloneOrPull if path is not exist run git clone, else pull
func (*GitClient) CreateRemote ¶
CreateRemote create remote url eg. https://github.com/git-fixtures/basic.git
func (*GitClient) DeleteBranch ¶ added in v0.2.0
func (c *GitClient) DeleteBranch(branchName, path string, repo *git.Repository) error
DeleteBranch delete special branch
func (*GitClient) DeleteRemote ¶
DeleteRemote delete special remote
type GiteeAPI ¶
type GiteeAPI struct { Client *gitee.APIClient Context context.Context IsAuthed bool // contains filtered or unexported fields }
func NewGiteeAPI ¶
NewGiteeAPI return new Gitee API
func (*GiteeAPI) CreateOrgRepo ¶
func (g *GiteeAPI) CreateOrgRepo(baseRepo *Repository, orgName string) (*Repository, error)
CreateOrgRepo create a new org repository
func (*GiteeAPI) CreateRepository ¶
func (g *GiteeAPI) CreateRepository(baseRepo *Repository, orgName string) (*Repository, error)
CreateRepository create a new repository, if repo is already exist, just return it
func (*GiteeAPI) CreateUserRepo ¶
func (g *GiteeAPI) CreateUserRepo(baseRepo *Repository) (*Repository, error)
CreateUserRepo create a new user repository
func (*GiteeAPI) GetOrganization ¶
func (g *GiteeAPI) GetOrganization(orgName string) (*Organization, error)
func (*GiteeAPI) GetRepository ¶
func (g *GiteeAPI) GetRepository(orgName, repoName string) (*Repository, error)
GetRepository fetches a repository
func (*GiteeAPI) IsAPIAuthed ¶ added in v0.2.3
IsAPIAuthed return is the API auth, true or false
func (*GiteeAPI) Organizations ¶
func (g *GiteeAPI) Organizations(user string) ([]*Organization, error)
Organizations list all Organizations
func (*GiteeAPI) Repositories ¶
func (g *GiteeAPI) Repositories(user string) ([]*Repository, error)
Repositories list all repositories for the authenticated user
func (*GiteeAPI) RepositoriesByOrg ¶
func (g *GiteeAPI) RepositoriesByOrg(orgName string) ([]*Repository, error)
RepositoriesByOrg list repositories for special org
func (*GiteeAPI) UpdateRepository ¶
func (g *GiteeAPI) UpdateRepository(orgName, repoName string, baseRepo *Repository) (*Repository, error)
UpdateRepository updates a repository
type GithubAPI ¶
type GithubAPI struct { Client *github.Client Context context.Context IsAuthed bool // contains filtered or unexported fields }
func NewGithubAPI ¶
NewGithubAPI return new Github API
func (*GithubAPI) CreateRepository ¶
func (g *GithubAPI) CreateRepository(baseRepo *Repository, orgName string) (*Repository, error)
CreateRepository create a new repository, if repo is already exist, just return it
func (*GithubAPI) GetOrganization ¶
func (g *GithubAPI) GetOrganization(orgName string) (*Organization, error)
GetOrganization get an organization by name
func (*GithubAPI) GetRepository ¶
func (g *GithubAPI) GetRepository(orgName, repoName string) (*Repository, error)
GetRepository fetches a repository
func (*GithubAPI) IsAPIAuthed ¶ added in v0.2.3
IsAPIAuthed return is the API auth, true or false
func (*GithubAPI) Organizations ¶
func (g *GithubAPI) Organizations(user string) ([]*Organization, error)
Organizations list Organizations
func (*GithubAPI) Repositories ¶
func (g *GithubAPI) Repositories(user string) ([]*Repository, error)
Repositories list all repositories for the authenticated user, if user is empty show all repos support two method:
https://docs.github.com/en/rest/repos/repos#list-repositories-for-the-authenticated-user if user is empty https://docs.github.com/en/rest/repos/repos#list-repositories-for-a-user if user is special
func (*GithubAPI) RepositoriesByOrg ¶
func (g *GithubAPI) RepositoriesByOrg(orgName string) ([]*Repository, error)
RepositoriesByOrg list repositories for special org
func (*GithubAPI) UpdateRepository ¶
func (g *GithubAPI) UpdateRepository(orgName, repoName string, baseRepo *Repository) (*Repository, error)
UpdateRepository updates a repository
type IGitAPI ¶
type IGitAPI interface { IsAPIAuthed() bool Organizations(user string) ([]*Organization, error) GetOrganization(orgName string) (*Organization, error) Repositories(user string) ([]*Repository, error) GetRepository(orgName, repoName string) (*Repository, error) CreateRepository(baseRepo *Repository, orgName string) (*Repository, error) UpdateRepository(orgName, repoName string, baseRepo *Repository) (*Repository, error) RepositoriesByOrg(orgName string) ([]*Repository, error) }
type Mirror ¶
type Mirror struct { SrcGit string SrcOrg string DstGit string DstOrg string SrcAccountType string DstAccountType string CloneStyle string CachePath string BlackList []string WhiteList []string ForceUpdate bool Debug bool Timeout time.Duration Mappings map[string]string // contains filtered or unexported fields }
type Organization ¶
type Repository ¶
type Repository struct { Owner *User `json:"owner,omitempty"` Name *string `json:"name,omitempty"` FullName *string `json:"full_name,omitempty"` Description *string `json:"description,omitempty"` HTMLURL *string `json:"html_url,omitempty"` CloneURL *string `json:"clone_url,omitempty"` GitURL *string `json:"git_url,omitempty"` SSHURL *string `json:"ssh_url,omitempty"` Homepage *string `json:"homepage,omitempty"` Fork *bool `json:"fork,omitempty"` Organization *Organization `json:"organization,omitempty"` Topics []string `json:"topics,omitempty"` // Additional mutable fields when creating and editing a repository Private *bool `json:"private,omitempty"` Archived *bool `json:"archived,omitempty"` }
Repository represents a Common repository.