Skip to content

Commit a381b59

Browse files
authored
Merge pull request #1060 from MikeMcQuaid/update-tag-tweaks
update.sh: tweak tag handling.
2 parents 09e0b09 + f9bd121 commit a381b59

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Library/Homebrew/cmd/update.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ merge_or_rebase() {
218218
if [[ "$DIR" = "$HOMEBREW_REPOSITORY" && -z "$HOMEBREW_NO_UPDATE_CLEANUP" ]]
219219
then
220220
UPSTREAM_TAG="$(git tag --list --sort=-version:refname | head -n1)"
221+
else
222+
UPSTREAM_TAG=""
221223
fi
222224

223225
if [ -n "$UPSTREAM_TAG" ]
@@ -253,7 +255,8 @@ EOS
253255
fi
254256

255257
INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)"
256-
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
258+
if [[ -n "$UPSTREAM_TAG" ]] ||
259+
[[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
257260
then
258261

259262
if [[ -z "$HOMEBREW_NO_UPDATE_CLEANUP" ]]
@@ -265,7 +268,8 @@ EOS
265268

266269
# Recreate and check out `#{upstream_branch}` if unable to fast-forward
267270
# it to `origin/#{@upstream_branch}`. Otherwise, just check it out.
268-
if git merge-base --is-ancestor "$UPSTREAM_BRANCH" "$REMOTE_REF" &>/dev/null
271+
if [[ -z "$UPSTREAM_TAG" ]] &&
272+
git merge-base --is-ancestor "$UPSTREAM_BRANCH" "$REMOTE_REF" &>/dev/null
269273
then
270274
git checkout --force "$UPSTREAM_BRANCH" "${QUIET_ARGS[@]}"
271275
else

0 commit comments

Comments
 (0)