Skip to content

Commit dd349a2

Browse files
committed
fix(ci): reconcile wheels after rewritten history
Signed-off-by: AlpinDale <alpindale@gmail.com>
1 parent ec14ea3 commit dd349a2

2 files changed

Lines changed: 34 additions & 10 deletions

File tree

‎.github/scripts/build_nightly_commits.sh‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,27 @@ fi
103103

104104
base_commit=""
105105
if [[ "$last_built" =~ ^[0-9a-f]{40}$ ]] &&
106-
git cat-file -e "${last_built}^{commit}" 2>/dev/null &&
107-
git merge-base --is-ancestor "$last_built" "$target_commit"; then
108-
base_commit="$last_built"
109-
elif [[ "${PUSH_BEFORE:-}" =~ ^[0-9a-f]{40}$ ]] &&
106+
git cat-file -e "${last_built}^{commit}" 2>/dev/null; then
107+
if git merge-base --is-ancestor "$last_built" "$target_commit"; then
108+
base_commit="$last_built"
109+
else
110+
# A force-push can replace already-built commits with equivalent commits
111+
# that have new IDs. Resume from the histories' common ancestor so every
112+
# replacement commit receives a wheel.
113+
base_commit="$(git merge-base "$last_built" "$target_commit" || true)"
114+
fi
115+
fi
116+
117+
if [[ -z "$base_commit" ]] &&
118+
[[ "${PUSH_BEFORE:-}" =~ ^[0-9a-f]{40}$ ]] &&
110119
[[ ! "${PUSH_BEFORE}" =~ ^0+$ ]] &&
111120
git cat-file -e "${PUSH_BEFORE}^{commit}" 2>/dev/null &&
112121
git merge-base --is-ancestor "$PUSH_BEFORE" "$target_commit"; then
113122
base_commit="$PUSH_BEFORE"
114-
elif git rev-parse "${target_commit}^" >/dev/null 2>&1; then
123+
fi
124+
125+
if [[ -z "$base_commit" ]] &&
126+
git rev-parse "${target_commit}^" >/dev/null 2>&1; then
115127
base_commit="$(git rev-parse "${target_commit}^")"
116128
fi
117129

‎.github/scripts/reconcile_platform_wheels.sh‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,27 @@ fi
124124

125125
base_commit=""
126126
if [[ "$last_built" =~ ^[0-9a-f]{40}$ ]] &&
127-
git cat-file -e "${last_built}^{commit}" 2>/dev/null &&
128-
git merge-base --is-ancestor "$last_built" "$target_commit"; then
129-
base_commit="$last_built"
130-
elif [[ "${PUSH_BEFORE:-}" =~ ^[0-9a-f]{40}$ ]] &&
127+
git cat-file -e "${last_built}^{commit}" 2>/dev/null; then
128+
if git merge-base --is-ancestor "$last_built" "$target_commit"; then
129+
base_commit="$last_built"
130+
else
131+
# A force-push can replace already-built commits with equivalent commits
132+
# that have new IDs. Resume from the histories' common ancestor so every
133+
# replacement commit receives a wheel.
134+
base_commit="$(git merge-base "$last_built" "$target_commit" || true)"
135+
fi
136+
fi
137+
138+
if [[ -z "$base_commit" ]] &&
139+
[[ "${PUSH_BEFORE:-}" =~ ^[0-9a-f]{40}$ ]] &&
131140
[[ ! "${PUSH_BEFORE}" =~ ^0+$ ]] &&
132141
git cat-file -e "${PUSH_BEFORE}^{commit}" 2>/dev/null &&
133142
git merge-base --is-ancestor "$PUSH_BEFORE" "$target_commit"; then
134143
base_commit="$PUSH_BEFORE"
135-
elif git rev-parse "${target_commit}^" >/dev/null 2>&1; then
144+
fi
145+
146+
if [[ -z "$base_commit" ]] &&
147+
git rev-parse "${target_commit}^" >/dev/null 2>&1; then
136148
base_commit="$(git rev-parse "${target_commit}^")"
137149
fi
138150

0 commit comments

Comments
 (0)