Skip to content

Commit

Permalink
warn instead of exiting when it is not possible to get version from git
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Oct 9, 2024
1 parent 737ab9d commit 727b508
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions internal/core/versiongetter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +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.
//
Expand Down Expand Up @@ -115,6 +114,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 {
Expand Down

0 comments on commit 727b508

Please sign in to comment.