From d7e2d5be36f2c14ddf4e2e8c5cc34001ab8b4ac5 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 29 May 2017 15:13:08 +0100 Subject: [PATCH] update-test: tweak more edge cases. Don't try to `fetch --depth=1` unless we've confirmed the repository is already shallow. Otherwise this can discard history from a full clone. Additionally, if the repository wasn't shallow but there's no tags found assume that Git is too old and try a naive sort if on Linux where `sort` is able to sort versions. --- Library/Homebrew/dev-cmd/update-test.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb index e658207503..aa7fe6a924 100644 --- a/Library/Homebrew/dev-cmd/update-test.rb +++ b/Library/Homebrew/dev-cmd/update-test.rb @@ -36,8 +36,12 @@ module Homebrew tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname") previous_tag = tags.lines[1] previous_tag ||= begin - safe_system "git", "fetch", "--tags", "--depth=1" - tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname") + if (HOMEBREW_REPOSITORY/".git/shallow").exist? + safe_system "git", "fetch", "--tags", "--depth=1" + tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname") + elsif OS.linux? + tags = Utils.popen_read("git tag --list | sort -rV") + end tags.lines[1] end previous_tag = previous_tag.to_s.chomp