I have bunch of ruby scripts in a git repository and it seems to be really hard to enforce people to write properly indented code.
I also have a small ruby script that formats to code to specific standard and now i would like to run that as a a filter script so that junk wont get committed into repository.
echo "*.rb filter=rubyfilter" > .gitattributes
echo "[filter \"rubyfilter\"]" >> .git/config
echo " clean = /home/rasjani/bin/rbeauty" >> .git/config
echo " smudge = /home/rasjani/bin/rbeauty" >> .git/config
does the dirty trick git side but the ruby script should then process the files affected:
how / where do i look those up from ?
As described in the GitPro Book
The
git attributesman page mentions:So your script will process each
*.rbfiles (in the directory and subdirectories where the.gitattributesfile is located) on checkout and commit.See this SO question for a concrete example.
You can test your own setup with a:
Note: as mentioned in this SO question,
smudgeandcleanscripts can only modify the content of a file, without knowing what exact file they are processing.