[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [sandboxed-tor-browser/master] Include the git revision as a static asset, and display it as part of the `--version` output.



commit 77d6921cad4d5c0d1dbc2bbbbe0991779e9e7501
Author: Yawning Angel <yawning@xxxxxxxxxxxxxxx>
Date:   Sat Dec 17 19:26:51 2016 +0000

    Include the git revision as a static asset, and display it as part of the `--version` output.
    
    Exactly what it says on the tin, I'm going to use this to force updating
    certain config options.
---
 .gitignore                                      |  1 +
 Makefile                                        |  4 +++-
 src/cmd/sandboxed-tor-browser/internal/ui/ui.go | 11 ++++++++++-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 8fc2492..9334d77 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 bin/
 pkg/
+data/revision
 data/tbb_stub.so
 data/*.bpf
 src/cmd/sandboxed-tor-browser/internal/data/bindata.go
diff --git a/Makefile b/Makefile
index edbfa4c..67f6723 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 CC	:= gcc
-CFLAGS := -Os -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector --param ssp-buffer-size=1 -fPIC -Wall -Werror -Wextra -Wl,-z,relro,-z,now
+CFLAGS	:= -Os -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector --param ssp-buffer-size=1 -fPIC -Wall -Werror -Wextra -Wl,-z,relro,-z,now
 
 GTK3TAG := gtk_3_14
 
@@ -10,6 +10,7 @@ sandboxed-tor-browser: static-assets
 	mv ./bin/sandboxed-tor-browser-$(GTK3TAG) ./bin/sandboxed-tor-browser
 
 static-assets: go-bindata gen-seccomp tbb_stub
+	git rev-parse --short HEAD > data/revision
 	./bin/gen-seccomp -o ./data
 	./bin/go-bindata -nometadata -pkg data -prefix data -o ./src/cmd/sandboxed-tor-browser/internal/data/bindata.go data/...
 
@@ -24,6 +25,7 @@ gen-seccomp:
 
 clean:
 	rm -f ./src/cmd/sandboxed-tor-browser/internal/data/bindata.go
+	rm -f ./data/revision
 	rm -f ./data/tbb_stub.so
 	rm -f ./data/*.bpf
 	rm -Rf ./bin
diff --git a/src/cmd/sandboxed-tor-browser/internal/ui/ui.go b/src/cmd/sandboxed-tor-browser/internal/ui/ui.go
index 973024c..969d7c0 100644
--- a/src/cmd/sandboxed-tor-browser/internal/ui/ui.go
+++ b/src/cmd/sandboxed-tor-browser/internal/ui/ui.go
@@ -57,6 +57,9 @@ var (
 
 	// Version is the version of `sandboxed-tor-browser`.
 	Version string
+
+	// Revision is the git commit of `sandboxed-tor-browser`.
+	Revision string
 )
 
 const (
@@ -165,7 +168,7 @@ func (c *Common) Run() error {
 		}
 	}
 	if c.PrintVersion {
-		fmt.Printf("sandboxed-tor-browser %s\n", Version)
+		fmt.Printf("sandboxed-tor-browser %s (%s)\n", Version, Revision)
 		return nil // Skip the lock, because we will exit.
 	}
 
@@ -457,6 +460,12 @@ func init() {
 		Version = strings.TrimSpace(string(d))
 	}
 
+	if d, err := data.Asset("revision"); err != nil {
+		panic(err)
+	} else {
+		Revision = strings.TrimSpace(string(d))
+	}
+
 	// Fixup all the bridge lines to be well formed.
 	for _, bridges := range Bridges {
 		for i, v := range bridges {

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits