-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcommit-windows.sh
More file actions
executable file
·85 lines (66 loc) · 2.59 KB
/
commit-windows.sh
File metadata and controls
executable file
·85 lines (66 loc) · 2.59 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# Retrieve the current Git user name and email address
git_user_name=$(git config user.name)
git_user_email=$(git config user.email)
friday="5"
saturday="6"
sunday="7"
################################################
# You can change these variables to change the start and end dates of the commits
start_date="2024-04-06"
end_date="2024-07-18"
# You can choose to exclude certain days of the week from having commits. You can exclude up to 3 days.
exclude_days=("$saturday" "$friday")
# Other examples
# exclude_days=("$friday" "$saturday")
# exclude_days=("$friday" "$saturday" "$sunday")
################################################
# Create the text file
filename="commits.txt"
touch "$filename"
# Set the current date as "start date". This will change as we loop through each day of the year
current_date="$start_date"
# Loop through each day of the year
while [ "$current_date" != "$end_date" ]; do
# Get the day of the week (1-7, where 1 is Monday and 7 is Sunday)
day_of_week=$(date -d "$current_date" +"%u")
# Check if the day is not in the exclude_days array
if [ "$day_of_week" != "${exclude_days[0]}" ] && [ "$day_of_week" != "${exclude_days[1]}" ] && [ "$day_of_week" != "${exclude_days[2]}" ]; then
# Generate a random number between 1 and 100
random_num=$((RANDOM % 100 + 1))
# Set num_changes based on the probability distribution
if [ "$random_num" -le 30 ]; then
num_changes=0
elif [ "$random_num" -le 55 ]; then
num_changes=1
elif [ "$random_num" -le 75 ]; then
num_changes=2
elif [ "$random_num" -le 90 ]; then
num_changes=3
else
num_changes=4
fi
# Make the specified number of changes
for ((i = 1; i <= num_changes; i++)); do
# Add a character to the text file
echo "a" >> "$filename"
# Add the file to Git
git add "$filename"
# Set the commit date with the correct format
commit_date="${current_date}T00:00:00"
# Commit the changes to Git with the current date as the commit date and set the Git user name and email
GIT_AUTHOR_DATE="$commit_date" \
GIT_COMMITTER_DATE="$commit_date" \
GIT_AUTHOR_NAME="$git_user_name" \
GIT_AUTHOR_EMAIL="$git_user_email" \
GIT_COMMITTER_NAME="$git_user_name" \
GIT_COMMITTER_EMAIL="$git_user_email" \
git commit -m "Change $i on $current_date"
done
fi
# Increment the date by one day
current_date=$(date -d "$current_date + 1 day" +"%Y-%m-%d")
done
git push origin main
rm "$filename"
echo -e "\033[32m\n########\nDone! Go to your Github profile and enjoy your greens!\n#########\033[0m"