@@ -2,6 +2,7 @@ SOURCE ?= file go-bindata github
2
2
DATABASE ?= postgres
3
3
VERSION ?= $(shell git describe --tags 2>/dev/null)
4
4
TEST_FLAGS ?=
5
+ REPO_OWNER ?= $(shell cd .. && basename "$$(pwd ) ")
5
6
6
7
7
8
build-cli : clean
@@ -39,12 +40,12 @@ test-with-flags:
39
40
@go test $(TEST_FLAGS) ./testing/...
40
41
41
42
@echo -n '$(SOURCE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./source/{}
42
- @go test $(TEST_FLAGS) ./source/testing
43
- @go test $(TEST_FLAGS) ./source/stub
43
+ @go test $(TEST_FLAGS) ./source/testing/...
44
+ @go test $(TEST_FLAGS) ./source/stub/...
44
45
45
46
@echo -n '$(DATABASE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./database/{}
46
- @go test $(TEST_FLAGS) ./database/testing
47
- @go test $(TEST_FLAGS) ./database/stub
47
+ @go test $(TEST_FLAGS) ./database/testing/...
48
+ @go test $(TEST_FLAGS) ./database/stub/...
48
49
49
50
# deprecated v1compat:
50
51
@go test ./migrate/...
@@ -59,16 +60,37 @@ deps:
59
60
-go test -v -i ./...
60
61
61
62
63
+ list-external-deps :
64
+ $(call external_deps,'.')
65
+ $(call external_deps,'./cli/...')
66
+ $(call external_deps,'./testing/...')
67
+
68
+ $(foreach v, $(SOURCE), $(call external_deps,'./source/$(v)/...'))
69
+ $(call external_deps,'./source/testing/...')
70
+ $(call external_deps,'./source/stub/...')
71
+
72
+ $(foreach v, $(DATABASE), $(call external_deps,'./database/$(v)/...'))
73
+ $(call external_deps,'./database/testing/...')
74
+ $(call external_deps,'./database/stub/...')
75
+
76
+
62
77
restore-import-paths :
63
- find . -name ' *.go' -type f -execdir sed -i ' ' s# \" github.com/$(shell cd .. && basename " $$( pwd ) ") /migrate# \" github.com/mattes/migrate# g ' {}' \;
78
+ find . -name ' *.go' -type f -execdir sed -i ' ' s% \" github.com/$(REPO_OWNER ) /migrate% \" github.com/mattes/migrate% g ' {}' \;
64
79
65
80
66
81
rewrite-import-paths :
67
- find . -name ' *.go' -type f -execdir sed -i ' ' s#\" github.com/mattes/migrate#\" github.com/$(shell cd .. && basename "$$(pwd ) ") /migrate#g ' {}' \;
82
+ find . -name ' *.go' -type f -execdir sed -i ' ' s%\" github.com/mattes/migrate%\" github.com/$(REPO_OWNER ) /migrate%g ' {}' \;
83
+
84
+
85
+ define external_deps
86
+ @echo -- $(1 )
87
+ @go list -f '{{join .Deps "\n"}}' $(1 ) | grep -v github.com/$(REPO_OWNER ) /migrate | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
88
+ @# \n
89
+ endef
68
90
69
91
70
92
.PHONY : build-cli clean test-short test test-with-flags deps html-coverage \
71
- restore-import-paths rewrite-import-paths
93
+ restore-import-paths rewrite-import-paths list-external-deps
72
94
73
95
SHELL = /bin/bash
74
96
RAND = $(shell echo $$RANDOM)
0 commit comments