From 1c5e399b3e3ba70f6a4d10878fb62af6447d7890 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Wed, 9 Oct 2024 21:47:01 +0200 Subject: [PATCH] warn instead of exiting when it is not possible to get version from git --- internal/core/versiongetter/main.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/internal/core/versiongetter/main.go b/internal/core/versiongetter/main.go index dfa85a7324f..016ef3103ba 100644 --- a/internal/core/versiongetter/main.go +++ b/internal/core/versiongetter/main.go @@ -69,9 +69,7 @@ func gitDescribeTags(repo *git.Repository) (string, error) { } } -func do() error { - log.Println("getting mediamtx version...") - +func tagFromGit() error { // [git.PlainOpen] uses a ChrootOS that limits filesystem access to the .git directory only. // // Unfortunately, this can cause issues with package build environments such as Arch Linux's, @@ -115,6 +113,21 @@ func do() error { return nil } +func do() error { + log.Println("getting mediamtx version...") + + err := tagFromGit() + if err != nil { + log.Println("WARN: cannot get tag from .git folder, using v0.0.0 as version") + err = os.WriteFile("VERSION", []byte("v0.0.0"), 0o644) + if err != nil { + return fmt.Errorf("failed to write version file: %w", err) + } + } + + return nil +} + func main() { err := do() if err != nil {