-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6_commit-result-files.sh
109 lines (91 loc) · 3.24 KB
/
6_commit-result-files.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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
# Prompt user to input the file type
# Determine the glob patterns used to filter target files
while true; do
echo "Enter file type [dump/force/rerun/restart]:"
read -r filetype
case $filetype in
dump)
dirname="dumpfiles" # Default directory name
aliasdir="dump_files" # Alias directory name
fileprefix="dump.cutsic." # File name prefix
filesuffix=".lammpstrj.gz*" # File name suffix
break;;
force)
dirname="force_files"
aliasdir="dump*force" # Support using the * wildcard
fileprefix="dump.force.cut_sic."
filesuffix=".gz*" # Support using the * wildcard
break;;
rerun)
dirname="rerun_files"
aliasdir="dump_rerun"
fileprefix="dump.rerun.cut_sic."
filesuffix=".gz*" # Support using the * wildcard
break;;
restart)
dirname="restart_files"
aliasdir="restart"
fileprefix="cut_sic.restart."
filesuffix="" # Support using the * wildcard
break;;
*)
echo "Invalid input"
;;
esac
done
# Prompt user to input the cutting speed
while true; do
echo "Enter the cutting speed [1-3]:"
read -r speed
if [[ "$speed" =~ ^[1-3]$ ]]; then
break
else
echo "Invalid input"
fi
done
# Rename alias directory to the default name
if [[ ! -d "$dirname" ]] && ls -d "$aliasdir" 1> /dev/null 2>&1; then
mv "$aliasdir/" "$dirname/"
fi
# Create commits according to the user inputs
# Determine the number of iterations required to commit all files based on cutting speed
if [[ -n "$dirname" && -n "$fileprefix" && ("$filetype" == "restart" || -n "$filesuffix" ) ]]; then
echo "git add ${dirname}/*"
git add "${dirname}/${fileprefix}0${filesuffix}"
git add "${dirname}/${fileprefix}[0-9]00${filesuffix}"
git add "${dirname}/${fileprefix}[0-9][0-9]00${filesuffix}"
git commit -m "Add ${filetype} files (index < 9000)"
if [ "$speed" -eq 1 ]
then
for i in {1..39}
do
git add "${dirname}/${fileprefix}${i}[0-9][0-9]00${filesuffix}"
git commit -m "Add ${filetype} files (index < ${i}9900)"
done
git add "${dirname}/${fileprefix}40[0-9][0-9]00${filesuffix}"
git commit -m "Add last ${filetype} file (400000)"
elif [ "$speed" -eq 2 ]
then
for i in {1..19}
do
git add "${dirname}/${fileprefix}${i}[0-9][0-9]00${filesuffix}"
git commit -m "Add ${filetype} files (index < ${i}9900)"
done
git add "${dirname}/${fileprefix}20[0-9][0-9]00${filesuffix}"
git commit -m "Add last ${filetype} file (200000)"
elif [ "$speed" -eq 3 ]
then
for i in {1..12}
do
git add "${dirname}/${fileprefix}${i}[0-9][0-9]00${filesuffix}"
git commit -m "Add ${filetype} files (index < ${i}9900)"
done
git add "${dirname}/${fileprefix}13[0-2][0-9]00${filesuffix}"
git commit -m "Add ${filetype} files (index < 132900)"
git add "${dirname}/${fileprefix}13[0-9][0-9]00${filesuffix}"
git commit -m "Add last ${filetype} file (133000)"
else
echo "Invalid input. Please enter a number from 1 to 3."
fi
fi