-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DMPRoadmap Rubocop style guide gem (#1797)
* Add DMPRoadmap Rubocop style guide gem * Add bin exe for Rubocop check on changed files
- Loading branch information
Showing
4 changed files
with
56 additions
and
6 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,3 @@ | ||
inherit_gem: | ||
rubocop-dmp_roadmap: | ||
- config/default.yml |
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
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
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,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Which branch should we compare HEAD with for changed files? (defaults: 'development') | ||
BRANCH='development' | ||
DIRS='app lib' | ||
|
||
while getopts 'b:d:' optname | ||
do | ||
case "$optname" in | ||
"b") | ||
BRANCH=$OPTARG | ||
;; | ||
"d") | ||
DIRS=$OPTARG | ||
;; | ||
esac | ||
done | ||
|
||
# Get a list of all files that have changed on this branch in app and lib directories. | ||
CHANGED_FILES=$(git diff --name-only $BRANCH -- $DIRS) | ||
|
||
# A string with the name of each changed file | ||
EXISTING_FILES="" | ||
|
||
# Iterate over each changed file | ||
for FILEPATH in $CHANGED_FILES | ||
do | ||
# Append this filename if the file still exists (in case the file has been deleted) | ||
if [ -f $FILEPATH ]; then | ||
EXISTING_FILES+=" $FILEPATH" | ||
fi | ||
done | ||
|
||
# If there are no files that have been changed... | ||
if [ -z "$EXISTING_FILES" ] | ||
then | ||
# Print a message and exit | ||
echo "Rubocop changed: No matching files have changed." | ||
exit 0 | ||
else | ||
# Run Rubocop against the files that have chagned | ||
rubocop -p $EXISTING_FILES | ||
fi |