diff --git a/git.go b/git.go index ea06aec..f4f74e8 100644 --- a/git.go +++ b/git.go @@ -10,7 +10,7 @@ import ( "time" ) -const _VERSION = "0.3.4" +const _VERSION = "0.3.5" func Version() string { return _VERSION diff --git a/repo.go b/repo.go index 4bec04f..f9ec8b5 100644 --- a/repo.go +++ b/repo.go @@ -43,6 +43,15 @@ func (repo *Repository) parsePrettyFormatLogToList(logs []byte) (*list.List, err return l, nil } +// IsRepoURLAccessible checks if given repository URL is accessible. +func IsRepoURLAccessible(url string) bool { + _, err := NewCommand("ls-remote", "-q", "-h", url, "HEAD").Run() + if err != nil { + return false + } + return true +} + // InitRepository initializes a new Git repository. func InitRepository(repoPath string, bare bool) error { os.MkdirAll(repoPath, os.ModePerm) @@ -141,9 +150,9 @@ func Push(repoPath, remote, branch string) error { } type CheckoutOptions struct { - Branch string + Branch string OldBranch string - Timeout time.Duration + Timeout time.Duration } // Checkout checkouts a branch