test-bot: add comments, tweak argument handling.
This commit is contained in:
parent
5a11970d63
commit
74a2c3a509
@ -299,28 +299,31 @@ module Homebrew
|
|||||||
|
|
||||||
travis_pr = ENV["TRAVIS_PULL_REQUEST"] && ENV["TRAVIS_PULL_REQUEST"] != "false"
|
travis_pr = ENV["TRAVIS_PULL_REQUEST"] && ENV["TRAVIS_PULL_REQUEST"] != "false"
|
||||||
|
|
||||||
# Use Jenkins environment variables if present.
|
# Use Jenkins GitHub Pull Request Builder plugin variables for
|
||||||
if no_args? && ENV["GIT_PREVIOUS_COMMIT"] && ENV["GIT_COMMIT"] \
|
# pull request jobs.
|
||||||
&& !ENV["ghprbPullLink"]
|
if ENV["ghprbPullLink"]
|
||||||
diff_start_sha1 = shorten_revision ENV["GIT_PREVIOUS_COMMIT"]
|
|
||||||
diff_end_sha1 = shorten_revision ENV["GIT_COMMIT"]
|
|
||||||
elsif ENV["TRAVIS_COMMIT_RANGE"]
|
|
||||||
diff_start_sha1, diff_end_sha1 = ENV["TRAVIS_COMMIT_RANGE"].split "..."
|
|
||||||
diff_end_sha1 = ENV["TRAVIS_COMMIT"] if travis_pr
|
|
||||||
elsif ENV["ghprbPullLink"]
|
|
||||||
# Handle Jenkins pull request builder plugin.
|
|
||||||
@url = ENV["ghprbPullLink"]
|
@url = ENV["ghprbPullLink"]
|
||||||
@hash = nil
|
@hash = nil
|
||||||
test "git", "checkout", "origin/master"
|
test "git", "checkout", "origin/master"
|
||||||
|
# Use Travis CI pull-request variables for pull request jobs.
|
||||||
elsif travis_pr
|
elsif travis_pr
|
||||||
@url = "https://github.com/#{ENV["TRAVIS_REPO_SLUG"]}/pull/#{ENV["TRAVIS_PULL_REQUEST"]}"
|
@url = "https://github.com/#{ENV["TRAVIS_REPO_SLUG"]}/pull/#{ENV["TRAVIS_PULL_REQUEST"]}"
|
||||||
@hash = nil
|
@hash = nil
|
||||||
elsif @hash
|
|
||||||
diff_start_sha1 = current_sha1
|
|
||||||
brew_update
|
|
||||||
diff_end_sha1 = current_sha1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Use Jenkins Git plugin variables for master branch jobs.
|
||||||
|
if ENV["GIT_PREVIOUS_COMMIT"] && ENV["GIT_COMMIT"]
|
||||||
|
diff_start_sha1 = ENV["GIT_PREVIOUS_COMMIT"]
|
||||||
|
diff_end_sha1 = ENV["GIT_COMMIT"]
|
||||||
|
# Use Travis CI Git variables for master or branch jobs.
|
||||||
|
elsif ENV["TRAVIS_COMMIT_RANGE"]
|
||||||
|
diff_start_sha1, diff_end_sha1 = ENV["TRAVIS_COMMIT_RANGE"].split "..."
|
||||||
|
# Otherwise just use the current SHA-1 (which may be overriden later)
|
||||||
|
else
|
||||||
|
diff_end_sha1 = diff_start_sha1 = current_sha1
|
||||||
|
end
|
||||||
|
|
||||||
|
# Handle no arguments being passed on the command-line e.g. `brew test-bot`.
|
||||||
if no_args?
|
if no_args?
|
||||||
if diff_start_sha1 == diff_end_sha1 || \
|
if diff_start_sha1 == diff_end_sha1 || \
|
||||||
single_commit?(diff_start_sha1, diff_end_sha1)
|
single_commit?(diff_start_sha1, diff_end_sha1)
|
||||||
@ -328,19 +331,26 @@ module Homebrew
|
|||||||
else
|
else
|
||||||
@name = "#{diff_start_sha1}-#{diff_end_sha1}"
|
@name = "#{diff_start_sha1}-#{diff_end_sha1}"
|
||||||
end
|
end
|
||||||
|
# Handle formulae arguments being passed on the command-line e.g. `brew test-bot wget fish`.
|
||||||
|
elsif @formulae && @formulae.any?
|
||||||
|
@name = "#{@formulae.first}-#{diff_end_sha1}"
|
||||||
|
# Handle a hash being passed on the command-line e.g. `brew test-bot 1a2b3c`.
|
||||||
elsif @hash
|
elsif @hash
|
||||||
test "git", "checkout", @hash
|
test "git", "checkout", @hash
|
||||||
diff_start_sha1 = "#{@hash}^"
|
diff_start_sha1 = "#{@hash}^"
|
||||||
diff_end_sha1 = @hash
|
diff_end_sha1 = @hash
|
||||||
@name = @hash
|
@name = @hash
|
||||||
elsif ENV["TRAVIS_PULL_REQUEST"] && ENV["TRAVIS_PULL_REQUEST"] != "false"
|
# Handle a URL being passed on the command-line or through Jenkins/Travis
|
||||||
@short_url = @url.gsub("https://github.com/", "")
|
# environment variables e.g.
|
||||||
@name = "#{@short_url}-#{diff_end_sha1}"
|
# `brew test-bot https://github.com/Homebrew/homebrew/pull/44293`.
|
||||||
# TODO: in future this may need to use `brew pull` to push the right commit.
|
|
||||||
elsif @url
|
elsif @url
|
||||||
|
# TODO: in future Travis CI may need to also use `brew pull` to e.g. push
|
||||||
|
# the right commit to BrewTestBot.
|
||||||
|
unless travis_pr
|
||||||
diff_start_sha1 = current_sha1
|
diff_start_sha1 = current_sha1
|
||||||
test "brew", "pull", "--clean", @url
|
test "brew", "pull", "--clean", @url
|
||||||
diff_end_sha1 = current_sha1
|
diff_end_sha1 = current_sha1
|
||||||
|
end
|
||||||
@short_url = @url.gsub("https://github.com/", "")
|
@short_url = @url.gsub("https://github.com/", "")
|
||||||
if @short_url.include? "/commit/"
|
if @short_url.include? "/commit/"
|
||||||
# 7 characters should be enough for a commit (not 40).
|
# 7 characters should be enough for a commit (not 40).
|
||||||
@ -350,8 +360,7 @@ module Homebrew
|
|||||||
@name = "#{@short_url}-#{diff_end_sha1}"
|
@name = "#{@short_url}-#{diff_end_sha1}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
diff_start_sha1 = diff_end_sha1 = current_sha1
|
raise "Cannot set @name: invalid command-line arguments!"
|
||||||
@name = "#{@formulae.first}-#{diff_end_sha1}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV["TRAVIS"]
|
if ENV["TRAVIS"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user