Merge lp:~chipaca/snappy/precommit into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by John Lenton
Status: Merged
Approved by: John Lenton
Approved revision: 704
Merged at revision: 706
Proposed branch: lp:~chipaca/snappy/precommit
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 169 lines (+76/-40)
4 files modified
.precommit (+32/-0)
.tarmac.sh (+1/-1)
i18n/xgettext-go/main.go (+0/-2)
run-checks (+43/-37)
To merge this branch: bzr merge lp:~chipaca/snappy/precommit
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
Review via email: mp+271290@code.launchpad.net

Commit message

Added a precommit hook. Made some changes to run-checks to make it better as a precommit script.

Also made vet happy wrt unreachable code in xgettext-go.

Description of the change

A very silly branch that you can ignore until things are less manic.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.precommit'
2--- .precommit 1970-01-01 00:00:00 +0000
3+++ .precommit 2015-09-16 12:23:49 +0000
4@@ -0,0 +1,32 @@
5+#!/bin/sh
6+set -e
7+echo "$@"
8+# put me in the project root, call me ".precommit".
9+# And put this here-document in ~/.bazaar/plugins/precommit_script.py:
10+<<EOF
11+import os
12+
13+if not os.getenv("SKIP_COMMIT_HOOK"):
14+ import subprocess
15+ from bzrlib.mutabletree import MutableTree
16+ from bzrlib import errors
17+
18+ def start_commit_hook(*_):
19+ """This hook will execute '.precommit' script from root path of the bazaar
20+ branch. Commit will be canceled if precommit fails."""
21+
22+ # this hook only makes sense if a precommit file exist.
23+ if not os.path.exists(".precommit"):
24+ return
25+ try:
26+ subprocess.check_call(os.path.abspath(".precommit"))
27+ # if precommit fails (process return not zero) cancel commit.
28+ except subprocess.CalledProcessError:
29+ raise errors.BzrError("pre commit check failed (set SKIP_COMMIT_HOOK to skip).")
30+
31+ MutableTree.hooks.install_named_hook('start_commit', start_commit_hook,
32+ 'Run "precommit" script on start_commit')
33+EOF
34+
35+./run-checks --quick
36+
37
38=== modified file '.tarmac.sh'
39--- .tarmac.sh 2015-02-13 13:29:27 +0000
40+++ .tarmac.sh 2015-09-16 12:23:49 +0000
41@@ -11,4 +11,4 @@
42 cp -a . $GOPATH/src/launchpad.net/snappy/
43 cd $GOPATH/src/launchpad.net/snappy
44
45-./run-checks
46+sh -v ./run-checks
47
48=== modified file 'i18n/xgettext-go/main.go'
49--- i18n/xgettext-go/main.go 2015-09-10 06:16:31 +0000
50+++ i18n/xgettext-go/main.go 2015-09-16 12:23:49 +0000
51@@ -89,8 +89,6 @@
52 default:
53 panic(fmt.Sprintf("unknown type: %v", val))
54 }
55-
56- return ""
57 }
58
59 func inspectNodeForTranslations(fset *token.FileSet, f *ast.File, n ast.Node) bool {
60
61=== modified file 'run-checks'
62--- run-checks 2015-09-02 18:11:49 +0000
63+++ run-checks 2015-09-16 12:23:49 +0000
64@@ -1,6 +1,6 @@
65 #!/bin/sh
66
67-set -ev
68+set -eu
69
70 if which goctest >/dev/null; then
71 goctest="goctest"
72@@ -8,6 +8,11 @@
73 goctest="go test"
74 fi
75
76+QUICK=""
77+if [ "${1:-}" = "--quick" ]; then
78+ QUICK=yes
79+fi
80+
81 echo Checking docs
82 ./mdlint.py docs/*.md
83
84@@ -20,27 +25,26 @@
85 exit 1
86 fi
87
88-echo Installing godeps
89-go get launchpad.net/godeps
90-export PATH=$PATH:$GOPATH/bin
91-
92-echo Install golint
93-go get github.com/golang/lint/golint
94-export PATH=$PATH:$GOPATH/bin
95-
96-echo Obtaining dependencies
97-godeps -u dependencies.tsv
98-
99-
100-
101-echo Building
102-go build -v launchpad.net/snappy/...
103-
104-
105-# tests
106-echo Running tests from $(pwd)
107-$goctest -v -cover ./...
108-
109+if [ -z "$QUICK" ]; then
110+ echo Installing godeps
111+ go get launchpad.net/godeps
112+ export PATH=$PATH:$GOPATH/bin
113+
114+ echo Install golint
115+ go get github.com/golang/lint/golint
116+ export PATH=$PATH:$GOPATH/bin
117+
118+ echo Obtaining dependencies
119+ godeps -u dependencies.tsv
120+
121+ echo Building
122+ go build -v launchpad.net/snappy/...
123+
124+
125+ # tests
126+ echo Running tests from $(pwd)
127+ $goctest -v -cover ./...
128+fi
129
130 # go vet
131 echo Running vet
132@@ -67,21 +71,23 @@
133 fi
134
135
136-# integration tests
137-echo Building the integration tests
138-go build _integration-tests/main.go
139-
140-# the rabbit hole
141-echo Running the tests for the integration testutils
142-$goctest -v -cover ./_integration-tests/testutils/...
143-
144-# integration suite in kvm
145-if which adt-run >/dev/null 2>&1; then
146- echo "Running integration tests on rolling edge"
147- go run _integration-tests/main.go --snappy-from-branch
148- # print the results.
149- if which subunit2pyunit >/dev/null 2>&1; then
150- subunit-1to2 /tmp/snappy-test/output/artifacts/results.subunit | subunit2pyunit
151+if [ -z "$QUICK" ]; then
152+ # integration tests
153+ echo Building the integration tests
154+ go build _integration-tests/main.go
155+
156+ # the rabbit hole
157+ echo Running the tests for the integration testutils
158+ $goctest -v -cover ./_integration-tests/testutils/...
159+
160+ # integration suite in kvm
161+ if which adt-run >/dev/null 2>&1; then
162+ echo "Running integration tests on rolling edge"
163+ go run _integration-tests/main.go --snappy-from-branch
164+ # print the results.
165+ if which subunit2pyunit >/dev/null 2>&1; then
166+ subunit-1to2 /tmp/snappy-test/output/artifacts/results.subunit | subunit2pyunit
167+ fi
168 fi
169 fi
170

Subscribers

People subscribed via source and target branches