|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PROJECT_DIR="$HOME/llm-mail-trainer" |
|
|
LOG_DIR="$PROJECT_DIR/scheduler_logs" |
|
|
LOG_FILE="$LOG_DIR/commits.log" |
|
|
REMOTE="hf" |
|
|
|
|
|
|
|
|
mkdir -p "$LOG_DIR" |
|
|
|
|
|
|
|
|
log() { |
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE" |
|
|
} |
|
|
|
|
|
|
|
|
get_commit_message() { |
|
|
local messages=( |
|
|
"chore: Update project files" |
|
|
"docs: Minor documentation updates" |
|
|
"refactor: Code cleanup" |
|
|
"style: Format improvements" |
|
|
"chore: Regular maintenance" |
|
|
"docs: Improve comments" |
|
|
"chore: Sync changes" |
|
|
"refactor: Minor optimizations" |
|
|
) |
|
|
local idx=$((RANDOM % ${#messages[@]})) |
|
|
echo "${messages[$idx]}" |
|
|
} |
|
|
|
|
|
|
|
|
main() { |
|
|
log "=== Starting auto-commit scheduler ===" |
|
|
|
|
|
cd "$PROJECT_DIR" || { |
|
|
log "ERROR: Cannot access $PROJECT_DIR" |
|
|
exit 1 |
|
|
} |
|
|
|
|
|
|
|
|
if git diff --quiet && git diff --cached --quiet; then |
|
|
log "No changes to commit" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else |
|
|
log "Changes detected, preparing commit..." |
|
|
fi |
|
|
|
|
|
|
|
|
git add -A |
|
|
|
|
|
|
|
|
if git diff --cached --quiet; then |
|
|
log "Nothing staged to commit" |
|
|
exit 0 |
|
|
fi |
|
|
|
|
|
|
|
|
BRANCH=$(git branch --show-current) |
|
|
log "Current branch: $BRANCH" |
|
|
|
|
|
|
|
|
COMMIT_MSG=$(get_commit_message) |
|
|
git commit -m "$COMMIT_MSG" >> "$LOG_FILE" 2>&1 |
|
|
|
|
|
if [ $? -eq 0 ]; then |
|
|
log "β
Committed: $COMMIT_MSG" |
|
|
|
|
|
|
|
|
git push "$REMOTE" "$BRANCH" >> "$LOG_FILE" 2>&1 |
|
|
|
|
|
if [ $? -eq 0 ]; then |
|
|
log "β
Pushed to $REMOTE/$BRANCH" |
|
|
|
|
|
|
|
|
log "π Syncing model files..." |
|
|
cd "$PROJECT_DIR" |
|
|
source venv/bin/activate 2>/dev/null |
|
|
python scripts/sync_models.py >> "$LOG_FILE" 2>&1 |
|
|
log "β
Model sync complete" |
|
|
else |
|
|
log "β Push failed" |
|
|
fi |
|
|
else |
|
|
log "β Commit failed" |
|
|
fi |
|
|
|
|
|
log "=== Scheduler complete ===" |
|
|
} |
|
|
|
|
|
|
|
|
main |
|
|
|