mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-07-20 00:12:19 +00:00
Add a -version flag.
This commit is contained in:
@@ -2,6 +2,27 @@
|
||||
|
||||
package main
|
||||
|
||||
import gitpages "codeberg.org/git-pages/git-pages/src"
|
||||
import (
|
||||
"runtime/debug"
|
||||
|
||||
func main() { gitpages.Main() }
|
||||
git_pages "codeberg.org/git-pages/git-pages/src"
|
||||
)
|
||||
|
||||
// By default the version information is retrieved from VCS. If not available during build,
|
||||
// override this variable using linker flags to change the displayed version.
|
||||
// Example: `-ldflags "-X main.versionOverride=v1.2.3"`
|
||||
var versionOverride = ""
|
||||
|
||||
func extractVersion() string {
|
||||
if versionOverride != "" {
|
||||
return versionOverride
|
||||
} else if buildInfo, ok := debug.ReadBuildInfo(); ok {
|
||||
return buildInfo.Main.Version
|
||||
} else {
|
||||
panic("version information not available")
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
git_pages.Main(extractVersion())
|
||||
}
|
||||
|
||||
+9
-2
@@ -178,7 +178,7 @@ func usage() {
|
||||
fmt.Fprintf(os.Stderr, "(server) "+
|
||||
"git-pages [-config <file>|-no-config]\n")
|
||||
fmt.Fprintf(os.Stderr, "(info) "+
|
||||
"git-pages {-print-config-env-vars|-print-config}\n")
|
||||
"git-pages {-version|-print-config-env-vars|-print-config}\n")
|
||||
fmt.Fprintf(os.Stderr, "(debug) "+
|
||||
"git-pages {-list-blobs|-list-manifests}\n")
|
||||
fmt.Fprintf(os.Stderr, "(debug) "+
|
||||
@@ -192,7 +192,7 @@ func usage() {
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
func Main() {
|
||||
func Main(versionInfo string) {
|
||||
ctx := context.Background()
|
||||
|
||||
flag.Usage = usage
|
||||
@@ -232,8 +232,15 @@ func Main() {
|
||||
"run a store `migration` (one of: create-domain-markers)")
|
||||
traceGarbage := flag.Bool("trace-garbage", false,
|
||||
"estimate total size of unreachable blobs")
|
||||
version := flag.Bool("version", false,
|
||||
"display version")
|
||||
flag.Parse()
|
||||
|
||||
if *version {
|
||||
fmt.Printf("git-pages %s\n", versionInfo)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
var cliOperations int
|
||||
for _, selected := range []bool{
|
||||
*listBlobs,
|
||||
|
||||
Reference in New Issue
Block a user