diff --git a/Library/Contributions/cmd/brew-test-bot.rb b/Library/Contributions/cmd/brew-test-bot.rb index caee05395d..1d8ae1472e 100755 --- a/Library/Contributions/cmd/brew-test-bot.rb +++ b/Library/Contributions/cmd/brew-test-bot.rb @@ -145,6 +145,10 @@ class Test git('symbolic-ref HEAD').gsub('refs/heads/', '').strip end + def single_commit? start_revision, end_revision + git("rev-list --count #{start_revision}..#{end_revision}").to_i == 1 + end + @category = __method__ @start_branch = current_branch @@ -160,7 +164,8 @@ class Test end if @hash == 'HEAD' - if diff_start_sha1 == diff_end_sha1 + if diff_start_sha1 == diff_end_sha1 or \ + single_commit?(diff_start_sha1, diff_end_sha1) @name = diff_end_sha1 else @name = "#{diff_start_sha1}-#{diff_end_sha1}" @@ -174,7 +179,14 @@ class Test test "git checkout #{current_sha1}" test "brew pull --clean #{@url}" diff_end_sha1 = current_sha1 - @name = "#{@url}-#{diff_end_sha1}" + @short_url = @url.gsub('https://github.com/', '') + if @short_url.include? '/commit/' + # 7 characters should be enough for a commit (not 40). + @short_url.gsub!(/(commit\/\w{7}).*/, '\1') + @name = @short_url + else + @name = "#{@short_url}-#{diff_end_sha1}" + end else diff_start_sha1 = diff_end_sha1 = current_sha1 @name = "#{@formulae.first}-#{diff_end_sha1}"