-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitvb-is-unpickable
executable file
·52 lines (44 loc) · 1.62 KB
/
gitvb-is-unpickable
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
#!/usr/bin/env bash
set -e
GITVB_HOME="./.git/.gitvb-v0"
MAIN_BRANCH="${MAIN_BRANCH:-main}"
if [ -z "$1" ]; then
echo "usage: gitvb-is-unpickable <branch>"
exit 1
fi
# if you're unpicking you shouldn't have staged changes since we don't check your stage here
if [ ! -z "$(git diff --staged)" ]; then
echo "there are staged changes. exiting."
exit 1
fi
branch="$1"
files="$(git diff --name-only)"
picked="$(gitvb-ls)"
stashAdvice=""
if [ ! -z "$files" ]; then
while IFS= read -r file; do
# check what branch this file belongs to:
while IFS= read -r branch; do
if gitvb-is-changed-by-branch $file $branch 2> /dev/null; then
echo
echo "cannot unpick this. your working tree builds upon the work of one of your picked branches."
echo "i.e. $file is modified on '$branch' but also in your tree"
echo ""
echo "if gitvb just blindly stashed the changes, they may not reapply onto the tree"
echo "after unpicking this branch, so we can't safely do anything automatically."
echo
echo "current working tree includes:"
gitvb-pretty-changelist "$(git diff --name-only)"
echo
echo "the minimum to continue unpicking is:"
echo ""
echo " $ git stash -m 'work on top of $branch' -- $file"
echo ""
echo "if you wish to continue unpicking"
echo ""
exit 1
fi
done <<< "$picked"
done <<< "$files"
echo "unpick lgtm!"
fi