-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgo-auto.sh
More file actions
executable file
·63 lines (49 loc) · 1.52 KB
/
go-auto.sh
File metadata and controls
executable file
·63 lines (49 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# go-auto.sh - Fully automated script to run tests, commit, and push changes
# Created by Kent Beck with Augment AI
# Set -e to exit immediately if any command fails
set -e
# Print a message with a border
print_message() {
local message="$1"
local length=${#message}
local border=$(printf '=%.0s' $(seq 1 $((length + 4))))
echo ""
echo "$border"
echo " $message"
echo "$border"
echo ""
}
# Step 1: Run tests
print_message "STEP 1: Running tests"
npm test
# If tests pass, proceed to commit
if [ $? -eq 0 ]; then
print_message "STEP 2: Tests passed! Staging all changes"
# Stage all changes
git add .
# Generate a commit message based on the changes
print_message "STEP 3: Creating commit"
# Get a summary of changes for the commit message
changed_files=$(git diff --cached --name-only)
file_count=$(echo "$changed_files" | wc -l | tr -d ' ')
# Create a commit message based on the changes
if [ $file_count -eq 1 ]; then
# Single file change
file=$(echo "$changed_files" | tr -d '\n')
commit_message="Update $file"
else
# Multiple file changes
commit_message="Update BitBLT implementation ($file_count files)"
fi
echo "Using commit message: $commit_message"
# Commit the changes
git commit -m "$commit_message"
# Push to remote
print_message "STEP 4: Pushing to remote"
git push origin main
print_message "SUCCESS: All steps completed successfully!"
else
print_message "ERROR: Tests failed. Fix the issues before committing."
exit 1
fi