本文整理匯總了Golang中github.com/openshift/source-to-image/pkg/scm/git.Git.Checkout方法的典型用法代碼示例。如果您正苦於以下問題:Golang Git.Checkout方法的具體用法?Golang Git.Checkout怎麽用?Golang Git.Checkout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/openshift/source-to-image/pkg/scm/git.Git
的用法示例。
在下文中一共展示了Git.Checkout方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: extractGitSource
func extractGitSource(git git.Git, gitSource *api.GitBuildSource, revision *api.SourceRevision, dir string, timeout time.Duration) (bool, error) {
if gitSource == nil {
return false, nil
}
// Set the HTTP and HTTPS proxies to be used by git clone.
originalProxies := setHTTPProxy(gitSource.HTTPProxy, gitSource.HTTPSProxy)
defer resetHTTPProxy(originalProxies)
// Check source URI, trying to connect to the server only if not using a proxy.
if err := checkSourceURI(git, gitSource.URI, timeout); err != nil {
return true, err
}
glog.V(2).Infof("Cloning source from %s", gitSource.URI)
if err := git.Clone(gitSource.URI, dir, s2iapi.CloneConfig{Recursive: true, Quiet: true}); err != nil {
return true, err
}
// if we specify a commit, ref, or branch to checkout, do so
if len(gitSource.Ref) != 0 || (revision != nil && revision.Git != nil && len(revision.Git.Commit) != 0) {
commit := gitSource.Ref
if revision != nil && revision.Git != nil && revision.Git.Commit != "" {
commit = revision.Git.Commit
}
if err := git.Checkout(dir, commit); err != nil {
return true, err
}
}
return true, nil
}