github.com/sagernet/sing-box@v1.2.7/cmd/internal/build_shared/tag.go (about)

     1  package build_shared
     2  
     3  import "github.com/sagernet/sing/common/shell"
     4  
     5  func ReadTag() (string, error) {
     6  	currentTag, err := shell.Exec("git", "describe", "--tags").ReadOutput()
     7  	if err != nil {
     8  		return currentTag, err
     9  	}
    10  	currentTagRev, _ := shell.Exec("git", "describe", "--tags", "--abbrev=0").ReadOutput()
    11  	if currentTagRev == currentTag {
    12  		return currentTag[1:], nil
    13  	}
    14  	shortCommit, _ := shell.Exec("git", "rev-parse", "--short", "HEAD").ReadOutput()
    15  	return currentTagRev[1:] + "-" + shortCommit, nil
    16  }