Always fetch at least the latest tag.

This commit is contained in:
Markus Reiter 2018-08-11 00:21:32 +02:00
parent 8f3a80b562
commit bdc2458c15
3 changed files with 11 additions and 3 deletions

View File

@ -59,7 +59,7 @@ HOMEBREW_VERSION="$(git -C "$HOMEBREW_REPOSITORY" describe --tags --dirty --abbr
HOMEBREW_USER_AGENT_VERSION="$HOMEBREW_VERSION"
if [[ -z "$HOMEBREW_VERSION" ]]
then
HOMEBREW_VERSION=">=1.4.0 (shallow or no git repository)"
HOMEBREW_VERSION=">=1.7.1 (shallow or no git repository)"
HOMEBREW_USER_AGENT_VERSION="1.X.Y"
fi

View File

@ -33,7 +33,14 @@ EOS
[[ -d "$DIR/.git" ]] || continue
cd "$DIR" || continue
echo "==> Fetching $DIR..."
git fetch --tags --force origin
if [[ "$DIR" = "$HOMEBREW_REPOSITORY" ]]; then
latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)"
git fetch --force origin --shallow-since="$latest_tag"
else
git fetch --force --tags origin
fi
echo
echo "==> Resetting $DIR..."

View File

@ -35,7 +35,8 @@ git_init_if_necessary() {
git config --bool core.autocrlf false
git config remote.origin.url "$BREW_OFFICIAL_REMOTE"
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch --force --depth=1 origin refs/heads/master:refs/remotes/origin/master
latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)"
git fetch --force origin --shallow-since="$latest_tag"
git reset --hard origin/master
SKIP_FETCH_BREW_REPOSITORY=1
set +e