1
0
mirror of https://github.com/strongdm/comply synced 2025-12-06 06:14:09 +00:00

chore: migrate to go modules

This commit is contained in:
Carlos C
2019-07-14 13:51:10 -03:00
parent 87e8266f1b
commit c303b68201
125 changed files with 7334 additions and 2443 deletions

24
vendor/github.com/Clever/gitsem/.drone.yml generated vendored Normal file
View File

@@ -0,0 +1,24 @@
image: bradrydzewski/go:1.3
script:
- make test
notify:
email:
recipients:
- drone@clever.com
hipchat:
room: Clever-Dev-CI
token: {{hipchat_token}}
on_started: true
on_success: true
on_failure: true
publish:
github:
branch: master
script:
- make release
artifacts:
- release
tag: v$(cat VERSION)
token: {{github_token}}
user: Clever
repo: gitsem

25
vendor/github.com/Clever/gitsem/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,25 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
gitsem

54
vendor/github.com/Clever/gitsem/Makefile generated vendored Normal file
View File

@@ -0,0 +1,54 @@
SHELL := /bin/bash
PKG = github.com/Clever/gitsem
PKGS = $(PKG)
VERSION := $(shell cat VERSION)
EXECUTABLE := gitsem
BUILDS := \
build/$(EXECUTABLE)-v$(VERSION)-darwin-amd64 \
build/$(EXECUTABLE)-v$(VERSION)-linux-amd64 \
build/$(EXECUTABLE)-v$(VERSION)-windows-amd64
COMPRESSED_BUILDS := $(BUILDS:%=%.tar.gz)
RELEASE_ARTIFACTS := $(COMPRESSED_BUILDS:build/%=release/%)
.PHONY: test golint
golint:
@go get github.com/golang/lint/golint
test: $(PKGS)
$(PKGS): golint
@go get -d -t $@
@gofmt -w=true $(GOPATH)/src/$@*/**.go
ifneq ($(NOLINT),1)
@echo "LINTING..."
@PATH=$(PATH):$(GOPATH)/bin golint $(GOPATH)/src/$@*/**.go
@echo ""
endif
ifeq ($(COVERAGE),1)
@go test -cover -coverprofile=$(GOPATH)/src/$@/c.out $@ -test.v
@go tool cover -html=$(GOPATH)/src/$@/c.out
else
@echo "TESTING..."
@go test $@ -test.v
endif
run:
@go run main.go
build/$(EXECUTABLE)-v$(VERSION)-darwin-amd64:
GOARCH=amd64 GOOS=darwin go build -o "$@/$(EXECUTABLE)"
build/$(EXECUTABLE)-v$(VERSION)-linux-amd64:
GOARCH=amd64 GOOS=linux go build -o "$@/$(EXECUTABLE)"
build/$(EXECUTABLE)-v$(VERSION)-windows-amd64:
GOARCH=amd64 GOOS=windows go build -o "$@/$(EXECUTABLE).exe"
build: $(BUILDS)
%.tar.gz: %
tar -C `dirname $<` -zcvf "$<.tar.gz" `basename $<`
$(RELEASE_ARTIFACTS): release/% : build/%
mkdir -p release
cp $< $@
release: $(RELEASE_ARTIFACTS)
clean:
rm -rf build release

34
vendor/github.com/Clever/gitsem/README.md generated vendored Normal file
View File

@@ -0,0 +1,34 @@
# gitsem
A command line utility for managing semantically versioned (semver) git tags.
Run this in a git repository to bump the version and write the new data back to the VERSION file.
It will also create a version commit and (optional) tag, and fail if the repo is not clean.
## Installation
```shell
$ go get github.com/Clever/gitsem
```
## Example
```shell
$ gitsem patch
$ gitsem -m "Upgrade to %s for reasons" patch
$ gitsem minor
```
## Usage
```shell
gitsem [options] version
```
`version` can be one of: `newversion | patch | minor | major`
The version argument should be a valid semver string, or a field of a semver string (one of "patch", "minor", or "major").
In the second case, the existing version will be incremented by 1 in the specified field.
### Options
- `m=%s` specifies a commit message to use when bumping the version. If %s appears, it will be replaced with the new version number.
- `tag=true` whether or not to create a tag at the version commit

1
vendor/github.com/Clever/gitsem/VERSION generated vendored Normal file
View File

@@ -0,0 +1 @@
1.0.4

39
vendor/github.com/Clever/gitsem/git.go generated vendored Normal file
View File

@@ -0,0 +1,39 @@
package main
import (
"bytes"
"os/exec"
"strings"
)
func isRepoClean() (bool, error) {
cmd := exec.Command("git", "status", "-s")
result := &bytes.Buffer{}
cmd.Stdout = result
if err := cmd.Run(); err != nil {
return false, err
}
return result.String() == "", nil
}
func repoRoot() (string, error) {
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
result := &bytes.Buffer{}
cmd.Stdout = result
if err := cmd.Run(); err != nil {
return "", err
}
return strings.TrimSpace(result.String()), nil
}
func addFile(path string) error {
return exec.Command("git", "add", path).Run()
}
func commit(message string) error {
return exec.Command("git", "commit", "-m", message).Run()
}
func tag(version string) error {
return exec.Command("git", "tag", version).Run()
}

126
vendor/github.com/Clever/gitsem/main.go generated vendored Normal file
View File

@@ -0,0 +1,126 @@
package main
import (
"flag"
"fmt"
"gopkg.in/blang/semver.v1"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
)
func commitMessage(message, version string) string {
if strings.Contains(message, "%s") {
return fmt.Sprintf(message, version)
}
return message
}
func getCurrentVersion(path string) (*semver.Version, error) {
if _, err := os.Stat(path); os.IsNotExist(err) {
return &semver.Version{}, nil
}
contents, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
return semver.New(strings.TrimSpace(string(contents)))
}
const versionFileName = "VERSION"
func exitWithError(message string) {
fmt.Fprintf(os.Stderr, message+"\n\n")
flag.Usage()
os.Exit(1)
}
func bump(old *semver.Version, part string) *semver.Version {
// We don't want to mutate the input, but there's no Clone or Copy method on a semver.Version,
// so we make a new one by parsing the string version of the old one.
// We ignore any errors because we know it's valid semver.
new, _ := semver.New(old.String())
switch part {
case "major":
new.Major++
new.Minor = 0
new.Patch = 0
case "minor":
new.Minor++
new.Patch = 0
case "patch":
new.Patch++
}
return new
}
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s: [options] version\n\n", os.Args[0])
fmt.Fprintf(os.Stderr, "version can be one of: newversion | patch | minor | major\n\n")
fmt.Fprintf(os.Stderr, "options:\n")
flag.PrintDefaults()
}
message := flag.String("m", "%s", "commit message for version commit")
help := flag.Bool("h", false, "print usage and exit")
shouldTag := flag.Bool("tag", true, "whether or not to make a tag at the version commit")
flag.Parse()
if *help {
flag.Usage()
os.Exit(0)
}
if *message == "" {
exitWithError("missing message")
}
if clean, err := isRepoClean(); err != nil {
log.Fatal(err)
} else if !clean {
log.Fatal("repo isn't clean")
}
root, err := repoRoot()
if err != nil {
log.Fatal(err)
}
versionFile := filepath.Join(root, versionFileName)
version, err := getCurrentVersion(versionFile)
if err != nil {
log.Fatal(err)
}
if len(flag.Args()) != 1 {
exitWithError("gitsem takes exactly one non-flag argument: version")
}
newVersion := flag.Args()[0]
switch newVersion {
case "patch", "minor", "major":
version = bump(version, newVersion)
default:
if version, err = semver.New(newVersion); err != nil {
log.Fatalf("failed to parse %s as semver: %s", newVersion, err.Error())
}
}
if err := ioutil.WriteFile(versionFile, []byte(version.String()), 0666); err != nil {
log.Fatal(err)
}
if err := addFile(versionFile); err != nil {
log.Fatal(err)
}
versionString := "v" + version.String()
*message = commitMessage(*message, versionString)
if err := commit(*message); err != nil {
log.Fatal(err)
}
if *shouldTag {
if err := tag(versionString); err != nil {
log.Fatal(err)
}
}
fmt.Println(versionString)
}