Skip to content

Commit 8d257e1

Browse files
committed
git hooks
1 parent eeea1fc commit 8d257e1

9 files changed

+278
-270
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ _testmain.go
2424
*.prof
2525

2626
env/
27-
hooks/
27+
bin/

Makefile

+11-30
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
go_version = go1.6.2.linux-amd64
1+
go_version = go1.7.linux-amd64
22

33
go:
44

@@ -10,47 +10,28 @@ go:
1010
cd env && \
1111
wget https://storage.googleapis.com/golang/$(go_version).tar.gz && \
1212
tar -xf ./$(go_version).tar.gz && \
13-
mkdir gopath && \
1413
rm ./$(go_version).tar.gz ; \
1514
fi
1615

17-
@GOROOT=$(shell pwd)/env/go \
18-
GOPATH=$(shell pwd)/env/gopath \
19-
env/go/bin/go get -u github.com/FiloSottile/gvt
20-
21-
@GOROOT=$(shell pwd)/env/go \
22-
GOPATH=$(shell pwd)/env/gopath \
23-
env/go/bin/go get -u github.com/kshvakov/build-html
24-
2516
@echo "\033[1mGo compiler installed!\033[0m"
2617

27-
build-hooks:
18+
build:
2819

29-
@echo "\033[1mBuild hooks\033[0m"
20+
@echo "\033[1mBuild hook\033[0m"
3021

31-
@rm -rf hooks && mkdir -p hooks/bin && \
32-
rm -rf env/gopath/src/github.com/postgres-ci/hooks
33-
34-
@git clone -b master https://github.com/postgres-ci/hooks.git env/gopath/src/github.com/postgres-ci/hooks
35-
36-
@echo "\033[1mBuild post-commit hook\033[0m"
37-
38-
@GOROOT=$(shell pwd)/env/go \
39-
GOPATH=$(shell pwd)/env/gopath \
40-
env/go/bin/go build -ldflags='-s -w' -o hooks/bin/post-commit \
41-
env/gopath/src/github.com/postgres-ci/hooks/local/bin/post-commit.go
22+
@rm -rf bin && mkdir -p bin && rm -rf env/gopath/src/github.com/postgres-ci/hooks && mkdir -p env/gopath/src/github.com/postgres-ci/hooks
4223

43-
@echo "\033[1mBuild post-receive hook\033[0m"
24+
@cp -r ./git env/gopath/src/github.com/postgres-ci/hooks/
4425

4526
@GOROOT=$(shell pwd)/env/go \
4627
GOPATH=$(shell pwd)/env/gopath \
47-
env/go/bin/go build -ldflags='-s -w' -o hooks/bin/post-receive \
48-
env/gopath/src/github.com/postgres-ci/hooks/server-side/bin/post-receive.go
28+
CGO_ENABLED=0 \
29+
env/go/bin/go build -ldflags='-s -w' -o bin/postgres-ci-git-hook postgres-ci-git-hook.go
4930

50-
@cp env/gopath/src/github.com/postgres-ci/hooks/local/post-commit.sample hooks
51-
@cp env/gopath/src/github.com/postgres-ci/hooks/server-side/post-receive.sample hooks
31+
@echo "\033[1mdone!\033[0m"
5232

53-
@echo "\033[1mBuild hooks: done!\033[0m"
33+
install: build
5434

35+
cp bin/postgres-ci-git-hook /usr/bin/postgres-ci-git-hook
5536

56-
all: go build-hooks
37+
all: go build install

hooks/post-commit.sample

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
export HOST=https://postgres-ci.com
4+
export TOKEN=587e6d7b-a023-4cab-b982-8169557e9e0c
5+
export EVENT=post-commit
6+
7+
/usr/bin/postgres-ci-git-hook

hooks/post-receive.sample

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
export HOST=https://postgres-ci.com
4+
export TOKEN=587e6d7b-a023-4cab-b982-8169557e9e0c
5+
export EVENT=post-receive
6+
7+
/usr/bin/postgres-ci-git-hook

local/bin/post-commit.go

-99
This file was deleted.

local/post-commit.sample

-7
This file was deleted.

0 commit comments

Comments
 (0)