Class: Boxen::Hook::GitHubIssue
Instance Attribute Summary collapse
Attributes inherited from Boxen::Hook
#checkout, #config, #puppet, #result
Instance Method Summary
collapse
Methods inherited from Boxen::Hook
all, #enabled?, #initialize, #run
Constructor Details
This class inherits a constructor from Boxen::Hook
Instance Attribute Details
#failure_label ⇒ Object
92
93
94
|
# File 'lib/boxen/hook/github_issue.rb', line 92
def failure_label
@failure_label ||= 'failure'
end
|
#ongoing_label ⇒ Object
97
98
99
|
# File 'lib/boxen/hook/github_issue.rb', line 97
def ongoing_label
@ongoing_label ||= 'ongoing'
end
|
Instance Method Details
#call ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/boxen/hook/github_issue.rb', line 10
def call
if result.success?
close_failures
else
warn "Sorry! Creating an issue on #{config.reponame}."
record_failure
end
end
|
#close_failures ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/boxen/hook/github_issue.rb', line 48
def close_failures
return unless issues?
= "Succeeded at version #{checkout.sha}."
failures.each do |issue|
config.api.(config.reponame, issue.number, )
config.api.close_issue(config.reponame, issue.number)
end
end
|
#compare_url ⇒ Object
19
20
21
22
|
# File 'lib/boxen/hook/github_issue.rb', line 19
def compare_url
return unless config.reponame
"https://github.com/#{config.reponame}/compare/#{checkout.sha}...master"
end
|
#failure_details ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/boxen/hook/github_issue.rb', line 67
def failure_details
body = ''
body << "Running on `#{hostname}` (OS X #{os}) under `#{shell}`, "
body << "version #{checkout.sha} ([compare to master](#{compare_url}))."
body << "\n\n"
if checkout.dirty?
body << "### Changes"
body << "\n\n"
body << "```\n#{checkout.changes}\n```"
body << "\n\n"
end
body << "### Puppet Command"
body << "\n\n"
body << "```\n#{puppet.command.join(' ')}\n```"
body << "\n\n"
body << "### Output (from #{config.logfile})"
body << "\n\n"
body << "```\n#{log}\n```\n"
body
end
|
#failures ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'lib/boxen/hook/github_issue.rb', line 58
def failures
return [] unless issues?
issues = config.api.list_issues(config.reponame, :state => 'open',
:labels => failure_label, :creator => config.login)
issues.reject! {|i| i.labels.collect(&:name).include?(ongoing_label)}
issues
end
|
#hostname ⇒ Object
24
25
26
|
# File 'lib/boxen/hook/github_issue.rb', line 24
def hostname
`hostname`.strip
end
|
#issues? ⇒ Boolean
102
103
104
105
106
107
|
# File 'lib/boxen/hook/github_issue.rb', line 102
def issues?
return unless config.reponame
return if config.reponame == 'boxen/our-boxen'
config.api.repository(config.reponame).has_issues
end
|
#log ⇒ Object
36
37
38
|
# File 'lib/boxen/hook/github_issue.rb', line 36
def log
File.read config.logfile
end
|
#os ⇒ Object
28
29
30
|
# File 'lib/boxen/hook/github_issue.rb', line 28
def os
`sw_vers -productVersion`.strip
end
|
6
7
8
|
# File 'lib/boxen/hook/github_issue.rb', line 6
def perform?
enabled? && !config.stealth? && !config.pretend? && checkout.master?
end
|
#record_failure ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/boxen/hook/github_issue.rb', line 40
def record_failure
return unless issues?
title = "Failed for #{config.user}"
config.api.create_issue(config.reponame, title, failure_details,
:labels => [failure_label])
end
|
#shell ⇒ Object
32
33
34
|
# File 'lib/boxen/hook/github_issue.rb', line 32
def shell
ENV["SHELL"]
end
|