Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint committed Jan 24, 2025
1 parent 7bad9b6 commit 5f2d8d7
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions runtime/app/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
package app

import (
"fmt"
"os"
"os/exec"
"strings"
)
Expand Down Expand Up @@ -42,12 +40,22 @@ func ProductVersion() string {
}

func describeVersion() string {
result, err := exec.Command("git", "describe", "--tags", "--always", "--match", "runtime/*").Output()
if os.Getenv("GITHUB_ACTION") != "" {
fmt.Println("*** debug: describeVersion result:", string(result))
if isShallowGit() {
result, err := exec.Command("git", "rev-parse", "--short", "HEAD").Output()
if err != nil {
return "(unknown)"
}
return "v0.0.0-?-g" + strings.TrimSpace(string(result))
} else {
result, err := exec.Command("git", "describe", "--tags", "--always", "--match", "runtime/*").Output()
if err != nil {
return "(unknown)"
}
return strings.TrimPrefix(strings.TrimSpace(string(result)), "runtime/")
}
if err != nil {
return "(unknown)"
}
return strings.TrimPrefix(strings.TrimSpace(string(result)), "runtime/")
}

func isShallowGit() bool {
result, err := exec.Command("git", "rev-parse", "--is-shallow-repository").Output()
return err == nil && strings.TrimSpace(string(result)) == "true"
}

0 comments on commit 5f2d8d7

Please sign in to comment.