git log

#! /bin/bash

echo $1
if [ $# -ne 1 ] 
then
  echo '分支不能为空'
  exit 8
fi

rm -rf /root/.m2/repository/com/xinyartech/xinya_*
rm -rf /root/workspace/xinya_erp/xinya_product/target/
rm -rf /root/workspace/xinya_erp/xinya_web/target

cd /root/workspace/xinya_erp/
git pull
git checkout $1
sleep 1
git pull
sleep 1

#获取上次git pull时间
dataline=$(cat /root/shell/datetime/testdatetime.txt)
if [ "$1" == "erp-ct-hotfix-v1" ];then
  dataline=$(cat /root/shell/datetime/datetime-ct-hotfix.txt)
fi
echo $dataline

#git log --graph --after="$dataline" --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --date=iso > /root/shell/tmp.log
git log --after="$dataline" --pretty=format:"%ai , %an: %s" > /root/shell/tmp.log
tmplog=$(cat /root/shell/tmp.log)
len=$(ls -l /root/shell/tmp.log | awk '{ print $5 }')
#echo $len

#存储git pull时间
pulltime=`date +"%Y-%m-%d %H:%M:%S"`
echo $pulltime > /root/shell/datetime/testdatetime.txt

#拉取有日志内容保存到文件中
if [ $len -gt 0 ]; then
  #git log --graph --after="$dataline" --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset %an' --date=iso > /root/shell/git$1.log
  echo ' ' >> /www/html/attachment/git$1log.txt
  echo ' ' >> /www/html/attachment/git$1log.txt
  echo '=============================================='$pulltime'=====================================================' >> /www/html/attachment/git$1log.txt
  git log --after="$dataline" --pretty=format:"%ai , %an: %s" >> /www/html/attachment/git$1log.txt 
  exit 8
fi

 

posted on 2020-04-07 14:01  Ruthless  阅读(424)  评论(0编辑  收藏  举报