Skip to content

Commit 612f019

Browse files
committed
Merge pull request #198 from zbeekman/misc-fixes
Git hooks robustness improvements and markdown tweaks
2 parents e7d7bcc + c2e4000 commit 612f019

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ This is the development branch, akin to GCC's `trunk`. Both of `devel` and `mast
101101
[these guidelines]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
102102
[an open issue]: https://github.com/sourceryinstitute/opencoarrays/issues
103103
[Create a branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
104-
[OpenCoarrays repo]: https://github.com/sourceryinstitute/opencoarrays#fork-destination-box
104+
[OpenCoarrays repo]: https://github.com/sourceryinstitute/opencoarrays/fork
105105
[Pull Request]: https://help.github.com/articles/using-pull-requests/
106106
[Fork]: https://help.github.com/articles/fork-a-repo/
107107
[helping out]: #helping-out

STATUS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ To-Do List
192192
[Numerical Algorithms Group (nagfor)]: #compiler-issues-nag
193193
[Portland Group (pgfortran)]: #compiler-issues-pg
194194
[IBM (xlf)]: #compiler-issues-ibm
195-
[forking the OpenCoarrays repository]: https://github.com/sourceryinstitute/opencoarrays/blob/master/STATUS.md#fork-destination-box
195+
[forking the OpenCoarrays repository]: https://github.com/sourceryinstitute/opencoarrays/fork
196196

197197
[TS 18508]: http://isotc.iso.org/livelink/livelink?func=ll&objId=17181227&objAction=Open
198198
[opencoarrays module]: ./src/extensions/opencoarrays.F90

developer-scripts/git-hooks/commit-msg

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
#
33
# An example hook script to check the commit log message.
44
# Called by "git commit" with one argument, the name of the file
@@ -59,7 +59,8 @@ and keeping a clean history, please see:
5959
2. http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
6060
3. https://www.reviewboard.org/docs/codebase/dev/git/clean-commits/
6161
62-
And for funny examples of what not to do, see: http://whatthecommit.com
62+
And for funny examples of what not to do, see: http://whatthecommit.com and
63+
http://stopwritingramblingcommitmessages.com
6364
EOF
6465

6566
}
@@ -77,7 +78,8 @@ test "" = "$(grep '^Signed-off-by: ' "$1" |
7778
# Check that the first line of the commit starts with a
7879
# capitalized letter.
7980
if ! (head -n 1 $1 | grep '^[A-Z]' &>/dev/null ); then
80-
echo >&2 "First word of commit message must be a capitalized imperative verb.\n"
81+
echo >&2 "First word of commit message must be a capitalized imperative verb."
82+
echo ""
8183
let status=1
8284
fi
8385

@@ -89,23 +91,28 @@ cat $1 | \
8991
nchars=$(wc -c <<<$line)
9092
if [[ "$ln" -eq "1" ]]; then
9193
if [[ "$nchars" -gt "51" ]]; then
92-
echo >&2 "First line of commit message too long ($nchars > 50 chars)\n"
94+
echo >&2 "First line of commit message too long ($nchars > 50 chars)"
95+
echo ""
9396
let status=1
9497
fi
9598
elif [[ "$ln" -eq "2" ]]; then
9699
if [[ "$nchars" -gt "1" ]] && ! grep '^#' <<<"$line" >/dev/null; then
97-
echo >&2 "Second line of commit message not blank\n"
100+
echo >&2 "Second line of commit message not blank"
101+
echo ""
98102
let status=1
99103
fi
100104
else
101105
if [[ "$nchars" -gt "72" ]]; then
102-
echo >&2 "Line $ln of commit message too long ($nchars > 72 chars)\n"
106+
echo >&2 "Line $ln of commit message too long ($nchars > 72 chars)"
107+
echo ""
103108
let status=1
104109
fi
105110
fi
106111
done
107112

108-
if [[ $status != 0 ]]; then
109-
error_message
110-
exit 1
113+
if [[ $status = 0 ]]; then
114+
exit 0
111115
fi
116+
117+
error_message
118+
exit 1

developer-scripts/git-hooks/pre-commit

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
#
33
# An example hook script to verify what is about to be committed.
44
# Called by "git commit" with no arguments. The hook should
@@ -71,15 +71,18 @@ for f in $(git diff-index --name-status --cached $against | grep -v ^D | cut -c3
7171
if [[ "$f" =~ ([.](h|m|c|rb|sh|py|txt|md|f90|F90|cmake|x64|csh)|makefile|Makefile)$ ]] ||
7272
head -n 1 | grep '^#!/'; then
7373
if ! ends_with_newline "$f"; then
74-
echo &>2 "No newline at end of file: $f\n"
74+
echo &>2 "No newline at end of file: $f"
75+
echo ""
7576
let status=1
7677
fi
7778
fi
7879
done
7980

8081
# If there are whitespace errors, print the offending file names and fail.
81-
git diff-index --check --cached $against -- || let status=1
82+
git diff-index --check --cached $against -- || (let status=1 echo 'white space violations found')
8283

83-
if [[ $status != 0 ]]; then
84-
exit 1
84+
if [[ $status = 0 ]]; then
85+
exit 0
8586
fi
87+
88+
exit 1

developer-scripts/setup-git.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ if [[ "$1" ]]; then
88
echo "WARNING: Settings will be applied globally. This may over-write some of your global git settings."
99
read -p "Press Ctrl-C to abort, and try again without \`--global\` or press any key to contibue" foo
1010
else
11-
echo -e "Usage: $0 [--global] [--help]\n"
11+
echo "Usage: $0 [--global] [--help]"
12+
echo ""
1213
echo "This script is to configure your git environment"
1314
echo "For contributing to OpenCoarrays. The \`--help\`"
1415
echo "flag will print this message. The \`--global\`"

0 commit comments

Comments
 (0)