Skip to content

Commit

Permalink
chore: Update tools, use new go-fish (#8)
Browse files Browse the repository at this point in the history
* chore: Use goimports

* chore: Use new go-fish

* chore: Upgrade tools

* chore: Fix check_fmt script
  • Loading branch information
cszatmary committed Apr 14, 2021
1 parent bf4a8c7 commit 9709288
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ shed_cache_key: &shed_cache_key shed-tools-20201218-{{ checksum "shed.lock" }}
jobs:
lint-build-test:
docker:
- image: cimg/go:1.15
- image: cimg/go:1.16
steps:
- checkout
- restore_cache:
Expand Down
8 changes: 4 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project_name: shed

before:
hooks:
- go mod download
- go mod tidy
- make completions

builds:
Expand Down Expand Up @@ -46,7 +46,7 @@ release:

# TODO(@cszatmary): Figure out homebrew release
# brews:
# - github:
# - tap:
# owner: getshiphub
# name: homebrew-tap
# commit_author:
Expand All @@ -58,5 +58,5 @@ release:
# system "#{bin}/shed --version"
# install: |
# bin.install "shed"
# bash_completion.install "dist/completions/shed.bash"
# zsh_completion.install "dist/completions/_shed"
# bash_completion.install "completions/shed.bash"
# zsh_completion.install "completions/_shed"
1 change: 1 addition & 0 deletions .hooks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go-fish
12 changes: 12 additions & 0 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
. "$(dirname "$0")/go-fish/go-fish.sh"

[ -n "$CI" ] && exit 0

shed() {
go run main.go "$@"
}

if GO_FILES="$(git diff --name-only --staged --diff-filter=ACMR | grep "\.go$")"; then
shed run goimports -- -w $GO_FILES && git add $GO_FILES
fi
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ COVERPKGS = ./cache,./client,./internal/spinner,./internal/util,./lockfile,./too
# Get all dependencies
setup:
@echo Installing dependencies
@go mod download
@go mod tidy
# Self-hoisted!
@echo Installing tool dependencies
@$(SHED) install
Expand All @@ -20,6 +20,13 @@ build-snapshot:
@$(SHED) run goreleaser build -- --snapshot --rm-dist
.PHONY: build-snapshot

release:
$(if $(version),,$(error version variable is not set))
git tag -a v$(version) -m "v$(version)"
git push origin v$(version)
$(SHED) run goreleaser release -- --rm-dist
.PHONY: release

# Generate shell completions for distribution
completions:
@mkdir -p completions
Expand All @@ -36,7 +43,7 @@ clean:
.PHONY: clean

fmt:
@gofmt -w .
@$(SHED) run goimports -- -w .
.PHONY: fmt

check-fmt:
Expand Down
7 changes: 0 additions & 7 deletions go-fish.yml

This file was deleted.

14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ go 1.15
require (
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-isatty v0.0.12
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.7.0
github.com/spf13/cobra v1.1.1
github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/mod v0.4.0
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e // indirect
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0 // indirect
golang.org/x/mod v0.4.2
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
54 changes: 17 additions & 37 deletions go.sum

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions scripts/check_fmt.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#!/bin/bash

if [ "$(gofmt -l . | wc -l)" -gt 0 ]; then
set -eo pipefail

shed() {
go run main.go "$@"
}

if [ "$(shed run goimports -- -l . | wc -l)" -gt 0 ]; then
echo "Unformatted files found:"
# Run again to print files. Couldn't figure out a way to
# save the output and make it work with wc.
gofmt -l .
shed run goimports -- -l .
exit 1
fi
9 changes: 6 additions & 3 deletions shed.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"tools": {
"github.com/cszatmary/go-fish": {
"version": "v0.0.0-20201203230243-22d10c9b658d"
"version": "v0.0.0-20210414180724-443d9e00794d"
},
"github.com/golangci/golangci-lint/cmd/golangci-lint": {
"version": "v1.33.0"
"version": "v1.39.0"
},
"github.com/goreleaser/godownloader": {
"version": "v0.1.1-0.20200813202458-888d721de8bd"
},
"github.com/goreleaser/goreleaser": {
"version": "v0.149.0"
"version": "v0.162.0"
},
"golang.org/x/tools/cmd/goimports": {
"version": "v0.1.0"
}
}
}

0 comments on commit 9709288

Please sign in to comment.