代码拉取完成,页面将自动刷新
#!/bin/sh
#
# Check for ruby style errors
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
# Change it to match your initial commit sha
against=123acdac4c698f24f2352cf34c3b12e246b48af1
fi
# Check if rubocop is installed for the current project
bin/bundle exec rubocop -v >/dev/null 2>&1 || { echo >&2 "[Ruby Style][Fatal]: Add rubocop to your Gemfile"; exit 1; }
# Get only the staged files
FILES="$(git diff --cached --name-only --diff-filter=AMC | grep "\.rb$" | tr '\n' ' ')"
echo "[Ruby Style][Info]: Checking Ruby Style"
if [ -n "$FILES" ]
then
echo "[Ruby Style][Info]: ${FILES}"
if [ ! -f '.rubocop.yml' ]; then
echo "[Ruby Style][Warning]: No .rubocop.yml config file."
fi
# Run rubocop on the staged files
bin/bundle exec rubocop ${FILES}
if [ $? -ne 0 ]; then
echo "[Ruby Style][Error]: Fix the issues and commit again"
echo "[Ruby Style][Error]: 修复这些缺陷之后再尝试提交"
exit 1
fi
else
echo "[Ruby Style][Info]: No files to check"
fi
exit 0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。