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:
authorLin Jen-Shin <godfat@godfat.org>2016-07-19 16:24:40 +0300
committerLin Jen-Shin <godfat@godfat.org>2016-07-19 16:24:40 +0300
commit87604ed6ceb7d088dd4ebbc20185fe6ef46180c5 (patch)
treef856fdec8195f1484453b9d86d9947fb43d4cf58 /lib
parent08b9532e376eae369cd04d9f86ea560acfd19ed0 (diff)
parente57c0c89f082e98f0fa0f3bd5ab0778c7304c41e (diff)
Merge branch 'master' into artifacts-from-ref-and-build-name-api
* master: (23 commits) Add CHANGELOG entry [ci skip] CHANGELOG item Added redirect_to_referer to login link on issues Simplify entities for branches and tags API Added Rake task for tracking deployments Return the number of marked todos Use local_assigns Use `humanize` Improve code design Remove unused create_pipeline_service_spec.rb Add notice implementation Make manual actions to work with master code Use `capitalize` instead of `titleize` for manual actions Mark builds with manual actions as skipped Fix rubocop offenses Update build fixtures to include manual actions Improve manual actions code and add model, service and feature tests Rename playable_actions to manual_actions Add implementation of manual actions Position commit icons closer to branch name/tag/sha; add min-width to pipeline actions cell ...
Diffstat (limited to 'lib')
-rw-r--r--lib/api/branches.rb12
-rw-r--r--lib/api/entities.rb51
-rw-r--r--lib/api/todos.rb2
-rw-r--r--lib/ci/gitlab_ci_yaml_processor.rb4
-rw-r--r--lib/tasks/gitlab/track_deployment.rake9
5 files changed, 33 insertions, 45 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb
index 35efe4f2e4a..66b853eb342 100644
--- a/lib/api/branches.rb
+++ b/lib/api/branches.rb
@@ -15,7 +15,8 @@ module API
# GET /projects/:id/repository/branches
get ":id/repository/branches" do
branches = user_project.repository.branches.sort_by(&:name)
- present branches, with: Entities::RepoObject, project: user_project
+
+ present branches, with: Entities::RepoBranch, project: user_project
end
# Get a single branch
@@ -28,7 +29,8 @@ module API
get ':id/repository/branches/:branch', requirements: { branch: /.+/ } do
@branch = user_project.repository.branches.find { |item| item.name == params[:branch] }
not_found!("Branch") unless @branch
- present @branch, with: Entities::RepoObject, project: user_project
+
+ present @branch, with: Entities::RepoBranch, project: user_project
end
# Protect a single branch
@@ -60,7 +62,7 @@ module API
developers_can_merge: developers_can_merge || false)
end
- present @branch, with: Entities::RepoObject, project: user_project
+ present @branch, with: Entities::RepoBranch, project: user_project
end
# Unprotect a single branch
@@ -79,7 +81,7 @@ module API
protected_branch = user_project.protected_branches.find_by(name: @branch.name)
protected_branch.destroy if protected_branch
- present @branch, with: Entities::RepoObject, project: user_project
+ present @branch, with: Entities::RepoBranch, project: user_project
end
# Create branch
@@ -97,7 +99,7 @@ module API
if result[:status] == :success
present result[:branch],
- with: Entities::RepoObject,
+ with: Entities::RepoBranch,
project: user_project
else
render_api_error!(result[:message], 400)
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index d6fed1a1eed..d7e74582459 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -114,33 +114,23 @@ module API
end
end
- class RepoObject < Grape::Entity
+ class RepoBranch < Grape::Entity
expose :name
- expose :commit do |repo_obj, options|
- if repo_obj.respond_to?(:commit)
- repo_obj.commit
- elsif options[:project]
- options[:project].repository.commit(repo_obj.target)
- end
+ expose :commit do |repo_branch, options|
+ options[:project].repository.commit(repo_branch.target)
end
- expose :protected do |repo_obj, options|
- if options[:project]
- options[:project].protected_branch? repo_obj.name
- end
+ expose :protected do |repo_branch, options|
+ options[:project].protected_branch? repo_branch.name
end
- expose :developers_can_push do |repo_obj, options|
- if options[:project]
- options[:project].developers_can_push_to_protected_branch? repo_obj.name
- end
+ expose :developers_can_push do |repo_branch, options|
+ options[:project].developers_can_push_to_protected_branch? repo_branch.name
end
- expose :developers_can_merge do |repo_obj, options|
- if options[:project]
- options[:project].developers_can_merge_to_protected_branch? repo_obj.name
- end
+ expose :developers_can_merge do |repo_branch, options|
+ options[:project].developers_can_merge_to_protected_branch? repo_branch.name
end
end
@@ -437,27 +427,14 @@ module API
end
class RepoTag < Grape::Entity
- expose :name
- expose :message do |repo_obj, _options|
- if repo_obj.respond_to?(:message)
- repo_obj.message
- else
- nil
- end
- end
+ expose :name, :message
- expose :commit do |repo_obj, options|
- if repo_obj.respond_to?(:commit)
- repo_obj.commit
- elsif options[:project]
- options[:project].repository.commit(repo_obj.target)
- end
+ expose :commit do |repo_tag, options|
+ options[:project].repository.commit(repo_tag.target)
end
- expose :release, using: Entities::Release do |repo_obj, options|
- if options[:project]
- options[:project].releases.find_by(tag: repo_obj.name)
- end
+ expose :release, using: Entities::Release do |repo_tag, options|
+ options[:project].releases.find_by(tag: repo_tag.name)
end
end
diff --git a/lib/api/todos.rb b/lib/api/todos.rb
index 2a6bfa98ca4..26c24c3baff 100644
--- a/lib/api/todos.rb
+++ b/lib/api/todos.rb
@@ -75,7 +75,7 @@ module API
todos = find_todos
todos.each(&:done)
- present paginate(Kaminari.paginate_array(todos)), with: Entities::Todo, current_user: current_user
+ todos.length
end
end
end
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb
index a48dc542b14..41449d720b3 100644
--- a/lib/ci/gitlab_ci_yaml_processor.rb
+++ b/lib/ci/gitlab_ci_yaml_processor.rb
@@ -194,8 +194,8 @@ module Ci
raise ValidationError, "#{name} job: allow_failure parameter should be an boolean"
end
- if job[:when] && !job[:when].in?(%w[on_success on_failure always])
- raise ValidationError, "#{name} job: when parameter should be on_success, on_failure or always"
+ if job[:when] && !job[:when].in?(%w[on_success on_failure always manual])
+ raise ValidationError, "#{name} job: when parameter should be on_success, on_failure, always or manual"
end
if job[:environment] && !validate_environment(job[:environment])
diff --git a/lib/tasks/gitlab/track_deployment.rake b/lib/tasks/gitlab/track_deployment.rake
new file mode 100644
index 00000000000..84aa2e8507a
--- /dev/null
+++ b/lib/tasks/gitlab/track_deployment.rake
@@ -0,0 +1,9 @@
+namespace :gitlab do
+ desc 'GitLab | Tracks a deployment in GitLab Performance Monitoring'
+ task track_deployment: :environment do
+ metric = Gitlab::Metrics::Metric.
+ new('deployments', version: Gitlab::VERSION)
+
+ Gitlab::Metrics.submit_metrics([metric.to_hash])
+ end
+end