Skip to content

Commit a8440f2

Browse files
Merge pull request #1798
Pre commit hook fix
2 parents 21c8ef2 + 8ccdb12 commit a8440f2

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.pre-commit-config.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ repos:
55
- id: check-yaml
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
8+
9+
- repo: local
10+
hooks:
11+
- id: malformed-event-dates
12+
name: Malformed event date check
13+
entry: ./_scripts/_malformeddates.sh
14+
language: system
15+
types: [file]
16+
files: \.(markdown|md)$
17+
pass_filenames: false

_scripts/_malformeddates.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
online_and_timezone=$(grep -Er --files-match '^online: true$' | xargs grep --files-with-match '^tz:')
3+
if [ -n "${malformed_event_dates}" ]; then
4+
echo "Online events should not have a time-zone. Offending files:" >&2
5+
echo "${malformed_event_dates}" >&2
6+
exit 1
7+
fi
8+
malformed_timezones=$(grep -Er --files-match '^tz:[^/]*$')
9+
if [ -n "${malformed_timezones}" ]; then
10+
echo "Time-zones should be in the form 'Continent/City'. Offending files:" >&2
11+
echo "${malformed_timezones}" >&2
12+
exit 1
13+
fi
14+
malformed_event_dates=$(grep -Er --files-without-match '^eventdate: [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [-+][0-9]{4}$' _events)
15+
if [ -n "${malformed_event_dates}" ]; then
16+
echo "Malformed event date in:" >&2
17+
echo "${malformed_event_dates}" >&2
18+
exit 1
19+
fi

0 commit comments

Comments
 (0)