/
make-dev
executable file
·47 lines (34 loc) · 1004 Bytes
/
make-dev
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
#!/bin/bash
commit_mes=$1
if [ ".$commit_mes" = "." ]; then
echo "usage: $0 <commit-message>"
exit 1
fi
src_branch=mix
dst_branch=dev
cur_hash=$(git log -n1 --format="%H")
cur_branch=$(./_script/_git_branch)
if [ ".$cur_branch" = "." ]; then
echo "not on a branch"
exit 1
fi
src_tree_hash=$(git cat-file -p $src_branch | head -n1 | awk '{print $2}')
changelog="$(./_script/build-d/make-change-log)"
mes="$commit_mes
$changelog
x-update-from: $src_branch $cur_hash"
new_commit_hash=$(echo "$mes" | git commit-tree $src_tree_hash -p $dst_branch)
git checkout $dst_branch \
&& \
if [ ".$changelog" = "." ]; then
all_changelog="$(cat changelog.md 2>/dev/null)"
else
all_changelog="$changelog
$(cat changelog.md 2>/dev/null)"
fi \
&& git merge --ff-only $new_commit_hash \
&& echo "$all_changelog" >changelog.md \
&& git add changelog.md \
&& git commit --amend --no-edit -m "$mes" \
|| git reset HEAD^
git checkout $cur_branch