-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check-metadata.sh: new maintenance script
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -u | ||
|
||
error () { | ||
>&2 echo "ERROR: " "$@" | ||
} | ||
|
||
has_metadata_entry () { | ||
# .user.jss files have slashes and spaces at the start of the line, | ||
# but .user.css files do not | ||
grep -q -E "^[/ ]*@${1}" "${2}" | ||
} | ||
|
||
has_version () { | ||
has_metadata_entry 'version *[0-9.-]+' "$1" | ||
} | ||
|
||
has_license () { | ||
has_metadata_entry 'license *' "$1" | ||
} | ||
|
||
has_namespace () { | ||
# some have https://github.com/rybak/atlassian-tweaks while others | ||
# have https://github.com/rybak, without the repository name | ||
# both are fine | ||
has_metadata_entry 'namespace *https://github.com/rybak' "$1" | ||
} | ||
|
||
has_homepageURL () { | ||
has_metadata_entry 'homepageURL *https://github.com/rybak/atlassian-tweaks' "$1" | ||
} | ||
|
||
check () { | ||
if ! $1 "$2" | ||
then | ||
error "$3" | ||
res=false | ||
fi | ||
} | ||
|
||
GITHUB_URL=https://github.com/rybak/atlassian-tweaks | ||
|
||
res=true | ||
for f in *.user.js *.user.css | ||
do | ||
check has_version "$f" "File '$f' is missing @version" | ||
check has_license "$f" "File '$f' is missing @license" | ||
check has_namespace "$f" "File '$f' is missing @namespace $GITHUB_URL" | ||
check has_homepageURL "$f" "File '$f' is missing @homepageURL $GITHUB_URL" | ||
done | ||
|
||
$res |