Class: Gitmine::Issue
Instance Attribute Summary collapse
-
#assigned_to ⇒ Object
readonly
Returns the value of attribute assigned_to.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Class Method Summary collapse
-
.find(issue_id) ⇒ Object
Get the issue from redmine.
-
.get_for_commit(commit_message) ⇒ Object
Parse the commit_message and get the associated issue if any.
-
.parse_for_issue_id(msg) ⇒ Object
Extract the issue_id from a commit message.
Instance Method Summary collapse
-
#add_note(note) ⇒ Object
Add a note to the Issue.
-
#build_via_issue_id(issue_id) ⇒ Object
Get attributes from redmine and set them all.
- #local_branch ⇒ Object
- #remote_branch ⇒ Object
- #update_status(st) ⇒ Object
Instance Attribute Details
#assigned_to ⇒ Object (readonly)
Returns the value of attribute assigned_to.
3 4 5 |
# File 'lib/gitmine/issue.rb', line 3 def assigned_to @assigned_to end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/gitmine/issue.rb', line 3 def id @id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/gitmine/issue.rb', line 3 def status @status end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
3 4 5 |
# File 'lib/gitmine/issue.rb', line 3 def subject @subject end |
Class Method Details
.find(issue_id) ⇒ Object
Get the issue from redmine
24 25 26 27 28 |
# File 'lib/gitmine/issue.rb', line 24 def self.find(issue_id) Issue.new.tap { |issue| issue.build_via_issue_id(issue_id) } end |
.get_for_commit(commit_message) ⇒ Object
Parse the commit_message and get the associated issue if any.
18 19 20 21 |
# File 'lib/gitmine/issue.rb', line 18 def self.get_for_commit() issue_id = parse_for_issue_id() issue_id ? Issue.find(issue_id) : nil end |
.parse_for_issue_id(msg) ⇒ Object
Extract the issue_id from a commit message. Examples:
CommitMsgToIssueId.parse("Message for Issue #123.")
=> 123
CommitMsgToIssueId.parse("#123.")
=> nil
12 13 14 15 |
# File 'lib/gitmine/issue.rb', line 12 def self.parse_for_issue_id(msg) match = msg.match(/Issue #(\d+)/) match ? match[1] : nil end |
Instance Method Details
#add_note(note) ⇒ Object
Add a note to the Issue
50 51 52 53 54 55 |
# File 'lib/gitmine/issue.rb', line 50 def add_note(note) response = self.class.put(url(self.id), :query => {:notes => note}, :body => "") # nginx reject requests without body raise response.response.to_s unless response.code == 200 puts green("Note added to Issue ##{self.id}: #{note}") end |
#build_via_issue_id(issue_id) ⇒ Object
Get attributes from redmine and set them all
39 40 41 42 43 44 45 46 47 |
# File 'lib/gitmine/issue.rb', line 39 def build_via_issue_id(issue_id) @id = issue_id data = http_get(issue_id).parsed_response['issue'] if data @subject = data['subject'] @status = data['status']['name'] @assigned_to = (data['assigned_to'] || {})['name'] end end |
#local_branch ⇒ Object
30 31 32 |
# File 'lib/gitmine/issue.rb', line 30 def local_branch LocalBranch.find(self.id) end |
#remote_branch ⇒ Object
34 35 36 |
# File 'lib/gitmine/issue.rb', line 34 def remote_branch RemoteBranch.find(self.id) end |
#update_status(st) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/gitmine/issue.rb', line 57 def update_status(st) status_id = Gitmine::Config.statuses[st] raise "Please specify status_id in .gitmine.yml for #{st}" unless status_id response = self.class.put(url(self.id), :query => {:issue => {:status_id => status_id }}, :body => "") raise response.response.to_s unless response.code == 200 puts green("Issue ##{self.id} -> #{st}") end |