Skip to content
Newer
Older
100755 62 lines (56 sloc) 1.66 KB
9d85b18 @grantneufeld Preflight script to run before committing a code checkin.
authored Feb 19, 2011
1 #!/bin/sh
2 #
3 # preflight.sh - Pre-flighting a Ruby project before a version commit.
4 #
5 # Requirements:
6 # * git
7 # * Ruby Gems
8 # - cucumber
f9a2c46 @grantneufeld Slight tweaking of preflight script.
authored Jul 18, 2011
9 # - metric_fu
9d85b18 @grantneufeld Preflight script to run before committing a code checkin.
authored Feb 19, 2011
10 # - rspec
11 # - simple_cov
12 #
13 # simple_cov needs to be configured to generate the coverage/percentage.txt file,
14 # which will just have the numeric percentage result.
15
1852890 @grantneufeld Update commit preflight script to halt if there are no changes to be …
authored Feb 19, 2011
16 # checking for changes
17 gs="$(git status | tail -n 1)"
18 if echo $gs | grep -q "^nothing to commit" ; then
19 # no uncommitted changes - so nothing to commit
20 echo "Nothing to commit."
21 exit 2
22 fi
23
9d85b18 @grantneufeld Preflight script to run before committing a code checkin.
authored Feb 19, 2011
24 echo "Running test suites..."
25 rm coverage/resultset.yml
f9a2c46 @grantneufeld Slight tweaking of preflight script.
authored Jul 18, 2011
26 bundle exec rake spec
27 bundle exec rake cucumber
9d85b18 @grantneufeld Preflight script to run before committing a code checkin.
authored Feb 19, 2011
28
29 # the following requires simple_cov to be configured to generate the coverage/percentage.txt file.
30 if cat coverage/percentage.txt | grep -q "^100\.0*$" ; then
31 # we have 100% coverage
32 echo ""
33 else
34 # we have < 100% coverage:
35 echo "Incomplete code test coverage ($(cat coverage/percentage.txt)%)."
36 open coverage/index.html
37 exit 1
38 fi
39
b339d22 @grantneufeld Gem updates. Bye-bye MetricFu.
authored Jan 31, 2012
40 # # report on the code quality
41 # echo "Generating Metric Fu reports..."
42 # bundle exec rake metrics:all
43 # open tmp/metric_fu/output/index.html
44 # echo ""
45 # FIXME: bring in some of the individual Metric Fu components, such as rails_best_practices.
9d85b18 @grantneufeld Preflight script to run before committing a code checkin.
authored Feb 19, 2011
46
1852890 @grantneufeld Update commit preflight script to halt if there are no changes to be …
authored Feb 19, 2011
47 # report the git status
9d85b18 @grantneufeld Preflight script to run before committing a code checkin.
authored Feb 19, 2011
48 echo "Checking version control status..."
1852890 @grantneufeld Update commit preflight script to halt if there are no changes to be …
authored Feb 19, 2011
49 if echo $gs | grep -q "^no changes added to commit" ; then
9d85b18 @grantneufeld Preflight script to run before committing a code checkin.
authored Feb 19, 2011
50 # there are changes, but none have been staged for version control
51 git status
52 echo ""
53 echo "Nothing has been staged for commit. Please use 'git add <path>' to stage files for commit."
54 exit 3
55 else
56 # there are files to commit
57 git status
58 echo ""
59 echo "Ready for commit ('git commit')."
60 echo "Use 'git add <path>', first, if you want to add additional files for the commit."
61 fi
Something went wrong with that request. Please try again.