forked from SchildiChat/SchildiChat-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge_helpers.sh
executable file
·58 lines (52 loc) · 1.43 KB
/
merge_helpers.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
#!/bin/bash
find_last_commit_for_title() {
local title="$1"
git log --oneline --author=SpiritCroc | grep "$title" | head -n 1 | sed 's| .*||'
}
revert_last() {
local title="$1"
git revert --no-edit `find_last_commit_for_title "$title"`
}
require_clean_git() {
if [ "$NO_REQUIRE_CLEAN_GIT" = "y" ]; then
return
fi
uncommitted=`git status --porcelain`
if [ ! -z "$uncommitted" ]; then
echo "Uncommitted changes are present, please commit first!"
exit 1
fi
}
upstream_latest_tag() {
git describe --abbrev=0 upstream/master --tags
}
upstream_previous_tag() {
git describe --abbrev=0 `upstream_latest_tag`~1 --tags
}
downstream_latest_tag() {
local commit="HEAD"
while true; do
local tag=`git describe --abbrev=0 "$commit" --tags`
if [[ "$tag" =~ "sc_" ]]; then
echo "$tag"
break
else
commit="$commit^1"
fi
done
}
upstream_diff() {
local latest_tag=`upstream_latest_tag`
local previous_tag=`upstream_previous_tag`
git diff "$previous_tag".."$latest_tag" "$@"
}
upstream_log() {
local latest_tag=`upstream_latest_tag`
local previous_tag=`upstream_previous_tag`
git log "$previous_tag".."$latest_tag" "$@"
}
downstream_upstream_diff() {
local previous_tag=`upstream_previous_tag`
local downstream_tag=`downstream_latest_tag`
git diff "$previous_tag".."$downstream_latest_tag" "$@"
}