Class: Gitlab::BitbucketImport::RefConverter
- Inherits:
-
Object
- Object
- Gitlab::BitbucketImport::RefConverter
- Defined in:
- lib/gitlab/bitbucket_import/ref_converter.rb
Constant Summary collapse
- REPO_MATCHER =
'https://bitbucket.org/%s'- PR_NOTE_ISSUE_NAME_REGEX =
"(issues\/.*\/(.*)\\))"- UNWANTED_NOTE_REF_HTML =
"{: data-inline-card='' }"
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #convert_note(note) ⇒ Object
-
#initialize(project) ⇒ RefConverter
constructor
A new instance of RefConverter.
Constructor Details
#initialize(project) ⇒ RefConverter
Returns a new instance of RefConverter.
12 13 14 |
# File 'lib/gitlab/bitbucket_import/ref_converter.rb', line 12 def initialize(project) @project = project end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
10 11 12 |
# File 'lib/gitlab/bitbucket_import/ref_converter.rb', line 10 def project @project end |
Instance Method Details
#convert_note(note) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gitlab/bitbucket_import/ref_converter.rb', line 16 def convert_note(note) repo_matcher = REPO_MATCHER % project.import_source return note unless note.match?(repo_matcher) note = note.gsub(repo_matcher, url_helpers.project_url(project)) .gsub(UNWANTED_NOTE_REF_HTML, '') .strip if note.match?('issues') note.gsub!('issues', '-/issues') note.gsub!("/#{issue_name(note)}", '') if issue_name(note) else note.gsub!('pull-requests', '-/merge_requests') note.gsub!('src', '-/blob') note.gsub!('lines-', 'L') end note end |