我正在寻找一种为每个提交消息创建带有时间戳的提交消息日志的方法,以跟踪我本周的工作?有没有人举这个例子?
您可以创建一个commit.sh bash脚本来简化该过程。
#!/bin/bash
## your timestamp
NOW=$(date +%Y.%m.%d-%H:%M:%S)
## your source file
g=main.sh
## get the current version by extracting from the first 3 lines
## ideally they are comments, containing the version
cv=`head -n 3 $g | grep "version" | sed 's/[^0-9.]*//g'`
## if you want a new version automatically incremented
nv=`echo $cv | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}'`
## automatically apply it in your sourcecode
echo "Updateing $g from $cv to $nv $NOW"
## re-print the first 3 lines of your code - this is bash here
cat $g > $g.bak
echo '#!/bin/bash' > $g
echo '# Last update:'$NOW >> $g
echo '# version '$nv >> $g
tail -n +4 $g.bak >> $g
rm $g.bak
## git action
git add . --all
git commit -m "$nv $1"
git push
## If you want a log of your commits
echo "$NOW - Updated $g from $cv to $nv - $1" >> $0.log
这样你就可以:
./commit.sh "I worked a lot on this, now it's done."
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句