-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbulkcommit.sh
executable file
·51 lines (44 loc) · 1.87 KB
/
bulkcommit.sh
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
##This Shell Script is for creating bulk commits on the fly. ##
## Current Working Directory ##
echo "Present Working Directory is >> "$PWD
#I need to write code logic for deleting/creating folders for the bulk commit
echo "Do you want to re-create(previous data will be shreaded) 'BulkCommitDir' folder? (y/n) >> "
read createNewDirectoryFlag
if [ ${createNewDirectoryFlag} == "y" ] || [ ${createNewDirectoryFlag} == "yes" ]; then
#echo "your answer is '$createNewDirectoryFlag'"
directoryRecreateCmd="rm -rf BulkCommitDir && mkdir BulkCommitDir"
echo "Recreating 'BulkCommitDir' folder........."
eval "$directoryRecreateCmd"
else
echo "Folder Recreation skipped...."
fi
# Function to create multiple commits
createNewCommits() {
x=1
while [ $x -le $totalCommitCount ]; do
echo "------- Creating File -------> $x"
current_time=$(date "+%Y_%m_%d_%H_%M_%s")
echo "Current Time : $current_time"
command="echo 'randfile_$x_$current_time' >> BulkCommitDir/randfile_'$x'_$current_time.txt && git add . && git commit -m '$x:randfile_$current_time.txt'"
echo $command
eval "$command"
latestCommitSHAValueCommand="git rev-parse HEAD"
echo "Latest Commit SHA >> '$latestCommitSHAValueCommand'"
eval "$latestCommitSHAValueCommand"
x=$(($x + 1))
sleep .001
# echo "\tWaiting for 1 sec."
done
}
# Conditional Check for the total commits to be done.
echo "Enter, How many new commits you want? "
read totalCommitCount
if [ ${totalCommitCount} -le 0 ]; then
echo "Zero or Negative Input, No commits to happen."
elif [ ${totalCommitCount} -gt 5000 ]; then
echo "Input is more than 5000, Please input a positive integer less than 5000"
else
echo "'${totalCommitCount}' new commits in progress."
createNewCommits
echo "'${totalCommitCount}' new commits are created..... "
fi