@@ -86,6 +86,12 @@ ALLOW_DIRTY=false
86
86
COMMIT_METHOD=" none"
87
87
START_REVISION=" master"
88
88
TEST_ONLY=false
89
+ VERBOSE=false
90
+
91
+ # Default to verbose operation if this isn't an interactive build.
92
+ if [[ ! -t 1 ]]; then
93
+ VERBOSE=true
94
+ fi
89
95
90
96
while [[ $# -gt 0 ]]; do
91
97
case " $1 " in
@@ -114,6 +120,10 @@ while [[ $# -gt 0 ]]; do
114
120
COMMIT_METHOD=message
115
121
;;
116
122
123
+ --verbose)
124
+ VERBOSE=true
125
+ ;;
126
+
117
127
--test-only)
118
128
# In test-only mode, no changes are made, so there's no reason to
119
129
# require a clean source tree.
@@ -122,10 +132,9 @@ while [[ $# -gt 0 ]]; do
122
132
;;
123
133
124
134
* )
125
- if git rev-parse " $1 " >& /dev/null; then
126
- START_REVISION=" $1 "
127
- break
128
- fi
135
+ START_REVISION=" $1 "
136
+ shift
137
+ break
129
138
;;
130
139
esac
131
140
shift
@@ -149,14 +158,40 @@ if ! git diff-index --quiet HEAD --; then
149
158
fi
150
159
fi
151
160
152
- # Record actual start, but only if the revision is specified as a single
153
- # commit. Ranges specified with .. or ... are left alone.
161
+ # Show Travis-related environment variables, to help with debuging failures.
162
+ if [[ " ${VERBOSE} " == true ]]; then
163
+ env | egrep ' ^TRAVIS_(BRANCH|COMMIT|PULL)' | sort || true
164
+ fi
165
+
166
+ # When travis clones a repo for building, it uses a shallow clone. When
167
+ # building a branch it can sometimes give a revision range that refers to
168
+ # commits that don't exist in the shallow clone. This has been observed in a
169
+ # branch build where the branch only has a single commit. The cause of this
170
+ # behavior is unclear but as a workaround ...
154
171
if [[ " ${START_REVISION} " == * ..* ]]; then
172
+ RANGE_START=" ${START_REVISION/ ..*/ } "
173
+ RANGE_END=" ${START_REVISION/* ../ } "
174
+
175
+ # Figure out if we have access to master. If not add it to the repo.
176
+ if ! git rev-parse origin/master >& /dev/null; then
177
+ git remote set-branches --add origin master
178
+ git fetch origin
179
+ fi
180
+
181
+ NEW_RANGE_START=$( git merge-base origin/master " ${RANGE_END} " )
182
+ START_REVISION=" ${START_REVISION/ $RANGE_START / $NEW_RANGE_START } "
183
+
155
184
START_SHA=" ${START_REVISION} "
185
+
156
186
else
157
187
START_SHA=$( git rev-parse " ${START_REVISION} " )
158
188
fi
159
189
190
+ if [[ " ${VERBOSE} " == true ]]; then
191
+ echo " START_REVISION=$START_REVISION "
192
+ echo " START_SHA=$START_SHA "
193
+ fi
194
+
160
195
# If committing --fixup, avoid messages with fixup! fixup! that might come from
161
196
# multiple fixup commits.
162
197
HEAD_SHA=$( git rev-parse HEAD)
0 commit comments