2015-02-02 18:11:19 -05:00
|
|
|
class ExternalIssue
|
2015-05-02 23:11:21 -04:00
|
|
|
include Referable
|
|
|
|
|
2015-02-02 18:11:19 -05:00
|
|
|
def initialize(issue_identifier, project)
|
|
|
|
@issue_identifier, @project = issue_identifier, project
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
@issue_identifier.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def id
|
|
|
|
@issue_identifier.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def iid
|
|
|
|
@issue_identifier.to_s
|
|
|
|
end
|
|
|
|
|
2015-04-30 17:27:33 -04:00
|
|
|
def title
|
|
|
|
"External Issue #{self}"
|
|
|
|
end
|
|
|
|
|
2015-02-02 18:11:19 -05:00
|
|
|
def ==(other)
|
|
|
|
other.is_a?(self.class) && (to_s == other.to_s)
|
|
|
|
end
|
|
|
|
|
|
|
|
def project
|
|
|
|
@project
|
|
|
|
end
|
2015-05-14 16:59:39 -04:00
|
|
|
|
2016-10-11 11:37:19 -04:00
|
|
|
def project_id
|
|
|
|
@project.id
|
|
|
|
end
|
|
|
|
|
|
|
|
# Pattern used to extract `JIRA-123` issue references from text
|
|
|
|
def self.reference_pattern
|
|
|
|
@reference_pattern ||= %r{(?<issue>\b([A-Z][A-Z0-9_]+-)\d+)}
|
|
|
|
end
|
|
|
|
|
2015-05-14 16:59:39 -04:00
|
|
|
def to_reference(_from_project = nil)
|
|
|
|
id
|
|
|
|
end
|
2016-03-22 05:56:44 -04:00
|
|
|
|
|
|
|
def reference_link_text(from_project = nil)
|
2016-04-12 04:01:52 -04:00
|
|
|
return "##{id}" if /^\d+$/.match(id)
|
|
|
|
|
|
|
|
id
|
2016-03-22 05:56:44 -04:00
|
|
|
end
|
2015-02-02 18:11:19 -05:00
|
|
|
end
|