-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathguppy
More file actions
executable file
·58 lines (47 loc) · 1.28 KB
/
Copy pathguppy
File metadata and controls
executable file
·58 lines (47 loc) · 1.28 KB
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
# Pull fresh code from upstream master, push to origin master
UPSTREAM=$(git remote -v | grep '^upstream\>.\+(fetch)$')
if [ -z "$UPSTREAM" ]; then
echo "You need to be in a git repo with a fetchable \"upstream\" remote!"
exit 1
fi
ORIGIN=$(git remote -v | grep '^origin\>.\+(push)$')
if [ -z "$ORIGIN" ]; then
echo "You need to be in a git repo with a pushable \"origin\" remote!"
exit 1
fi
on_exit () {
if [ -n "$ON_BRANCH" ]; then
echo "Switching back to $ON_BRANCH..."
git checkout "$ON_BRANCH"
fi
if [ -n "$GIT_STASH" ]; then
echo "Restoring stash..."
git stash pop
fi
}
trap on_exit EXIT
GIT_STASH=$(git status --porcelain | grep -v '^??')
if [ -n "$GIT_STASH" ]; then
echo "Stashing current state..."
git stash
fi
ON_MASTER=$(git branch | grep '^* master$')
ON_BRANCH=""
if [ -z "$ON_MASTER" ]; then
ON_BRANCH=$(git branch | grep '^* ' | sed 's/^* //')
echo "Switching to master..."
git checkout master
if [ $? -ne 0 ]; then
echo "Failed to checkout master!?"
exit 1
fi
fi
# Now we're on master in a clean state; push and pull away
git pull --ff-only upstream master
if [ $? -ne 0 ]; then
echo "Could not pull cleanly into your master branch... you will need to manually merge changes from upstream."
exit 1
fi
git submodule update
git push origin master