我正在尝试创建一个bash脚本,我将在即将提交的文件上运行jalopy(Java代码格式化程序),以确保代码格式化正确完成,否则拒绝提交。
到目前为止,我已经研究并尝试了以下内容:
#!/bin/bash
AllVariables="$@"
checkingAnyArgs='/tmp/checkingAnyArgs'
echo >> ${checkingAnyArgs} ; echo >> ${checkingAnyArgs}
echo "\$AllVariables: ${AllVariables}" >> ${checkingAnyArgs}
echo "I see the commit now." >> ${checkingAnyArgs}
while read oldrev newrev ref
do
echo "STARTING [$oldrev $newrev $ref]" >> ${checkingAnyArgs}
echo "git diff-tree --full-index -a -r \$oldrev..\$newrev -- $(git diff-tree --full-index -a -r $oldrev..$newrev) " >> ${checkingAnyArgs}
for FILE in `git diff-tree -r $oldrev..$newrev | awk '{print $6}'`
do
echo "pwd: $(pwd)" >> ${checkingAnyArgs}
echo "git update-ref refs/blametree/$ref/$FILE $newrev $oldrev" >> ${checkingAnyArgs}
echo "ls -l $FILE: $(ls -l $FILE)" >> ${checkingAnyArgs}
if [[ $(grep 'changed' $FILE) ]] ; then
echo "$FILE ' contains changed!'" >> ${checkingAnyArgs}
exit 1
fi
#echo "git diff-tree --name-status -rz $ref $newrev : $(git diff-tree --name-status -rz $ref..$newrev)" >> ${checkingAnyArgs}
echo "jalopy.sh --convention http://svn1.cvs.ula.comcast.net/svn/cvs-common/trunk/tools/jalopy/jalopy-1.9.4.xml --profile default -r ${FILE} -d /root/test-jalopy1" >> ${checkingAnyArgs}
/opt/jalopy/bin/jalopy.sh --convention http://svn1.cvs.ula.comcast.net/svn/cvs-common/trunk/tools/jalopy/jalopy-1.9.4.xml --profile default ${FILE} -d /root/test-jalopy1 >> ${checkingAnyArgs} 2>&1
#git update-ref refs/blametree/$ref/$path $newrev >> ${checkingAnyArgs}
done
done
$ {checkingAnyArgs}输出
$AllVariables:
I see the commit now.
STARTING [2f4ccbcc830ee5c464aeb34f0468dcda4782c507 6392fa90586a0b262fb6abde643a8d955e00d32b refs/heads/master]
git diff-tree --full-index -a -r $oldrev..$newrev -- :100644 100644 ee3198f98544cda7b2075ff25f92dab63a7afc0f e5695b1a44a821041016cae7fe3063effde7b977 M Test.java
pwd: /usr/local/stash/data/repositories/1
git update-ref refs/blametree/refs/heads/master/Test.java 6392fa90586a0b262fb6abde643a8d955e00d32b 2f4ccbcc830ee5c464aeb34f0468dcda4782c507
ls -l Test.java:
jalopy.sh --convention URL/jalopy-1.9.4.xml --profile default -r Test.java -d /root/test-jalopy1
Jalopy Source Code Formatter 1.9.4_79
Multi-User License (120 Users) Owner: TVWorks, Mill Valley, USA
Copyright (c) 2003-2010 TRIEMAX Software. All rights reserved.
[INFO] Detecting code convention format
[INFO] Jalopy code convention detected
[INFO] Importing settings into profile "default"
[INFO] Imported 742 keys into profile "default"
No files found for path or filter expression "Test.java"
所以我的问题是为什么它找不到'Test.java'文件?任何帮助在这里表示赞赏。或者,我如何使用此文件。
谢谢, 穆尔塔扎