Skip to content

Commit 1c99fe6

Browse files
committed
Build with commit info
1 parent 17c6523 commit 1c99fe6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ profanity.txt
77
# Local scripts
88
*.sh
99
*.bat
10+
!build.sh
1011

1112
# Logs
1213
logs

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go build -ldflags "-X main.version=$(git rev-parse --short HEAD)"

main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"errors"
5+
"fmt"
56
"io"
67
"net"
78
"net/rpc"
@@ -31,7 +32,8 @@ import (
3132
)
3233

3334
var (
34-
config = common.GetConfig()
35+
config = common.GetConfig()
36+
version string
3537
)
3638

3739
func main() {
@@ -44,6 +46,14 @@ func main() {
4446
noSignal := false
4547
noReload := false
4648

49+
for _, arg := range args {
50+
switch arg {
51+
case "--version", "-v":
52+
fmt.Printf("wfc-server commit %s\n", version)
53+
os.Exit(0)
54+
}
55+
}
56+
4757
if len(args) > 1 {
4858
for _, arg := range args[1:] {
4959
switch arg {

0 commit comments

Comments
 (0)