GetRepoUrl get git repo origin URL.
(repoDir string)
| 14 | |
| 15 | // GetRepoUrl get git repo origin URL. |
| 16 | func GetRepoUrl(repoDir string) (string, error) { |
| 17 | cmd := exec.Command("git", "-C", repoDir, "remote", "get-url", "origin") |
| 18 | output, err := cmd.CombinedOutput() |
| 19 | if err != nil { |
| 20 | return "", fmt.Errorf("get repo url -> %s", output) |
| 21 | } |
| 22 | return strings.TrimSpace(string(output)), nil |
| 23 | } |
| 24 | |
| 25 | // GetCurrentBranch read current branch of repo. |
| 26 | func GetCurrentBranch(repoDir string) (string, error) { |