auto-sync: 2026-03-26 00:39:54
This commit is contained in:
+12
-13
@@ -29,19 +29,8 @@ fi
|
||||
|
||||
echo "[$(date)] git pull success" >> "$LOG_FILE"
|
||||
|
||||
# 第二步:检查本地是否有变更
|
||||
git diff --quiet
|
||||
exit_code=$?
|
||||
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
# 没有变更,正常退出
|
||||
echo "[$(date)] No local changes, exiting." >> "$LOG_FILE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 有变更,进行提交
|
||||
echo "[$(date)] Step 2: Found local changes, committing..." >> "$LOG_FILE"
|
||||
|
||||
# 第二步:添加所有变更(包括未跟踪文件)
|
||||
echo "[$(date)] Step 2: Adding all changes..." >> "$LOG_FILE"
|
||||
git add .
|
||||
exit_code=$?
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
@@ -49,6 +38,16 @@ if [ $exit_code -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 第三步:检查是否有内容需要提交
|
||||
if git diff --cached --quiet; then
|
||||
# 没有变更需要提交,正常退出
|
||||
echo "[$(date)] No changes to commit, exiting." >> "$LOG_FILE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 有变更,进行提交
|
||||
echo "[$(date)] Step 3: Found changes to commit, committing..." >> "$LOG_FILE"
|
||||
|
||||
git commit -m "auto-sync: $(date '+%Y-%m-%d %H:%M:%S')"
|
||||
exit_code=$?
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
|
||||
Reference in New Issue
Block a user