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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-24 15:09:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-24 15:09:32 +0300
commita46b489e175708cc64fc5198f458f927558f11ba (patch)
tree96bb3be8fa37d729d1417b4e91df0bf718039911 /app/models
parentbd818d0618b0c1316c23f47f9ae41449e5d41fa8 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/issue.rb10
-rw-r--r--app/models/packages/go/module_version.rb4
2 files changed, 13 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 4c46f779893..16b30f193c7 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -24,6 +24,8 @@ class Issue < ApplicationRecord
include Todoable
include FromUnion
+ extend ::Gitlab::Utils::Override
+
DueDateStruct = Struct.new(:title, :name).freeze
NoDueDate = DueDateStruct.new('No Due Date', '0').freeze
AnyDueDate = DueDateStruct.new('Any Due Date', '').freeze
@@ -448,8 +450,14 @@ class Issue < ApplicationRecord
private
+ # Ensure that the metrics association is safely created and respecting the unique constraint on issue_id
+ override :ensure_metrics
def ensure_metrics
- super
+ if !association(:metrics).loaded? || metrics.blank?
+ metrics_record = Issue::Metrics.safe_find_or_create_by(issue: self)
+ self.metrics = metrics_record
+ end
+
metrics.record!
end
diff --git a/app/models/packages/go/module_version.rb b/app/models/packages/go/module_version.rb
index a50c78f8e69..fd575e6c96c 100644
--- a/app/models/packages/go/module_version.rb
+++ b/app/models/packages/go/module_version.rb
@@ -4,6 +4,7 @@ module Packages
module Go
class ModuleVersion
include Gitlab::Utils::StrongMemoize
+ include Gitlab::Golang
VALID_TYPES = %i[ref commit pseudo].freeze
@@ -81,6 +82,9 @@ module Packages
end
def valid?
+ # assume the module version is valid if a corresponding Package exists
+ return true if ::Packages::Go::PackageFinder.new(mod.project, mod.name, name).exists?
+
@mod.path_valid?(major) && @mod.gomod_valid?(gomod)
end