revParse returns the full commit hash for the given repo ref from local repo. The ref can be any valid git revision (branch, tag, HEAD, commit hash, etc.).
(repoDir, repoRef string)
| 401 | // revParse returns the full commit hash for the given repo ref from local repo. |
| 402 | // The ref can be any valid git revision (branch, tag, HEAD, commit hash, etc.). |
| 403 | func revParse(repoDir, repoRef string) (string, error) { |
| 404 | cmd := exec.Command("git", "-C", repoDir, "rev-parse", repoRef) |
| 405 | output, err := cmd.CombinedOutput() |
| 406 | if err != nil { |
| 407 | return "", fmt.Errorf("failed to git rev-parse %q -> %s", repoRef, output) |
| 408 | } |
| 409 | return strings.TrimSpace(string(output)), nil |
| 410 | } |
| 411 | |
| 412 | // fetchRemoteRef fetch a specific remote ref (branch, tag, or commit). |
| 413 | func fetchRemoteRef(nameVersion, repoDir, remoteName, refName string) error { |
no test coverage detected