Skip to content

Commit

Permalink
Add version (#1)
Browse files Browse the repository at this point in the history
* add version information
  • Loading branch information
sjeandeaux committed Sep 21, 2017
1 parent 4e618c6 commit fe127dd
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ FROM golang:1.9
WORKDIR /go/src/github.com/sjeandeaux/nexus-cli
COPY . .

RUN go-wrapper download # "go get -d -v ./..."
RUN go-wrapper install # "go install -v ./..."
RUN go-wrapper download
RUN go-wrapper install -ldflags " \
-X github.com/sjeandeaux/nexus-cli/information.Version=$(cat VERSION) \
-X github.com/sjeandeaux/nexus-cli/information.BuildTime=$(date +"%Y-%m-%dT%H:%M:%S") \
-X github.com/sjeandeaux/nexus-cli/information.GitCommit=$(git rev-parse --short HEAD) \
-X github.com/sjeandeaux/nexus-cli/information.GitDescribe=$(git describe --tags --always) \
-X github.com/sjeandeaux/nexus-cli/information.GitDirty=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)"

ENTRYPOINT ["go-wrapper" , "run"]
ENTRYPOINT ["go-wrapper", "run"]
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3.0
17 changes: 17 additions & 0 deletions information/information.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package information

import "fmt"

//We use ldflags
var (
Version = "No Version Provided"
GitCommit = "No GitCommit Provided"
GitDescribe = "No GitDescribe Provided"
GitDirty = "No GitDirty Provided"
BuildTime = "No BuildTime Provided"
)


func Print() string {
return fmt.Sprintf("%q-%q-%q-%q-%q", Version, BuildTime, GitCommit, GitDescribe, GitDirty)
}
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/sjeandeaux/nexus-cli/repositorymanager"

"os"
"github.com/sjeandeaux/nexus-cli/information"
)

type enableHash []string
Expand Down Expand Up @@ -58,7 +59,7 @@ func init() {

//main upload artifact
func main() {

log.Logger.Println(information.Print())
repo := repositorymanager.NewRepository(commandLine.urlOfRepository, commandLine.user, commandLine.password)

artifact, err := repositorymanager.NewArtifact(commandLine.groupID, commandLine.artifactID, commandLine.version, commandLine.file)
Expand Down
5 changes: 3 additions & 2 deletions repositorymanager/repositorymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/sjeandeaux/nexus-cli/log"

"errors"
"github.com/sjeandeaux/nexus-cli/information"
)

const (
Expand Down Expand Up @@ -107,10 +108,10 @@ func generateURLIssue(h string) string {
const (
title = "Move your ass"
urlFormat = "https://github.com/sjeandeaux/nexus-cli/issues/new?title=%s&body=%s"
bodyFormat = "Could you add the hash %q lazy man?"
bodyFormat = "Could you add the hash %q lazy man?\n%s"
)
escapedTitle := url.QueryEscape(title)
body := fmt.Sprintf(bodyFormat, h)
body := fmt.Sprintf(bodyFormat, h, information.Print())
escapedBody := url.QueryEscape(body)
urlIssue := fmt.Sprintf(urlFormat, escapedTitle, escapedBody)
return urlIssue
Expand Down

0 comments on commit fe127dd

Please sign in to comment.