CheckIfRemoteBranch check if repoRef is a branch.
(target, repoUrl, repoRef string)
| 16 | |
| 17 | // CheckIfRemoteBranch check if repoRef is a branch. |
| 18 | func CheckIfRemoteBranch(target, repoUrl, repoRef string) (bool, error) { |
| 19 | title := fmt.Sprintf("[query remote branch: %s]", target) |
| 20 | output, err := cmd.NewExecutor(title, "git", "ls-remote", "--heads", repoUrl, repoRef). |
| 21 | WithRetry(retryMaxAttempts).ExecuteOutput() |
| 22 | if err != nil { |
| 23 | return false, fmt.Errorf("failed to query remote branch %s of %s -> %w", repoRef, repoUrl, err) |
| 24 | } |
| 25 | |
| 26 | return strings.TrimSpace(output) != "", nil |
| 27 | } |
| 28 | |
| 29 | // CheckIfRemoteTag check if repoRef is a tag. |
| 30 | func CheckIfRemoteTag(target, repoUrl, repoRef string) (bool, error) { |
no test coverage detected