AppRunner: Include commit message in the status
Change-Id: I1c9101df71e004888b0fc38cbc351d77fbcc70bd
diff --git a/apps/app-runner/main.go b/apps/app-runner/main.go
index b9acaa6..96a647e 100644
--- a/apps/app-runner/main.go
+++ b/apps/app-runner/main.go
@@ -35,7 +35,12 @@
Env []string `json:"env"`
}
-func CloneRepositoryBranch(addr, branch, rootDir string, signer ssh.Signer, path string) (string, error) {
+type Commit struct {
+ Hash string `json:"hash"`
+ Message string `json:"message"`
+}
+
+func CloneRepositoryBranch(addr, branch, rootDir string, signer ssh.Signer, path string) (*Commit, error) {
ref := fmt.Sprintf("refs/heads/%s", branch)
opts := &git.CloneOptions{
URL: addr,
@@ -59,15 +64,22 @@
},
}
}
- c, err := git.Clone(memory.NewStorage(), osfs.New(path, osfs.WithBoundOS()), opts)
+ repo, err := git.Clone(memory.NewStorage(), osfs.New(path, osfs.WithBoundOS()), opts)
if err != nil {
- return "", err
+ return nil, err
}
- head, err := c.Head()
+ head, err := repo.Head()
if err != nil {
- return "", err
+ return nil, err
}
- return head.Hash().String(), nil
+ commit, err := repo.CommitObject(head.Hash())
+ if err != nil {
+ return nil, err
+ }
+ return &Commit{
+ Hash: head.Hash().String(),
+ Message: commit.Message,
+ }, nil
}
func main() {