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
path: root/lib
diff options
context:
space:
mode:
authorAlfredo Sumaran <alfredo@gitlab.com>2016-04-21 20:47:32 +0300
committerAlfredo Sumaran <alfredo@gitlab.com>2016-04-21 20:47:32 +0300
commit3b39214f29f5c2e773f2af923cec70a463f39a73 (patch)
tree5e519a86c4f0431ca3f309474746a33d70dd1c9f /lib
parentd4f6d39896392a964c254ad542eeefeb7c254093 (diff)
parent1c7c114e76510349bebb2494c951713813526489 (diff)
Merge remote-tracking branch 'origin/master' into issue_14904
Diffstat (limited to 'lib')
-rw-r--r--lib/api/commit_statuses.rb21
-rw-r--r--lib/banzai/filter/label_reference_filter.rb36
-rw-r--r--lib/ci/status.rb19
-rw-r--r--lib/gitlab/gon_helper.rb1
-rw-r--r--lib/gitlab/sidekiq_middleware/memory_killer.rb4
5 files changed, 40 insertions, 41 deletions
diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb
index 8e74e177ea0..7388ed2f4ea 100644
--- a/lib/api/commit_statuses.rb
+++ b/lib/api/commit_statuses.rb
@@ -21,10 +21,9 @@ module API
authorize!(:read_commit_status, user_project)
not_found!('Commit') unless user_project.commit(params[:sha])
- ci_commit = user_project.ci_commit(params[:sha])
- return [] unless ci_commit
- statuses = ci_commit.statuses
+ ci_commits = user_project.ci_commits.where(sha: params[:sha])
+ statuses = ::CommitStatus.where(commit: ci_commits)
statuses = statuses.latest unless parse_boolean(params[:all])
statuses = statuses.where(ref: params[:ref]) if params[:ref].present?
statuses = statuses.where(stage: params[:stage]) if params[:stage].present?
@@ -51,7 +50,21 @@ module API
commit = @project.commit(params[:sha])
not_found! 'Commit' unless commit
- ci_commit = @project.ensure_ci_commit(commit.sha)
+ # Since the CommitStatus is attached to Ci::Commit (in the future Pipeline)
+ # We need to always have the pipeline object
+ # To have a valid pipeline object that can be attached to specific MR
+ # Other CI service needs to send `ref`
+ # If we don't receive it, we will attach the CommitStatus to
+ # the first found branch on that commit
+
+ ref = params[:ref]
+ unless ref
+ branches = @project.repository.branch_names_contains(commit.sha)
+ not_found! 'References for commit' if branches.none?
+ ref = branches.first
+ end
+
+ ci_commit = @project.ensure_ci_commit(commit.sha, ref)
name = params[:name] || params[:context]
status = GenericCommitStatus.running_or_pending.find_by(commit: ci_commit, name: name, ref: params[:ref])
diff --git a/lib/banzai/filter/label_reference_filter.rb b/lib/banzai/filter/label_reference_filter.rb
index a2987850d03..8488a493b55 100644
--- a/lib/banzai/filter/label_reference_filter.rb
+++ b/lib/banzai/filter/label_reference_filter.rb
@@ -18,9 +18,7 @@ module Banzai
def references_in(text, pattern = Label.reference_pattern)
text.gsub(pattern) do |match|
- project = project_from_ref($~[:project])
- params = label_params($~[:label_id].to_i, $~[:label_name])
- label = project.labels.find_by(params)
+ label = find_label($~[:project], $~[:label_id], $~[:label_name])
if label
yield match, label.id, $~[:project], $~
@@ -30,18 +28,12 @@ module Banzai
end
end
- def url_for_object(label, project)
- h = Gitlab::Routing.url_helpers
- h.namespace_project_issues_url(project.namespace, project, label_name: label.name,
- only_path: context[:only_path])
- end
+ def find_label(project_ref, label_id, label_name)
+ project = project_from_ref(project_ref)
+ return unless project
- def object_link_text(object, matches)
- if context[:project] == object.project
- LabelsHelper.render_colored_label(object)
- else
- LabelsHelper.render_colored_cross_project_label(object)
- end
+ label_params = label_params(label_id, label_name)
+ project.labels.find_by(label_params)
end
# Parameters to pass to `Label.find_by` based on the given arguments
@@ -55,7 +47,21 @@ module Banzai
if name
{ name: name.tr('"', '') }
else
- { id: id }
+ { id: id.to_i }
+ end
+ end
+
+ def url_for_object(label, project)
+ h = Gitlab::Routing.url_helpers
+ h.namespace_project_issues_url(project.namespace, project, label_name: label.name,
+ only_path: context[:only_path])
+ end
+
+ def object_link_text(object, matches)
+ if context[:project] == object.project
+ LabelsHelper.render_colored_label(object)
+ else
+ LabelsHelper.render_colored_cross_project_label(object)
end
end
end
diff --git a/lib/ci/status.rb b/lib/ci/status.rb
deleted file mode 100644
index 3fb1fe29494..00000000000
--- a/lib/ci/status.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-module Ci
- class Status
- def self.get_status(statuses)
- if statuses.none?
- 'skipped'
- elsif statuses.all? { |status| status.success? || status.ignored? }
- 'success'
- elsif statuses.all?(&:pending?)
- 'pending'
- elsif statuses.any?(&:running?) || statuses.any?(&:pending?)
- 'running'
- elsif statuses.all?(&:canceled?)
- 'canceled'
- else
- 'failed'
- end
- end
- end
-end
diff --git a/lib/gitlab/gon_helper.rb b/lib/gitlab/gon_helper.rb
index 9d81ffb3e6c..ab900b641c4 100644
--- a/lib/gitlab/gon_helper.rb
+++ b/lib/gitlab/gon_helper.rb
@@ -8,7 +8,6 @@ module Gitlab
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
gon.shortcuts_path = help_shortcuts_path
gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class
- gon.sentry_dsn = ApplicationSetting.current.sentry_dsn if Rails.env.production?
if current_user
gon.current_user_id = current_user.id
diff --git a/lib/gitlab/sidekiq_middleware/memory_killer.rb b/lib/gitlab/sidekiq_middleware/memory_killer.rb
index 37232743325..ae85b294d31 100644
--- a/lib/gitlab/sidekiq_middleware/memory_killer.rb
+++ b/lib/gitlab/sidekiq_middleware/memory_killer.rb
@@ -29,8 +29,8 @@ module Gitlab
"in #{GRACE_TIME} seconds"
sleep(GRACE_TIME)
- Sidekiq.logger.warn "sending SIGUSR1 to PID #{Process.pid}"
- Process.kill('SIGUSR1', Process.pid)
+ Sidekiq.logger.warn "sending SIGTERM to PID #{Process.pid}"
+ Process.kill('SIGTERM', Process.pid)
Sidekiq.logger.warn "waiting #{SHUTDOWN_WAIT} seconds before sending "\
"#{SHUTDOWN_SIGNAL} to PID #{Process.pid}"