-
Notifications
You must be signed in to change notification settings - Fork 6
/
run-rubocop.sh
45 lines (38 loc) · 1.48 KB
/
run-rubocop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -v
# Copyright (c) 2015 sanemat
# License MIT
# https://github.com/packsaddle/ruby-saddler/blob/master/bin/run-rubocop.sh
if [ -n "${TRAVIS_PULL_REQUEST}" ] && [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
# Travis-CI
#
# git clone --depth=50 \
# git://github.com/packsaddle/example-ruby-travis-ci.git \
# packsaddle/example-ruby-travis-ci
# cd packsaddle/example-ruby-travis-ci
# git fetch origin +refs/pull/1/merge:
# git checkout -qf FETCH_HEAD
echo gem install
gem install --no-document rubocop-select rubocop rubocop-checkstyle_formatter \
checkstyle_filter-git saddler saddler-reporter-github \
github_status_notifier
github-status-notifier notify --state pending --context saddler/rubocop
TARGET_FILES=$(git diff -z --name-only origin/master \
| xargs -0 rubocop-select)
if [ "${TARGET_FILES}" == "" ]; then
echo "no rubocop target found"
github-status-notifier notify --state success --context saddler/rubocop
exit 0
fi
git diff -z --name-only origin/master \
| xargs -0 rubocop-select \
| xargs rubocop \
--require rubocop/formatter/checkstyle_formatter \
--format RuboCop::Formatter::CheckstyleFormatter \
| checkstyle_filter-git diff origin/master \
| saddler report \
--require saddler/reporter/github \
--reporter Saddler::Reporter::Github::PullRequestReviewComment
github-status-notifier notify --exit-status $? --context saddler/rubocop
fi
exit 0