-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestore.sh
More file actions
83 lines (66 loc) · 3.07 KB
/
restore.sh
File metadata and controls
83 lines (66 loc) · 3.07 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
#!/bin/bash
# Set start and end date
START_DATE="2021-03-2" # YYYY-MM-DD
END_DATE="2021-04-24" # YYYY-MM-DD
# Min and max commits per selected day
MIN_COMMITS=1
MAX_COMMITS=3
# Min and max days per month to commit
MIN_DAYS_PER_MONTH=7
MAX_DAYS_PER_MONTH=13
# Set author and committer name and email
AUTHOR_NAME="Andrii"
AUTHOR_EMAIL="jastinmax999@gmail.com"
# Define an array of commit messages
commit_messages=(
"Fix: Resolve bug in authentication component"
"Feat: Add Google login support to authentication UI"
"Feat: Refactor user authentication components for better maintainability"
"Fix: Improve UI components for better UX and accessibility"
"Fix: Optimize Livewire component queries for performance"
"Fix: Correct issue with API response handling in Livewire components"
"Feat: Add new user profile UI components"
"Feat: Update dependencies and apply security patches"
"Fix: Fix broken links in documentation for TallCraftUI"
"Feat: Enhance performance of components for mobile responsiveness"
)
# Convert START_DATE to first day of the month
current_date=$(date -d "$START_DATE" +"%Y-%m-01")
# Loop through each month in the date range
while [[ "$current_date" < "$END_DATE" ]] || [[ "$current_date" == "$END_DATE" ]]; do
# Get number of days in the current month
days_in_month=$(date -d "$current_date +1 month -1 day" +"%d")
# Random number of commit days for the month
num_commit_days=$(( RANDOM % (MAX_DAYS_PER_MONTH - MIN_DAYS_PER_MONTH + 1) + MIN_DAYS_PER_MONTH ))
# Select random days in the month
commit_days=()
while [[ ${#commit_days[@]} -lt $num_commit_days ]]; do
random_day=$(( RANDOM % days_in_month + 1 ))
if [[ ! " ${commit_days[@]} " =~ " $random_day " ]]; then
commit_days+=("$random_day")
fi
done
# Make commits on selected random days
for day in "${commit_days[@]}"; do
commit_date=$(date -d "$current_date +$((day-1)) days" +"%Y-%m-%d")
# Random number of commits for the selected day
num_commits=$(( RANDOM % (MAX_COMMITS - MIN_COMMITS + 1) + MIN_COMMITS ))
for ((i=1; i<=num_commits; i++)); do
# Generate a random timestamp within the day
commit_time=$(date -d "$commit_date $((RANDOM % 24)):$((RANDOM % 60)):$((RANDOM % 60))" +"%Y-%m-%d %H:%M:%S")
# Pick a random commit message from the array
commit_message=${commit_messages[$RANDOM % ${#commit_messages[@]}]}
# Create or modify a file
echo "Commit on $commit_time" >> dummy.txt
# Add changes
git add .
# Commit with specific author details and timestamp
GIT_AUTHOR_NAME="$AUTHOR_NAME" GIT_AUTHOR_EMAIL="$AUTHOR_EMAIL" \
GIT_COMMITTER_NAME="$AUTHOR_NAME" GIT_COMMITTER_EMAIL="$AUTHOR_EMAIL" \
GIT_COMMITTER_DATE="$commit_time" GIT_AUTHOR_DATE="$commit_time" \
git commit -m "$commit_message"
done
done
# Move to the first day of the next month
current_date=$(date -d "$current_date +1 month" +"%Y-%m-01")
done