24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/wassup/helpers/netlify.rb', line 24
def self.deploy(deploy)
review_id = deploy["review_id"]
context = deploy["context"]
state = deploy["state"]
error_message = deploy["error_message"]
branch = deploy["branch"]
commit_ref = deploy["commit_ref"] || "HEAD"
url = deploy["deploy_url"]
if error_message.to_s.downcase.include?("canceled")
state = "cancelled"
end
color = "green"
if state == "building"
color = "yellow"
elsif state == "enqueued"
color = "magenta"
elsif state == "cancelled"
color = "gray"
elsif state == "error"
color = "red"
end
display_context = context.split('-').map(&:capitalize).join(' ')
display_context = "[fg=#{color}]#{display_context}"
if !review_id.nil?
display_context += " - ##{review_id}"
end
display_context += "[fg=gray]"
display_context += " (#{state})"
display_context += "[fg=white]"
if !branch.nil? && !commit_ref.nil?
display_context += "[fg=cyan]: #{branch}@#{commit_ref[0...7]}"
end
display = "#{display_context}"
return display
end
|