Added function to get commit as string

This commit is contained in:
David Allen 2024-06-26 13:39:27 -06:00
parent cda5e71584
commit 30c8336ca6
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC

View file

@ -7,6 +7,8 @@ import (
"io"
"net/http"
"os"
"os/exec"
"strings"
)
func PathExists(path string) (bool, error) {
@ -49,3 +51,13 @@ func ConvertMapOutput(m map[string][]byte) map[string]string {
}
return n
}
func GitCommit() string {
c := exec.Command("git", "rev-parse", "HEAD")
stdout, err := c.Output()
if err != nil {
return ""
}
return strings.TrimRight(string(stdout), "\n")
}