Browse Source

Expose current git commit

tags/v0.11.0-beta
Daniel Oaks 6 years ago
parent
commit
b1a73142b5
3 changed files with 18 additions and 0 deletions
  1. 2
    0
      .goreleaser.yml
  2. 3
    0
      irc/constants.go
  3. 13
    0
      oragono.go

+ 2
- 0
.goreleaser.yml View File

@@ -45,3 +45,5 @@ archive:
45 45
     - languages/*.md
46 46
 checksum:
47 47
   name_template: "{{ .ProjectName }}-{{ .Version }}-checksums.txt"
48
+git:
49
+  short_hash: true

+ 3
- 0
irc/constants.go View File

@@ -13,6 +13,9 @@ const (
13 13
 )
14 14
 
15 15
 var (
16
+	// Commit is the current git commit.
17
+	Commit = ""
18
+
16 19
 	// Ver is the full version of Oragono, used in responses to clients.
17 20
 	Ver = fmt.Sprintf("oragono-%s", SemVer)
18 21
 

+ 13
- 0
oragono.go View File

@@ -22,6 +22,8 @@ import (
22 22
 	"golang.org/x/crypto/ssh/terminal"
23 23
 )
24 24
 
25
+var commit = ""
26
+
25 27
 func main() {
26 28
 	version := irc.SemVer
27 29
 	usage := `oragono.
@@ -98,6 +100,17 @@ Options:
98 100
 		rand.Seed(time.Now().UTC().UnixNano())
99 101
 		if !arguments["--quiet"].(bool) {
100 102
 			logman.Info("startup", fmt.Sprintf("Oragono v%s starting", irc.SemVer))
103
+			if commit == "" {
104
+				logman.Debug("startup", fmt.Sprintf("Could not get current commit"))
105
+			} else {
106
+				logman.Info("startup", fmt.Sprintf("Running commit %s", commit))
107
+			}
108
+		}
109
+
110
+		// set current git commit
111
+		irc.Commit = commit
112
+		if commit != "" {
113
+			irc.Ver = fmt.Sprintf("%s-%s", irc.Ver, commit)
101 114
 		}
102 115
 
103 116
 		// profiling

Loading…
Cancel
Save