diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 12:09:15 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 12:09:15 +0000 |
commit | 0637ba1e6e9024f35b2cbf561d9002ec17350bb3 (patch) | |
tree | 960cebf0e892710c1b40f25e249d04aaf8f9b868 /app | |
parent | 4720b569f0fcbb47e9f1a60e95172ae63b6f065a (diff) | |
download | gitlab-ce-0637ba1e6e9024f35b2cbf561d9002ec17350bb3.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/job_artifact.rb | 4 | ||||
-rw-r--r-- | app/models/issue.rb | 4 | ||||
-rw-r--r-- | app/models/merge_request.rb | 31 | ||||
-rw-r--r-- | app/models/project_services/issue_tracker_service.rb | 4 | ||||
-rw-r--r-- | app/models/project_services/youtrack_service.rb | 2 |
5 files changed, 23 insertions, 22 deletions
diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb index 564853fc8a1..b66bc78094f 100644 --- a/app/models/ci/job_artifact.rb +++ b/app/models/ci/job_artifact.rb @@ -42,6 +42,7 @@ module Ci metrics: :gzip, metrics_referee: :gzip, network_referee: :gzip, + lsif: :gzip, # All these file formats use `raw` as we need to store them uncompressed # for Frontend to fetch the files and do analysis @@ -53,8 +54,7 @@ module Ci dast: :raw, license_management: :raw, license_scanning: :raw, - performance: :raw, - lsif: :raw + performance: :raw }.freeze TYPE_AND_FORMAT_PAIRS = INTERNAL_TYPES.merge(REPORT_TYPES).freeze diff --git a/app/models/issue.rb b/app/models/issue.rb index be702134ced..83f9e803d42 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -128,12 +128,12 @@ class Issue < ApplicationRecord def self.reference_pattern @reference_pattern ||= %r{ (#{Project.reference_pattern})? - #{Regexp.escape(reference_prefix)}(?<issue>\d+) + #{Regexp.escape(reference_prefix)}#{Gitlab::Regex.issue} }x end def self.link_reference_pattern - @link_reference_pattern ||= super("issues", /(?<issue>\d+)/) + @link_reference_pattern ||= super("issues", Gitlab::Regex.issue) end def self.reference_valid?(reference) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 6c32bdadfa8..b469174fc63 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -48,6 +48,7 @@ class MergeRequest < ApplicationRecord # 1. There are arguments - in which case we might be trying to force-reload. # 2. This association is already loaded. # 3. The latest diff does not exist. + # 4. It doesn't have any merge_request_diffs - it returns an empty MergeRequestDiff # # The second one in particular is important - MergeRequestDiff#merge_request # is the inverse of MergeRequest#merge_request_diff, which means it may not be @@ -56,7 +57,7 @@ class MergeRequest < ApplicationRecord def merge_request_diff fallback = latest_merge_request_diff unless association(:merge_request_diff).loaded? - fallback || super + fallback || super || MergeRequestDiff.new(merge_request_id: id) end belongs_to :head_pipeline, foreign_key: "head_pipeline_id", class_name: "Ci::Pipeline" @@ -404,7 +405,7 @@ class MergeRequest < ApplicationRecord end def commits(limit: nil) - return merge_request_diff.commits(limit: limit) if persisted? + return merge_request_diff.commits(limit: limit) if merge_request_diff.persisted? commits_arr = if compare_commits reversed_commits = compare_commits.reverse @@ -421,7 +422,7 @@ class MergeRequest < ApplicationRecord end def commits_count - if persisted? + if merge_request_diff.persisted? merge_request_diff.commits_count elsif compare_commits compare_commits.size @@ -431,7 +432,7 @@ class MergeRequest < ApplicationRecord end def commit_shas(limit: nil) - return merge_request_diff.commit_shas(limit: limit) if persisted? + return merge_request_diff.commit_shas(limit: limit) if merge_request_diff.persisted? shas = if compare_commits @@ -492,11 +493,11 @@ class MergeRequest < ApplicationRecord end def first_commit - merge_request_diff ? merge_request_diff.first_commit : compare_commits.first + compare_commits.present? ? compare_commits.first : merge_request_diff.first_commit end def raw_diffs(*args) - merge_request_diff ? merge_request_diff.raw_diffs(*args) : compare.raw_diffs(*args) + compare.present? ? compare.raw_diffs(*args) : merge_request_diff.raw_diffs(*args) end def diffs(diff_options = {}) @@ -557,7 +558,7 @@ class MergeRequest < ApplicationRecord end def diff_base_commit - if persisted? + if merge_request_diff.persisted? merge_request_diff.base_commit else branch_merge_base_commit @@ -565,7 +566,7 @@ class MergeRequest < ApplicationRecord end def diff_start_commit - if persisted? + if merge_request_diff.persisted? merge_request_diff.start_commit else target_branch_head @@ -573,7 +574,7 @@ class MergeRequest < ApplicationRecord end def diff_head_commit - if persisted? + if merge_request_diff.persisted? merge_request_diff.head_commit else source_branch_head @@ -581,7 +582,7 @@ class MergeRequest < ApplicationRecord end def diff_start_sha - if persisted? + if merge_request_diff.persisted? merge_request_diff.start_commit_sha else target_branch_head.try(:sha) @@ -589,7 +590,7 @@ class MergeRequest < ApplicationRecord end def diff_base_sha - if persisted? + if merge_request_diff.persisted? merge_request_diff.base_commit_sha else branch_merge_base_commit.try(:sha) @@ -597,7 +598,7 @@ class MergeRequest < ApplicationRecord end def diff_head_sha - if persisted? + if merge_request_diff.persisted? merge_request_diff.head_commit_sha else source_branch_head.try(:sha) @@ -758,7 +759,7 @@ class MergeRequest < ApplicationRecord end def ensure_merge_request_diff - merge_request_diff || create_merge_request_diff + merge_request_diff.persisted? || create_merge_request_diff end def create_merge_request_diff @@ -1005,7 +1006,7 @@ class MergeRequest < ApplicationRecord def closes_issues(current_user = self.author) if target_branch == project.default_branch messages = [title, description] - messages.concat(commits.map(&:safe_message)) if merge_request_diff + messages.concat(commits.map(&:safe_message)) if merge_request_diff.persisted? Gitlab::ClosingIssueExtractor.new(project, current_user) .closed_by_message(messages.join("\n")) @@ -1421,7 +1422,7 @@ class MergeRequest < ApplicationRecord end def has_commits? - merge_request_diff && commits_count.to_i > 0 + merge_request_diff.persisted? && commits_count.to_i > 0 end def has_no_commits? diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb index 9e1393196ff..7cdbb124dee 100644 --- a/app/models/project_services/issue_tracker_service.rb +++ b/app/models/project_services/issue_tracker_service.rb @@ -19,9 +19,9 @@ class IssueTrackerService < Service # overridden patterns. See ReferenceRegexes.external_pattern def self.reference_pattern(only_long: false) if only_long - /(\b[A-Z][A-Z0-9_]*-)(?<issue>\d+)/ + /(\b[A-Z][A-Z0-9_]*-)#{Gitlab::Regex.issue}/ else - /(\b[A-Z][A-Z0-9_]*-|#{Issue.reference_prefix})(?<issue>\d+)/ + /(\b[A-Z][A-Z0-9_]*-|#{Issue.reference_prefix})#{Gitlab::Regex.issue}/ end end diff --git a/app/models/project_services/youtrack_service.rb b/app/models/project_services/youtrack_service.rb index 02d06eeb405..0815e27850d 100644 --- a/app/models/project_services/youtrack_service.rb +++ b/app/models/project_services/youtrack_service.rb @@ -8,7 +8,7 @@ class YoutrackService < IssueTrackerService if only_long /(?<issue>\b[A-Za-z][A-Za-z0-9_]*-\d+\b)/ else - /(?<issue>\b[A-Za-z][A-Za-z0-9_]*-\d+\b)|(#{Issue.reference_prefix}(?<issue>\d+))/ + /(?<issue>\b[A-Za-z][A-Za-z0-9_]*-\d+\b)|(#{Issue.reference_prefix}#{Gitlab::Regex.issue})/ end end |