Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb26
1 files changed, 19 insertions, 7 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 6744ee230b0..bea86168c8d 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -25,6 +25,7 @@ class Issue < ApplicationRecord
include FromUnion
include EachBatch
include PgFullTextSearchable
+ include Exportable
extend ::Gitlab::Utils::Override
@@ -180,11 +181,7 @@ class Issue < ApplicationRecord
scope :confidential_only, -> { where(confidential: true) }
scope :without_hidden, -> {
- if Feature.enabled?(:ban_user_feature_flag)
- where('NOT EXISTS (?)', Users::BannedUser.select(1).where('issues.author_id = banned_users.user_id'))
- else
- all
- end
+ where('NOT EXISTS (?)', Users::BannedUser.select(1).where('issues.author_id = banned_users.user_id'))
}
scope :counts_by_state, -> { reorder(nil).group(:state_id).count }
@@ -328,13 +325,22 @@ class Issue < ApplicationRecord
'#'
end
+ # Alternative prefix for situations where the standard prefix would be
+ # interpreted as a comment, most notably to begin commit messages with
+ # (e.g. "GL-123: My commit")
+ def self.alternative_reference_prefix
+ 'GL-'
+ end
+
# Pattern used to extract `#123` issue references from text
#
# This pattern supports cross-project references.
def self.reference_pattern
@reference_pattern ||= %r{
- (#{Project.reference_pattern})?
- #{Regexp.escape(reference_prefix)}#{Gitlab::Regex.issue}
+ (?:
+ (#{Project.reference_pattern})?#{Regexp.escape(reference_prefix)} |
+ #{Regexp.escape(alternative_reference_prefix)}
+ )#{Gitlab::Regex.issue}
}x
end
@@ -672,6 +678,12 @@ class Issue < ApplicationRecord
true
end
+ # we want to have subscriptions working on work items only, legacy issues do not support graphql subscriptions, yet so
+ # we need sometimes GID of an issue instance to be represented as WorkItem GID. E.g. notes subscriptions.
+ def to_work_item_global_id
+ ::Gitlab::GlobalId.as_global_id(id, model_name: WorkItem.name)
+ end
+
private
def due_date_after_start_date