检查错误
(actualGitRepoUrl string, httpCode int)
| 106 | |
| 107 | // 检查错误 |
| 108 | func (g gitOperation) CheckError4RepositoryUrl(actualGitRepoUrl string, httpCode int) (err *GitRepoAccessError) { |
| 109 | if httpCode == 200 { |
| 110 | return |
| 111 | } |
| 112 | |
| 113 | uri, _ := url.Parse(actualGitRepoUrl) |
| 114 | hostName := strings.ToLower(uri.Hostname()) |
| 115 | if strings.Contains(hostName, "github.com") { // 如果是github,不存在或者私有都会返回是404 |
| 116 | if httpCode == 404 { |
| 117 | err = &GitRepoAccessError{GitRepoAccessStatus: GitRepoStatusEnum_Other} |
| 118 | } else { |
| 119 | err = &GitRepoAccessError{GitRepoAccessStatus: GitRepoStatusEnum_PrivateRepository} |
| 120 | } |
| 121 | } else if strings.Contains(hostName, "gitee.com") { |
| 122 | if httpCode == 404 { |
| 123 | err = &GitRepoAccessError{GitRepoAccessStatus: GitRepoStatusEnum_NotExists} |
| 124 | } else { |
| 125 | err = &GitRepoAccessError{GitRepoAccessStatus: GitRepoStatusEnum_PrivateRepository} |
| 126 | } |
| 127 | } else { |
| 128 | err = &GitRepoAccessError{GitRepoAccessStatus: GitRepoStatusEnum_Other} |
| 129 | } |
| 130 | |
| 131 | return |
| 132 | } |
| 133 | |
| 134 | // 使用git下载指定的文件 |
| 135 | func (g gitOperation) SparseCheckout(rootDir string, gitCloneUrl string, fileExpression string, branch string) ([]string, error) { |
no outgoing calls
no test coverage detected