Skip to content

Commit

Permalink
完成添加任意提交的脚本, 新年快乐
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuangcp committed Feb 16, 2018
1 parent afe3aa2 commit 1808dec
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions shell/create_commit.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/dash

# 本质上就是一条命令的事, 写脚本是为了方便处理时间而已
get_file_url(){
echo "开始寻找项目根目录..."
current_path=`pwd`
Expand All @@ -16,39 +16,50 @@ get_file_url(){
break
fi
done
echo '项目绝对路径: '`pwd`
date=`date -R`
echo $date
cd `pwd` && GIT_AUTHOR_DATE="$date" GIT_COMMITTER_DATE="$date" git commit -m ' update thisDate';

# echo '项目绝对路径: '`pwd`
}
# 创建提交
create_commit(){

# echo '项目绝对路径: '`pwd`
# echo $1'__'$2
date=$1
echo "$date" > ignore
get_file_url && cd `pwd` && git add * \
&& GIT_AUTHOR_DATE="$date" GIT_COMMITTER_DATE="$date" git commit -m ' daily update';
}

case $1 in
-h | h | help)
start='\033[0;32m'
end='\033[0m'
echo "运行:dash check_commit.sh $start <params> $end"
printf " $start%-16s$end%-20s\n" "-h|h|help" "帮助"
printf " $start%-16s$end%-20s\n\t%-20s\n" "-qu|qu|quantum <quantum> <startTime>" "按时间段提交; 参数1:时间长度,默认1天; 参数2: 开始时间,默认当天; 参数3:提交量,默认为1;" "例如 -qu 3 2 2 表示: 连续提交3天(含起点时间往前推),起点时间是2天前, 每天提交两次"
printf " $start%-16s$end%-20s\n\t%-20s\n\t%-20s\n" "-qu|qu|quantum <quantum> <startTime> <commitNum>" \
"按时间段提交; " "参数1:时间长度,默认1天; 参数2: 开始时间,默认当天; 参数3:提交量,默认为1;" \
"例如 -qu 3 2 2 表示: 连续提交3天(含起点时间往前推),起点时间是2天前, 每天提交两次"
;;
-qu | qu | quantum)
quantum=$2
startTime=$3
commitNum=$4

if [ "$quantum"z = "z" ]; then
quantum=1
fi
if [ "$startTime"z = "z" ]; then
startTime=0
fi
if [ "$commitNum"z = "z" ]; then
commitNum=1
fi
date --date=$startTime' day ago' -R
for i in `seq 10`
do

for i in `seq $quantum`; do
temp=$(( $startTime + $i - 1))
for k in `seq $commitNum`; do
currentDay=`date --date=$temp' day ago - '$k'min ago' -R`
create_commit "$currentDay"
done
done
;;
esac
;;
# *)
# echo 23333;;
esac

0 comments on commit 1808dec

Please sign in to comment.