mirror of
https://github.com/minio/mc.git
synced 2026-01-04 02:44:40 +03:00
Add more elaborate tag this time in [STRING-EPOCH-GITREV] format
This commit is contained in:
1
main.go
1
main.go
@@ -74,6 +74,7 @@ func getSystemData() map[string]string {
|
||||
"PLATFORM": platform,
|
||||
"RUNTIME": goruntime,
|
||||
"MEM": mem,
|
||||
"TAG": Tag,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
38
make.go
38
make.go
@@ -23,6 +23,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
@@ -30,14 +32,10 @@ import (
|
||||
)
|
||||
|
||||
type Version struct {
|
||||
Date string
|
||||
TagDate string
|
||||
Date string
|
||||
Tag string
|
||||
}
|
||||
|
||||
const (
|
||||
tagTimeStampFormat = "2006.01.02-MST"
|
||||
)
|
||||
|
||||
func writeVersion(version Version) error {
|
||||
var versionTemplate = `// -------- DO NOT EDIT --------
|
||||
// this is an autogenerated file
|
||||
@@ -51,7 +49,15 @@ import (
|
||||
|
||||
// Version autogenerated
|
||||
var Version = {{if .Date}}"{{.Date}}"{{else}}""{{end}}
|
||||
var TagVersion = {{if .TagDate}}"{{.TagDate}}"{{else}}""{{end}}
|
||||
|
||||
// Tag is of following format
|
||||
//
|
||||
// [[STRING]-[EPOCH]-[GITREV]]
|
||||
//
|
||||
// STRING is release string of your choice.
|
||||
// EPOCH is unix seconds since Jan 1, 1970 UTC.
|
||||
// GITREV is git commit id
|
||||
var Tag = {{if .Tag}}"{{.Tag}}"{{else}}""{{end}}
|
||||
|
||||
// getVersion -
|
||||
func getVersion() string {
|
||||
@@ -123,10 +129,24 @@ func runMcRelease(ctx *cli.Context) {
|
||||
if ctx.Args().First() == "help" {
|
||||
cli.ShowCommandHelpAndExit(ctx, "release", 1) // last argument is exit code
|
||||
}
|
||||
git := command{exec.Command("git", "rev-parse", "--short", "HEAD"), &bytes.Buffer{}, &bytes.Buffer{}}
|
||||
gitErr := git.runCommand()
|
||||
if gitErr != nil {
|
||||
fmt.Print(git)
|
||||
os.Exit(1)
|
||||
}
|
||||
revParse := git.stdout.String()
|
||||
t := time.Now().UTC()
|
||||
date := t.Format(time.RFC3339Nano)
|
||||
tagDate := t.Format(tagTimeStampFormat)
|
||||
version := Version{Date: date, TagDate: tagDate}
|
||||
|
||||
// [[STRING]-[EPOCH]-[GITREV]]
|
||||
//
|
||||
// STRING is release string of your choice.
|
||||
// EPOCH is unix seconds since Jan 1, 1970 UTC.
|
||||
// GITREV is git commit id
|
||||
tag := "release" + "-" + strconv.FormatInt(t.Unix(), 10) + "-" + strings.TrimSpace(revParse)
|
||||
|
||||
version := Version{Date: date, Tag: tag}
|
||||
err := writeVersion(version)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
|
||||
11
version.go
11
version.go
@@ -9,7 +9,16 @@ import (
|
||||
)
|
||||
|
||||
// Version autogenerated
|
||||
var Version = "2015-06-12T02:05:16.449416257Z"
|
||||
var Version = "2015-06-17T01:27:27.033965323Z"
|
||||
|
||||
// Tag is of following format
|
||||
//
|
||||
// [[STRING]-[EPOCH]-[GITREV]]
|
||||
//
|
||||
// STRING is release string of your choice.
|
||||
// EPOCH is unix seconds since Jan 1, 1970 UTC.
|
||||
// GITREV is git commit id
|
||||
var Tag = "release-1434504447-bb790ed"
|
||||
|
||||
// getVersion -
|
||||
func getVersion() string {
|
||||
|
||||
Reference in New Issue
Block a user