forked from dosemu2/dosemu2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unmake-tag.sh
executable file
·48 lines (44 loc) · 1002 Bytes
/
unmake-tag.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
#!/usr/bin/env bash
MWT=`git worktree list --porcelain | grep -B 3 "heads/master" | grep worktree \
|cut -d " " -f 2`
DWT=`git worktree list --porcelain | grep -B 3 "heads/devel" | grep worktree \
|cut -d " " -f 2`
if [ -n "$MWT" ]; then
# unfortunately git does not allow checking out the branch that
# has a work-tree elsewhere
pushd "$MWT"
else
BR=`git rev-parse --abbrev-ref HEAD`
if [ "$BR" != "master" ]; then
echo "Not on master branch"
exit 1
fi
fi
REV=`git log -1 | grep merge | sed -e 's/.*merge \([^ ]\+\).*/\1/'`
if [ -z "$REV" ]; then
echo "No merge commit found"
exit 1
fi
if ! git diff-files --quiet; then
echo "Work tree is not clean"
exit 1
fi
echo "Undoing $REV"
git reset --h HEAD^
if [ -n "$MWT" ]; then
popd
fi
git tag -d $REV
git tag -d $REV-dev
if [ -n "$DWT" ]; then
pushd "$DWT"
else
if ! git checkout devel; then
echo "Cannot checkout devel"
exit 1
fi
fi
git reset --h HEAD^
if [ -n "$DWT" ]; then
popd
fi