Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2016-04-08 15:56:47 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2016-04-08 15:56:47 +0300
commitcdc785b6b65e8cb811c9ea67616381ad95285745 (patch)
tree85bffe7b07eac8dea730b8e46eb97ef7efe12b30
parentb0ac2a7d3f7c48702120de4910cde34b7aee7bdd (diff)
parentc76f6213d42efb310c4af4db0ec74de5cbdbd95c (diff)
Merge branch 'add_show_version' into 'master' v0.2.3
Add version flag. It is handy to have only the version with revision printed out. Also useful for gitlab-org/omnibus-gitlab#1213 See merge request !5
-rw-r--r--404.go2
-rw-r--r--Makefile3
-rw-r--r--domain_test.go6
-rw-r--r--main.go14
4 files changed, 18 insertions, 7 deletions
diff --git a/404.go b/404.go
index 3634ddf0..5bcced47 100644
--- a/404.go
+++ b/404.go
@@ -1,8 +1,8 @@
package main
import (
- "net/http"
"fmt"
+ "net/http"
)
const predefined404 = `
diff --git a/Makefile b/Makefile
index 97852062..a4a9bee0 100644
--- a/Makefile
+++ b/Makefile
@@ -27,8 +27,7 @@ fmt:
go fmt ./... | awk '{ print "Please run go fmt"; exit 1 }'
vet:
- go get golang.org/x/tools/cmd/vet
- go vet
+ go tool vet *.go
lint:
go get github.com/golang/lint/golint
diff --git a/domain_test.go b/domain_test.go
index 56e032a4..f10009c3 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -2,12 +2,12 @@ package main
import (
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+ "mime"
"net/http"
+ "net/http/httptest"
"net/url"
"testing"
- "net/http/httptest"
- "github.com/stretchr/testify/require"
- "mime"
)
func TestGroupServeHTTP(t *testing.T) {
diff --git a/main.go b/main.go
index 74e208bc..ba7a25db 100644
--- a/main.go
+++ b/main.go
@@ -15,6 +15,7 @@ var VERSION = "dev"
var REVISION = "HEAD"
func appMain() {
+ var showVersion = flag.Bool("version", false, "Show version")
var listenHTTP = flag.String("listen-http", "", "The address to listen for HTTP requests")
var listenHTTPS = flag.String("listen-https", "", "The address to listen for HTTPS requests")
var listenProxy = flag.String("listen-proxy", "", "The address to listen for proxy requests")
@@ -27,9 +28,12 @@ func appMain() {
var daemonUID = flag.Uint("daemon-uid", 0, "Drop privileges to this user")
var daemonGID = flag.Uint("daemon-gid", 0, "Drop privileges to this group")
+ flag.Parse()
+
+ printVersion(*showVersion, VERSION)
+
log.Printf("GitLab Pages Daemon %s (%s)", VERSION, REVISION)
log.Printf("URL: https://gitlab.com/gitlab-org/gitlab-pages\n")
- flag.Parse()
err := os.Chdir(*pagesRoot)
if err != nil {
@@ -75,6 +79,14 @@ func appMain() {
runApp(config)
}
+func printVersion(showVersion bool, version string) {
+ if showVersion {
+ log.SetFlags(0)
+ log.Printf(version)
+ os.Exit(0)
+ }
+}
+
func main() {
log.SetOutput(os.Stderr)