Skip to content

Commit da893d7

Browse files
committed
[Abhishek] Adding the git hook which will run robocop to check the code before pushing any commit
1 parent 87ae1ed commit da893d7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

app/helpers/passages_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module PassagesHelper
4-
DRAFT_PASSAGES = 'drafts_passages'
4+
DRAFT_PASSAGES = 'drafts_passages'.freeze
55

66
def admin_tabs
77
{ drafts: :drafts, ongoing: :ongoing, finished: :concluded, new: :new }

setup-git-pre-hook.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
echo "
3+
#!/bin/sh
4+
red='\\\033[0;31m'
5+
white='\\\033[1;37m'
6+
b=\$(rubocop -D)
7+
exit_code=\$?
8+
if [[ \$exit_code != 0 ]]; then
9+
echo "\"\\\n \\\t \\\t \\\t \${red}Ooops!!!\""
10+
echo "\"\\\tYou seems to have voilated few code conventions.\""
11+
echo "\"\\\tMake sure you have fixed them before commiting your changes\""
12+
echo "\"\\\tRun \${white}rubocop -D\${red} to know about the voilated conventions\""
13+
exit \$exit_code
14+
fi
15+
" > .git/hooks/pre-commit
16+
17+
chmod +x .git/hooks/pre-commit
18+
19+
# Run this file to activate the git hook by running
20+
#` chmod 400 setup-git-pre-hook.sh ;sh setup-git-pre-hook.sh `

0 commit comments

Comments
 (0)