-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_patch_for_folder.sh
More file actions
99 lines (67 loc) · 1.95 KB
/
Copy pathcreate_patch_for_folder.sh
File metadata and controls
99 lines (67 loc) · 1.95 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
#
# !!!Please change git commands for your system.!!!
cd petel41
path="question/type/numerical"
#path="question/type/formulas"
#path="theme/boost_union"
#path="mod/quiz/report/advancedoverview"
# Revert git.
git reset --hard
git checkout prod_m41
git branch -D dev_m41X_petel
git branch dev_m41X_petel
git checkout dev_m41X_petel
# =================================================================================================
# Clear screen
clear
# Variables
declare -a ARRAY_HASHES=()
Red='\033[0;31m'
Green='\033[0;32m'
Blue='\033[0;34m'
Orange='\033[0;33m'
NoColor='\033[0m' # No Color
# Get history hashes.
for sha1 in $(git log --format=format:%H -1000 -- $path); do :
ARRAY_HASHES+=("$sha1")
done
# Print hashes with description and autor.
for hash in "${ARRAY_HASHES[@]}"
do :
printf '\033[1A\033[K'
description=$(git log $hash --format="%B" -n 1)
if [[ "$description" == *"MDL-"* ]]; then
echo -e "${Blue} ${hash} ${Red}- ${description} ${NoColor}"
else
echo -e "${Blue} ${hash} ${Green}- ${description} ${NoColor}"
fi
author=$(git log $hash --format="%an (%ae)" -n 1)
echo -e "${Orange} ${author} ${NoColor}"
echo -e ""
# Wait for next commit.
read -r -p "Do you want next commit? Press enter or 'q' for quit: " response
if [[ "$response" == q ]]; then
break
fi
done
# Create patch.
printf '\033[1A\033[K'
echo -e ""
read -r -p "Please enter hash for create patch: " hashpatch
# Exit if empty string
if [ -z "$hashpatch" ]; then
exit
fi
# Reset soft to commit.
process=$(git reset --soft $hashpatch)
# Commit changes for patch.
commit="git commit -m '$path' -- $path"
process=$(${commit})
#process=$(git commit -m 'message' -- $path)
for sha2 in $(git log --format=format:%H -1 -- $path); do :
break
done
#echo "${sha2}"
git format-patch -1 $sha2
#git format-patch -o "C:/OpenServer1/domains" 5c9a2075aaa65a9ce26ca4b699c66c6689c40eca