Skip to content

Commit 279ccc7

Browse files
committed
gitsync before you deploy
1 parent 43e4b5a commit 279ccc7

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

deploy.sh

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -euo pipefail
44

5+
./gitsync.sh
6+
57
# Use -B to keep gh-pages at most one commit ahead of master.
68
# This leads to the use of -f when pushing to gh-pages on remote.
79
# This might actually be one descent use of git push -f..

gitsync.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2016 Oleks <oleks@oleks.info>
4+
# See also https://github.com/oleks/gitsync
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
24+
set -euo pipefail
25+
26+
failcode=1
27+
28+
nlines=$(git status . --porcelain | wc -l)
29+
if [ ${nlines} -ne 0 ] ; then
30+
cat <<EOF
31+
#####################################################
32+
# Nice! You have changes. Now commit or stash them. #
33+
#####################################################
34+
EOF
35+
git status .
36+
exit ${failcode}
37+
fi
38+
39+
echo "Let me check your remote.."
40+
git remote update
41+
42+
gitstatus=$(git status .)
43+
set +e
44+
echo "${gitstatus}" | grep "Your branch is up-to-date" >/dev/null
45+
code=$?
46+
set -e
47+
48+
if [ ${code} -ne 0 ] ; then
49+
cat <<EOF
50+
#####################################
51+
# Nice! You have commits. Now push. #
52+
#####################################
53+
EOF
54+
git status .
55+
exit ${failcode}
56+
fi
57+
58+
echo "Looks like you are up-to-date."

0 commit comments

Comments
 (0)