refactor: remove stamp information from tools (#537)
This commit is contained in:
parent
62394fbb68
commit
04e1c3c473
|
@ -1,24 +1,11 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
# Under --stamp, the Go linker will fill in these placeholders with VCS info
|
||||
# see https://github.com/bazelbuild/rules_go/blob/master/go/core.rst#stamping-with-the-workspace-status-script
|
||||
_GO_STAMP_X_DEFS = {
|
||||
"BuildTime": "{BUILD_TIMESTAMP}",
|
||||
"GitCommit": "{STABLE_BUILD_SCM_SHA}",
|
||||
"GitStatus": "{STABLE_BUILD_SCM_LOCAL_CHANGES}",
|
||||
"HostName": "{BUILD_HOST}",
|
||||
"Release": "{STABLE_BUILD_SCM_TAG}",
|
||||
}
|
||||
|
||||
go_library(
|
||||
name = "common",
|
||||
srcs = [
|
||||
"copy.go",
|
||||
"file.go",
|
||||
"stamp.go",
|
||||
"version.go",
|
||||
],
|
||||
importpath = "github.com/aspect-build/bazel-lib/tools/common",
|
||||
visibility = ["//visibility:public"],
|
||||
x_defs = _GO_STAMP_X_DEFS,
|
||||
)
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
// Variables in this file will be replaced by the linker when Bazel is run with --stamp
|
||||
// The time should be in format '2018-12-12 12:30:00 UTC'
|
||||
// The GitStatus should be either "clean" or "dirty"
|
||||
// Release will be a comma-separated string representation of any tags.
|
||||
|
||||
package common
|
||||
|
||||
// BuildTime is a string representation of when this binary was built.
|
||||
var BuildTime = "an unknown time"
|
||||
|
||||
// GitCommit is the revision this binary was built from.
|
||||
var GitCommit = "an unknown revision"
|
||||
|
||||
// GitStatus is whether the git workspace was clean.
|
||||
var GitStatus = "unknown"
|
||||
|
||||
// HostName is the machine where this binary was built.
|
||||
var HostName = "an unknown machine"
|
||||
|
||||
// Release is the revision number, if any.
|
||||
var Release = "no release"
|
||||
|
||||
func IsStamped() bool {
|
||||
return BuildTime != "{BUILD_TIMESTAMP}"
|
||||
}
|
||||
|
||||
const (
|
||||
// Git status
|
||||
CleanGitStatus = "clean"
|
||||
|
||||
// Release values
|
||||
PreStampRelease = "no release"
|
||||
|
||||
// Version constants
|
||||
NotCleanVersionSuffix = " (with local changes)"
|
||||
NoReleaseVersion = "unknown [not built with --stamp]"
|
||||
)
|
|
@ -1,16 +0,0 @@
|
|||
package common
|
||||
|
||||
import "strings"
|
||||
|
||||
func Version() string {
|
||||
var versionBuilder strings.Builder
|
||||
if Release != "" && Release != PreStampRelease {
|
||||
versionBuilder.WriteString(Release)
|
||||
if GitStatus != CleanGitStatus {
|
||||
versionBuilder.WriteString(NotCleanVersionSuffix)
|
||||
}
|
||||
} else {
|
||||
versionBuilder.WriteString(NoReleaseVersion)
|
||||
}
|
||||
return versionBuilder.String()
|
||||
}
|
|
@ -79,13 +79,6 @@ func (w *walker) copyDir(src string, dst string) error {
|
|||
func main() {
|
||||
args := os.Args[1:]
|
||||
|
||||
if len(args) == 1 {
|
||||
if args[0] == "--version" || args[0] == "-v" {
|
||||
fmt.Printf("copy_directory %s\n", common.Version())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
fmt.Println("Usage: copy_directory src dst [--hardlink] [--verbose]")
|
||||
os.Exit(1)
|
||||
|
|
|
@ -373,13 +373,6 @@ func (w *walker) copyPaths(cfg *config) error {
|
|||
func main() {
|
||||
args := os.Args[1:]
|
||||
|
||||
if len(args) == 1 {
|
||||
if args[0] == "--version" || args[0] == "-v" {
|
||||
fmt.Printf("copy_to_directory %s\n", common.Version())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if len(args) != 1 && len(args) != 2 {
|
||||
fmt.Println("Usage: copy_to_directory config_file [workspace_name]")
|
||||
os.Exit(1)
|
||||
|
|
|
@ -8,20 +8,12 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/aspect-build/bazel-lib/tools/common"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
func main() {
|
||||
args := os.Args[1:]
|
||||
|
||||
if len(args) == 1 {
|
||||
if args[0] == "--version" || args[0] == "-v" {
|
||||
fmt.Printf("expand_template %s\n", common.Version())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if len(args) != 6 {
|
||||
fmt.Println("Usage: expand_template <template> <out> <substitutions_json> <volatile_status_file> <stable_status_file> <executable>")
|
||||
os.Exit(1)
|
||||
|
|
Loading…
Reference in New Issue