GetBranch retrieves the current HEADs name
(localPath string)
| 19 | |
| 20 | // GetBranch retrieves the current HEADs name |
| 21 | func GetBranch(localPath string) (string, error) { |
| 22 | repo, err := git.PlainOpen(localPath) |
| 23 | if err != nil { |
| 24 | return "", errors.Wrap(err, "git open") |
| 25 | } |
| 26 | |
| 27 | head, err := repo.Head() |
| 28 | if err != nil { |
| 29 | return "", errors.Wrap(err, "get head") |
| 30 | } |
| 31 | |
| 32 | return head.Name().Short(), nil |
| 33 | } |
| 34 | |
| 35 | // GetHash retrieves the current HEADs hash |
| 36 | func GetHash(ctx context.Context, localPath string) (string, error) { |
no test coverage detected