Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

Commit

Permalink
add list-external-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mattes committed Feb 9, 2017
1 parent b3f6bc4 commit 7979fdb
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SOURCE ?= file go-bindata github
DATABASE ?= postgres
VERSION ?= $(shell git describe --tags 2>/dev/null)
TEST_FLAGS ?=
REPO_OWNER ?= $(shell cd .. && basename "$$(pwd)")


build-cli: clean
Expand Down Expand Up @@ -39,12 +40,12 @@ test-with-flags:
@go test $(TEST_FLAGS) ./testing/...

@echo -n '$(SOURCE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./source/{}
@go test $(TEST_FLAGS) ./source/testing
@go test $(TEST_FLAGS) ./source/stub
@go test $(TEST_FLAGS) ./source/testing/...
@go test $(TEST_FLAGS) ./source/stub/...

@echo -n '$(DATABASE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./database/{}
@go test $(TEST_FLAGS) ./database/testing
@go test $(TEST_FLAGS) ./database/stub
@go test $(TEST_FLAGS) ./database/testing/...
@go test $(TEST_FLAGS) ./database/stub/...

# deprecated v1compat:
@go test ./migrate/...
Expand All @@ -59,16 +60,37 @@ deps:
-go test -v -i ./...


list-external-deps:
$(call external_deps,'.')
$(call external_deps,'./cli/...')
$(call external_deps,'./testing/...')

$(foreach v, $(SOURCE), $(call external_deps,'./source/$(v)/...'))
$(call external_deps,'./source/testing/...')
$(call external_deps,'./source/stub/...')

$(foreach v, $(DATABASE), $(call external_deps,'./database/$(v)/...'))
$(call external_deps,'./database/testing/...')
$(call external_deps,'./database/stub/...')


restore-import-paths:
find . -name '*.go' -type f -execdir sed -i '' s#\"github.com/$(shell cd .. && basename "$$(pwd)")/migrate#\"github.com/mattes/migrate#g '{}' \;
find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/$(REPO_OWNER)/migrate%\"github.com/mattes/migrate%g '{}' \;


rewrite-import-paths:
find . -name '*.go' -type f -execdir sed -i '' s#\"github.com/mattes/migrate#\"github.com/$(shell cd .. && basename "$$(pwd)")/migrate#g '{}' \;
find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/mattes/migrate%\"github.com/$(REPO_OWNER)/migrate%g '{}' \;


define external_deps
@echo -- $(1)
@go list -f '{{join .Deps "\n"}}' $(1) | grep -v github.com/$(REPO_OWNER)/migrate | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
@#\n
endef


.PHONY: build-cli clean test-short test test-with-flags deps html-coverage \
restore-import-paths rewrite-import-paths
restore-import-paths rewrite-import-paths list-external-deps

SHELL = /bin/bash
RAND = $(shell echo $$RANDOM)
Expand Down

0 comments on commit 7979fdb

Please sign in to comment.