-
Notifications
You must be signed in to change notification settings - Fork 100
/
.update
executable file
·145 lines (98 loc) · 2.7 KB
/
.update
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
#=========================================================================
# .update [options]
#=========================================================================
#
# -h Display this message
# -v Verbose mode
#
# Update the current public release from the correct branch in the
# labs repo.
#
# Author : Christopher Batten
# Date : August 28, 2015
#-------------------------------------------------------------------------
# Command line parsing
#-------------------------------------------------------------------------
function usage
{
echo ""
sed -n '3p' $0 | sed -e 's/#//'
sed -n '5,/^$/p' $0 | sed -e 's/#//'
exit 1
}
verbose=no
while getopts "hv" OPTION; do
case $OPTION in
v) verbose=yes ;;
h|?) usage ;;
esac
done
#-------------------------------------------------------------------------
# source branch
#-------------------------------------------------------------------------
src_branch="tut3-pymtl"
#-------------------------------------------------------------------------
# main
#-------------------------------------------------------------------------
echo ""
# Make sure working directory is not dirty
echo " - make sure working directory not dirty"
# if ( git diff --quiet ); then
# echo ""
# echo " ERROR: Dirty working directory"
# echo ""
# exit 1
# fi
# Make sure script is run in root of repo
echo " - make sure script is run in root of repo"
if [[ ! -f ".update" ]]; then
echo ""
echo " ERROR: Must run this script in root of repo"
echo ""
exit 1
fi
# Save current path
echo " - save current path"
topdir=${PWD}
# Remove all content
echo " - remove all content"
rm -rf .gitignore
rm -rf .travis.yml
rm -rf *
# Get last commit
echo " - get last commit"
last_commit=$(head -1 .changelog | cut -f1 -d' ')
# Clone labs repo
echo " - clone labs repo"
git clone git@github.com:cornell-ece4750/ece4750-labs \
--branch ${src_branch} upstream
# Create changelog
echo " - create changelog"
git --git-dir=${topdir}/upstream/.git \
log --oneline --no-color > .changelog
# Create commit message
echo " - create commit message"
echo "automated update" > .commitmsg
echo "" >> .commitmsg
git --git-dir=${topdir}/upstream/.git \
log --oneline --no-color ${last_commit}..HEAD >> .commitmsg
# Remove upstream git repo
echo " - remove upstream git repo"
rm -rf ${topdir}/upstream/.git
# Move all content from upstream
echo " - move all content from upstream"
shopt -s dotglob
mv ${topdir}/upstream/* ${topdir}
# Remove upstream
echo " - remove upstream"
rm -rf ${topdir}/upstream
# Commit changes
echo " - commit changes"
git add .
git rm --cached .commitmsg
git commit --file=.commitmsg
rm -rf .commitmsg
# exit
echo ""
exit 0