gpt4 book ai didi

linux - 检查 git 提交是否是一天的第一天的脚本

转载 作者:太空宇宙 更新时间:2023-11-04 11:10:49 25 4
gpt4 key购买 nike

任务如下:

  • 在构建服务器 (travis-ci) 上,我想检查推送是否是白天的第一次
  • 如果是,将主分支复制到另一个分支(每日快照)

最好的问候

最佳答案

在构建脚本的末尾,您可以将日期转储到文件中。一开始,你可以比较一下。它可能看起来像:

currentDate=$(date +%D)
isFirstBuildOfTheDay=true

if [ -e last_date_build.txt ]; then
if [ $currentDate = $(cat last_date_build.txt) ]; then
isFirstBuildOfTheDay=false
fi
fi

if $isFirstBuildOfTheDay; then
#Take a daily snapshot
fi

#Perform the actual build

echo $currentDate > last_date_build.txt

编辑以考虑评论:

如果你不能保留文件,将这个日期记录在标签上怎么样?

例如:

currentDate=$(date +%F)
dailyTag=daily_$currentDate
if ! git rev-parse $tag >/dev/null 2>&1; then
#Take a daily snapshot
git tag $dailyTag
git push --tags
fi

关于linux - 检查 git 提交是否是一天的第一天的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23322014/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com