Documentation
¶
Index ¶
- Constants
- Variables
- func FileExist(filename string) bool
- func ForkRepository(form *GitRepository, to *GitRepository) error
- func GitAuthWithBasic(account, password string) transport.AuthMethod
- func GitAuthWithDefaultPublicKeysFromFile(password string) transport.AuthMethod
- func GitAuthWithPublicKeysFromFile(pemFile, password string) transport.AuthMethod
- func MigrateRepository(form *GitRepository, to *GitRepository) error
- func MirrorPushRepository(form *GitRepository, to *GitRepository) error
- func SimpleForkRepository(hub IHub, repositoryURL string) error
- func SimpleMirrorPushRepository(formRepositoryURL, toRepositoryURL string, toHub IHub, ...) error
- type GitRepository
- func (r *GitRepository) Fork(dst *GitRepository) error
- func (r *GitRepository) GetLocalPath() string
- func (r *GitRepository) Mirror() error
- func (r *GitRepository) MirrorClone() error
- func (r *GitRepository) MirrorPush() error
- func (r *GitRepository) Open() error
- func (r *GitRepository) SetAuth(auth transport.AuthMethod) *GitRepository
- func (r *GitRepository) SetBasicAuth(account, password string)
- func (r *GitRepository) SetDefaultPublicKeys(password string)
- func (r *GitRepository) SetHub(hub IHub)
- func (r *GitRepository) SetPublicKeys(pemFile, password string)
- func (r *GitRepository) SetURL(repositoryURL string) error
- func (r *GitRepository) URL() string
- type IHub
Constants ¶
const ( VisibilityPrivate = "private" VisibilityInternal = "internal" VisibilityPublic = "public" )
Variables ¶
var (
ErrGitRepositorySetURL = errors.New("string interpretation failed")
)
Functions ¶
func ForkRepository ¶
func ForkRepository(form *GitRepository, to *GitRepository) error
ForkRepository gr := &gitmirror.GitRepository{} gr.SetHub(&githubm.Hub{Username: "username", Password: "ghp_**************"}) gr.SetURL("https://github.com/pkg6/gitmirror.git") gitmirror.ForkRepository(gr,nil)
func GitAuthWithBasic ¶
func GitAuthWithBasic(account, password string) transport.AuthMethod
func GitAuthWithDefaultPublicKeysFromFile ¶
func GitAuthWithDefaultPublicKeysFromFile(password string) transport.AuthMethod
func GitAuthWithPublicKeysFromFile ¶
func GitAuthWithPublicKeysFromFile(pemFile, password string) transport.AuthMethod
func MigrateRepository ¶
func MigrateRepository(form *GitRepository, to *GitRepository) error
func MirrorPushRepository ¶
func MirrorPushRepository(form *GitRepository, to *GitRepository) error
MirrorPushRepository form := &gitmirror.GitRepository{} form.SetURL("https://github.com/pkg6/gitmirror.git") h := &githubm.Hub{Username: "username", Password: "ghp_****************"} to := &gitmirror.GitRepository{} to.SetHub(h) to.SetBasicAuth("account", "ghp_****************") || to.SetDefaultPublicKeys("") to.SetURL("git@github.com:you/gitmirror.git") gitmirror.MirrorPushRepository(form, to)
func SimpleForkRepository ¶
func SimpleMirrorPushRepository ¶
func SimpleMirrorPushRepository(formRepositoryURL, toRepositoryURL string, toHub IHub, auth transport.AuthMethod) error
Types ¶
type GitRepository ¶
type GitRepository struct {
// IHub
Hub IHub
// pull push auth
Auth transport.AuthMethod
//true git@github.com:pkg6/gitmirror.git
//false https://github.com/pkg6/gitmirror.git
IsSSL bool
//exp:
//git@github.com:pkg6/git-mirror.git
//https://github.com/pkg6/gitmirror.git
RepositoryURL string
//exp: pkg6
OwnerOrOrg string
//exp:git-mirror
RepositoryName string
//Edit repository details->Description
Description string
//Edit repository details->Website
Homepage string
//private | internal |public
Visibility string
//exp: pwd/git-mirror
LocalPath string
// contains filtered or unexported fields
}
func (*GitRepository) Fork ¶
func (r *GitRepository) Fork(dst *GitRepository) error
func (*GitRepository) GetLocalPath ¶
func (r *GitRepository) GetLocalPath() string
func (*GitRepository) Mirror ¶
func (r *GitRepository) Mirror() error
Mirror git remote add mirror RepositoryURL git config --add remote.mirror.mirror true
func (*GitRepository) MirrorClone ¶
func (r *GitRepository) MirrorClone() error
MirrorClone git clone --mirror RepositoryURL LocalPath
func (*GitRepository) MirrorPush ¶
func (r *GitRepository) MirrorPush() error
MirrorPush git push --mirror
func (*GitRepository) SetAuth ¶
func (r *GitRepository) SetAuth(auth transport.AuthMethod) *GitRepository
func (*GitRepository) SetBasicAuth ¶
func (r *GitRepository) SetBasicAuth(account, password string)
func (*GitRepository) SetDefaultPublicKeys ¶
func (r *GitRepository) SetDefaultPublicKeys(password string)
func (*GitRepository) SetHub ¶
func (r *GitRepository) SetHub(hub IHub)
func (*GitRepository) SetPublicKeys ¶
func (r *GitRepository) SetPublicKeys(pemFile, password string)
func (*GitRepository) SetURL ¶
func (r *GitRepository) SetURL(repositoryURL string) error
func (*GitRepository) URL ¶
func (r *GitRepository) URL() string
type IHub ¶
type IHub interface {
SetAccount(account string)
SetPassword(password string)
Domain() string
RepositoryExist(repository *GitRepository) bool
RepositoryCreate(repository *GitRepository) error
RepositoryFork(form *GitRepository, to *GitRepository) error
}