-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhandle_cherry_pick_commit
executable file
·53 lines (49 loc) · 1.38 KB
/
handle_cherry_pick_commit
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
#!/bin/bash
#by haolong.zhang v0.1
function print_usage(){
echo Usage:
echo "$0 [from_branch] [need_dir] ...[need_file]..."
echo "eg:"
echo "$0 master modem_proc/ contents.xml "
echo "Nothing NONE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
}
function check_parameter_number(){
if [ $# -eq 0 ]
then
echo ">>>>>>>>>>>>>>>>>>Need some paramters<<<<<<<<<<<<<<<"
echo "find args="$#
echo "just show usage"
print_usage
exit 0
fi
}
function get_commit_really(){
rm input_for_cherry_pick.pre
echo "args="$@
git log --pretty=format:'%h ' $@ > just_commit.pre
#need a blank line at the end of just_commit.pre, so add below
echo >> just_commit.pre
n=$(awk 'END{print NR}' just_commit.pre)
for i in `seq $n`
do
echo $i
echo $n
hande_line=$(($n-$i+1))
echo "hande_line=$hande_line"
sed -n "$hande_line""p" just_commit.pre >> input_for_cherry_pick.pre
done
echo "resut below"
echo "orgin:"
echo "==============================================="
cat just_commit.pre
rm just_commit.pre
echo "==============================================="
echo "input for cherry pick:"
echo "==============================================="
cat input_for_cherry_pick.pre
echo "==============================================="
echo "you can use command to cherry-pick: cat input_for_cherry_pick.pre | xargs git cherry-pick"
}
#########################shell start here######################
check_parameter_number $@
get_commit_really $@