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
|
# File 'lib/bb_flow.rb', line 30
def self.run(command)
case command
when :commit
return puts Misc.execute('git commit') if Misc.execute('git diff-index HEAD --name-only --cached').empty?
message = (Options.get(:message) || Misc.edit).strip
cards = Trello.cards
cards = Printer.select_items(cards, 'Which cards does this commit address?') unless cards.blank?
card_lines = cards.map do |card|
"Trello Card: #{card.name}, #{card.short_url}"
end.join("\n")
Misc.execute("git commit -m \"#{message}\n\n#{card_lines}\"")
commit_sha = Misc.execute('git show-ref --head -s /HEAD/').strip
commit_url = "#{Github.http_url}/commit/#{commit_sha}"
cards.each do |card|
card.add_attachment(commit_url, message)
Printer.success("Added the commit to the „#{card.name}“ card (#{card.url}).")
end
when :pr
PullRequester.create!
else
Printer.panic("Incorrect parameter: #{command}")
end
end
|