-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit-task-done
executable file
·72 lines (57 loc) · 1.57 KB
/
git-task-done
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
#!/bin/bash
set -e
source "${0%[\\/]*}"/_git-common.sh
main=$(git rev-parse --abbrev-ref origin/HEAD | cut -f2 -d/)
curtask=$1
if [ "" == "$1" ]; then
curtask=$(git rev-parse --abbrev-ref HEAD)
if [ $main == $curtask ]; then
echo "Specify a task name to mark done or --continue to continue merging"
exit 1
fi
fi
git task-sync
remote=$(git config "branch.$main.remote")
taskfile="$(git rev-parse --git-dir)/TASK_NAME"
if [ "--continue" != "$1" ]; then
task=$curtask
if [[ $task == task-* ]]; then
task=${task:5}
fi
stat=`git task-status $task`
if [[ $stat != *env-* ]]; then
if [[ $2 == --force ]]; then
echo "Task is not in testing, marking it done anyway"
else
echo "Task is not in testing, run git task-test first or use --force"
exit 1
fi
fi
echo $task > $taskfile
echo Marking "'"task-$task"'" done
git checkout $main
if ! git merge --no-ff --no-edit -m "Mark task-$task done" $remote/task-$task
then
echo " - Fix the merge conflicts"
echo " - run 'git add -A' or 'git add <file>'"
echo " - run 'git commit'"
echo " - run 'git task-done --continue'"
exit 1
fi
else
task=`cat $taskfile`
fi
if [[ $2 != --force ]]; then
env=`expr "$stat" : 'testing on env-\(.*\)'`
tasks=`git branch -r --list $remote/task\* | cut -f2- -d/ | cut -f2- -d-`
for curtask in $tasks; do
curstat=`git task-status $curtask`
if [ "merged in env-$env" == "$curstat" ]; then
git push $remote :task-$curtask
git branch -d task-$curtask || true
fi
done
fi
git push $remote $main :task-$task
git branch -d task-$task || true
rm $taskfile