VERSION = $(shell git describe --tags)

all: build
	./guireleaser --help

# single: build
# 	./guireleaser go.wit.com/apps/go-clone --increment --release --reason "testing guireleaser" --dry-run
# dump:
# 	./guireleaser go.wit.com/apps/go-clone --increment --release --reason "testing guireleaser" --dry-run --dump-versions
# single-really-do-it: build
# 	./guireleaser go.wit.com/apps/go-clone --increment --release --reason "testing guireleaser"

stderr: build
	echo "writing to /tmp/guireleaser.stderr"
	./guireleaser >/tmp/guireleaser.stderr 2>&1

prepare-release:
	reset
	make curl-list-release-notdone
	make curl-incrementAllTargetVersions
	make curl-list-release-notdone
	make curl-whitelist-stuff
	make findNext
	make showNext

goimports:
	goimports -w *.go
	# // to globally reset paths:
	# // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" .

vet:
	GO111MODULE=off go vet

build:
	echo "build it!"
	-rm resources/*.so
	cp -a ~/go/src/go.wit.com/toolkits/*.so resources/
	GO111MODULE=off go build -v -x -ldflags " \
                -X main.VERSION=${VERSION}"

install:
	-rm resources/*.so
	cp -a ~/go/src/go.wit.com/toolkits/*.so resources/
	GO111MODULE=off go install -v -x -ldflags " \
                -X main.VERSION=${VERSION}"
	# go install -v -x
	guireleaser

check-git-clean:
	@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)

redomod:
	rm -f go.*
	GO111MODULE= go mod init
	GO111MODULE= go mod tidy

curl-help:
	curl --silent http://localhost:9419/help

curl-tempWin:
	curl --silent http://localhost:9419/tempWin

curl-rescan-All:
	curl --silent http://localhost:9419/rescanAll

curl-whitelist-stuff:
	curl --silent http://localhost:9419/whitelist?repo=go.wit.com/dev/test/gogit2
	curl --silent http://localhost:9419/whitelist?repo=git.wit.org/jcarr/clone-gitea

curl-setBranchesToMasterB:
	curl --silent http://localhost:9419/setBranchesToMasterB

# report on the release
findNext:
	curl --silent http://localhost:9419/findNext

showNext:
	curl --silent http://localhost:9419/showNext

doRelease:
	reset
	make curl-list-changed
	make showNext
	sleep 10
	curl --silent http://localhost:9419/doRelease

curl-setCurrent-go-wit-com-gui:
	curl --silent http://localhost:9419/setCurrentRepo?repo=go.wit.com/gui

curl-setTargetVersion-virtigo-v0.1.1:
	curl --silent http://localhost:9419/setTargetVersion?version=v0.1.1

curl-incrementAllTargetVersions:
	curl --silent http://localhost:9419/setAllTargetVersions

# report on the release
curl-list-release-notdone:
	curl --silent http://localhost:9419/releaseList?readonly=true

# only show repos that need to be merged to the master branch
curl-list-changed:
	curl --silent http://localhost:9419/list?perfect=false

# include repos that you probably can't git push commits
curl-list-everything:
	curl --silent http://localhost:9419/list?readonly=true

curl-file-for-go.wit.com:
	curl --silent http://localhost:9419/goweblist?readonly=true
	curl --silent http://localhost:9419/goweblist?readonly=true |sort > ~/go.wit.com.versions