@@ -33,7 +33,26 @@ API_VER=$(curl -s https://raw.githubusercontent.com/oxidecomputer/opte/"$OPTE_RE
33
33
# use the total number of pages to get the total number of commits.
34
34
# Thus the query parameter `page` in the "last" link (e.g. `&page=162`)
35
35
# gives us the rev count we want.
36
- REV_COUNT=$( curl -I -s " https://api.github.com/repos/oxidecomputer/opte/commits?per_page=1&sha=$OPTE_REV " | sed -n ' /^[Ll]ink:/ s/.*"next".*page=\([0-9]*\).*"last".*/\1/p' )
36
+ #
37
+ # We should be resilient against a transient GitHub issue here. If GitHub gives
38
+ # any answer, we'll carry on trying to get a page number out, but we really
39
+ # shouldn't if we get a non-200 error. We could `curl -f` to fail for a 4xx or
40
+ # above status, but then the observed output when this fails would be an opaque
41
+ # "exited with status 22" or something. Help ourselves out and keep the response
42
+ # head, printing that if something goes sideways instead.
43
+ COMMIT_INFO_HEAD=" $( curl -I -s " https://api.github.com/repos/oxidecomputer/opte/commits?per_page=1&sha=$OPTE_REV " ) "
44
+ REV_COUNT=$( echo " $HEAD " | sed -n ' /^[Ll]ink:/ s/.*"next".*page=\([0-9]*\).*"last".*/\1/p' )
45
+
46
+ if [ -z " $REV_COUNT " ]; then
47
+ # We didn't get a OPTE rev out. The rev *should* exist, so it should not be
48
+ # a 404. If this is a 5xx, it might be a transient error from GitHub. In
49
+ # either case, errors are infrequent enough lets just dump the response head
50
+ # and hope someone can do something contextually appropriate. And hope this
51
+ # doesn't become regular enough anyone wants to be smarter.
52
+ echo " Could not get rev count from GitHub response. Response headers:"
53
+ echo " $HEAD "
54
+ exit 1
55
+ fi
37
56
38
57
# Combine the API version and the revision count to get the full version
39
58
OPTE_VER=" 0.$API_VER .$REV_COUNT "
0 commit comments