diff options
author | Alex Goodman <wagoodman@gmail.com> | 2018-10-16 22:56:35 -0400 |
---|---|---|
committer | Alex Goodman <wagoodman@gmail.com> | 2018-10-16 22:56:35 -0400 |
commit | 9802546b60e04aaedf42a2c364fff979493c0d6a (patch) | |
tree | 5e39e21b114dcb5b7eec1fef892777d8e634554c | |
parent | dddb2e6b975e5efbf24e3ad91f9e5ab0aca42ba6 (diff) |
adding goreleaserv0.0.1
-rw-r--r-- | .goreleaser.yml | 26 | ||||
-rwxr-xr-x | .scripts/tag.sh | 37 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | filetree/efficiency_test.go | 50 | ||||
-rw-r--r-- | filetree/tree_test.go | 48 | ||||
-rw-r--r-- | main.go | 6 |
7 files changed, 125 insertions, 49 deletions
diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..432b292 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,26 @@ +release: + prerelease: true + +builds: + - binary: dive + goos: + - darwin + - linux + goarch: + - amd64 + ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.buildTime={{.Date}}`. + +archive: + format: tar.gz + +fpm: + license: MIT + homepage: https://github.com/wagoodman/dive/ + formats: + - deb + - rpm + +brew: + github: + owner: wagoodman + name: homebrew-dive
\ No newline at end of file diff --git a/.scripts/tag.sh b/.scripts/tag.sh new file mode 100755 index 0000000..2e28f9f --- /dev/null +++ b/.scripts/tag.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -u + +BOLD=$(tput bold) +NORMAL=$(tput sgr0) + +echo "${BOLD}Tagging${NORMAL}" + +#get highest tag number +VERSION=`git describe --abbrev=0 --tags` + +#replace . with space so can split into an array +VERSION_BITS=(${VERSION//./ }) + +#get number parts and increase last one by 1 +VNUM1=${VERSION_BITS[0]} +VNUM2=${VERSION_BITS[1]} +VNUM3=${VERSION_BITS[2]} +VNUM3=$((VNUM3+1)) + +#create new tag +NEW_TAG="$VNUM1.$VNUM2.$VNUM3" + +echo "Updating $VERSION to $NEW_TAG" + +#get current hash and see if it already has a tag +GIT_COMMIT=`git rev-parse HEAD` +NEEDS_TAG=`git describe --contains $GIT_COMMIT` + +#only tag if no tag already (would be better if the git describe command above could have a silent option) +if [ -z "$NEEDS_TAG" ]; then + echo "Tagged with $NEW_TAG (Ignoring fatal:cannot describe - this means commit is untagged) " + git tag $NEW_TAG + git push --tags +else + echo "Already a tag on this commit" +fi
\ No newline at end of file @@ -9,6 +9,10 @@ run: build build: go build -o build/$(BIN) +release: test + ./.scripts/tag.sh + goreleaser --rm-dist + install: go install ./... @@ -23,4 +27,4 @@ clean: rm -rf vendor go clean -.PHONY: build install test lint clean +.PHONY: build install test lint clean release @@ -6,6 +6,7 @@ A tool for interrogating docker images. + ## Installing ``` docker build -t die-test:latest . diff --git a/filetree/efficiency_test.go b/filetree/efficiency_test.go new file mode 100644 index 0000000..08b2e56 --- /dev/null +++ b/filetree/efficiency_test.go @@ -0,0 +1,50 @@ +package filetree + +// TODO: rewrite this to be weighted by file size + +// func TestEfficencyMap(t *testing.T) { +// trees := make([]*FileTree, 3) +// for ix, _ := range trees { +// tree := NewFileTree() +// tree.AddPath("/etc/nginx/nginx.conf", FileInfo{}) +// tree.AddPath("/etc/nginx/public", FileInfo{}) +// trees[ix] = tree +// } +// var expectedMap = map[string]int{ +// "/etc/nginx/nginx.conf": 3, +// "/etc/nginx/public": 3, +// } +// actualMap := EfficiencyMap(trees) +// if !reflect.DeepEqual(expectedMap, actualMap) { +// t.Fatalf("Expected %v but go %v", expectedMap, actualMap) +// } +// } +// +// func TestEfficiencyScore(t *testing.T) { +// trees := make([]*FileTree, 3) +// for ix, _ := range trees { +// tree := NewFileTree() +// tree.AddPath("/etc/nginx/nginx.conf", FileInfo{}) +// tree.AddPath("/etc/nginx/public", FileInfo{}) +// trees[ix] = tree +// } +// expected := 2.0 / 6.0 +// actual := CalculateEfficiency(trees) +// if math.Abs(expected-actual) > 0.0001 { +// t.Fatalf("Expected %f but got %f", expected, actual) +// } +// +// trees = make([]*FileTree, 1) +// for ix, _ := range trees { +// tree := NewFileTree() +// tree.AddPath("/etc/nginx/nginx.conf", FileInfo{}) +// tree.AddPath("/etc/nginx/public", FileInfo{}) +// trees[ix] = tree +// } +// expected = 1.0 +// actual = CalculateEfficiency(trees) +// if math.Abs(expected-actual) > 0.0001 { +// t.Fatalf("Expected %f but got %f", expected, actual) +// } +// } + diff --git a/filetree/tree_test.go b/filetree/tree_test.go index 6c95df0..2a00b69 100644 --- a/filetree/tree_test.go +++ b/filetree/tree_test.go @@ -2,8 +2,6 @@ package filetree import ( "fmt" - "math" - "reflect" "testing" ) @@ -526,49 +524,3 @@ func TestRemoveOnIterate(t *testing.T) { } } - -func TestEfficencyMap(t *testing.T) { - trees := make([]*FileTree, 3) - for ix, _ := range trees { - tree := NewFileTree() - tree.AddPath("/etc/nginx/nginx.conf", FileInfo{}) - tree.AddPath("/etc/nginx/public", FileInfo{}) - trees[ix] = tree - } - var expectedMap = map[string]int{ - "/etc/nginx/nginx.conf": 3, - "/etc/nginx/public": 3, - } - actualMap := EfficiencyMap(trees) - if !reflect.DeepEqual(expectedMap, actualMap) { - t.Fatalf("Expected %v but go %v", expectedMap, actualMap) - } -} - -func TestEfficiencyScore(t *testing.T) { - trees := make([]*FileTree, 3) - for ix, _ := range trees { - tree := NewFileTree() - tree.AddPath("/etc/nginx/nginx.conf", FileInfo{}) - tree.AddPath("/etc/nginx/public", FileInfo{}) - trees[ix] = tree - } - expected := 2.0 / 6.0 - actual := CalculateEfficiency(trees) - if math.Abs(expected-actual) > 0.0001 { - t.Fatalf("Expected %f but got %f", expected, actual) - } - - trees = make([]*FileTree, 1) - for ix, _ := range trees { - tree := NewFileTree() - tree.AddPath("/etc/nginx/nginx.conf", FileInfo{}) - tree.AddPath("/etc/nginx/public", FileInfo{}) - trees[ix] = tree - } - expected = 1.0 - actual = CalculateEfficiency(trees) - if math.Abs(expected-actual) > 0.0001 { - t.Fatalf("Expected %f but got %f", expected, actual) - } -} @@ -24,6 +24,12 @@ import ( "github.com/wagoodman/dive/cmd" ) +var ( + version = "No version provided" + commit = "No commit provided" + buildTime = "No build timestamp provided" +) + func main() { cmd.Execute() } |