warn instead of exiting when it is not possible to get version from git (#3857)

This commit is contained in:
Alessandro Ros 2024-10-09 21:57:05 +02:00 committed by GitHub
parent 737ab9d59a
commit f231837591
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 3 deletions

View File

@ -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 {