diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-10-25 02:13:24 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-10-25 02:13:24 +0800 |
commit | 600da9ee0bb823e4b14fd45d6ff0e5f0b61b9737 (patch) | |
tree | f91eeeee22da72eed5bdf5b87ca27bdc95b136a0 /lib/api/commit_statuses.rb | |
parent | 40ff7579e9ba025610dfada9703386b4dc657d6d (diff) | |
parent | cb38290ababe43aca0c635fb87d3a38c4c5debcd (diff) | |
download | gitlab-ce-19737-read-only-auditor.tar.gz |
Merge remote-tracking branch 'upstream/master' into 19737-read-only-auditor19737-read-only-auditor
* upstream/master: (1277 commits)
Grapify the labels API
Fix typo in project settings that prevents users from enabling container registry.
Fix old monitoring links to point to the new location
Added path parameter to Commits API
fixes build with cache:clear issue
Merge branch 'security-fix-leaking-namespace-name' into 'security'
Fix authored vote from notes
Grapify builds API
Add changelog item for groups 404 on relative url
Add relative url support to routing contrainers
Update project member controller to match recent master logic
Add parentheses around return redirect_to method
Trigger change even in select2 test helper to produce production-like behaviour
Refactor js that disable form submit if no members selected
Improve create project member test at project_members_controller_spec
Move changelog item to 8.14
Refactor create member tests from group_members_controller_spec
Refactor groups/projects members controller
Gracefully handle adding of no users to projects and groups
Revert "Change "Group#web_url" to return "/groups/twitter" rather than "/twitter"."
...
Diffstat (limited to 'lib/api/commit_statuses.rb')
-rw-r--r-- | lib/api/commit_statuses.rb | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb index dfbdd597d29..f54d4f06627 100644 --- a/lib/api/commit_statuses.rb +++ b/lib/api/commit_statuses.rb @@ -6,17 +6,17 @@ module API resource :projects do before { authenticate! } - # Get a commit's statuses - # - # Parameters: - # id (required) - The ID of a project - # sha (required) - The commit hash - # ref (optional) - The ref - # stage (optional) - The stage - # name (optional) - The name - # all (optional) - Show all statuses, default: false - # Examples: - # GET /projects/:id/repository/commits/:sha/statuses + desc "Get a commit's statuses" do + success Entities::CommitStatus + end + params do + requires :id, type: String, desc: 'The ID of a project' + requires :sha, type: String, desc: 'The commit hash' + optional :ref, type: String, desc: 'The ref' + optional :stage, type: String, desc: 'The stage' + optional :name, type: String, desc: 'The name' + optional :all, type: String, desc: 'Show all statuses, default: false' + end get ':id/repository/commits/:sha/statuses' do authorize!(:read_commit_status, user_project) @@ -31,22 +31,23 @@ module API present paginate(statuses), with: Entities::CommitStatus end - # Post status to commit - # - # Parameters: - # id (required) - The ID of a project - # sha (required) - The commit hash - # ref (optional) - The ref - # state (required) - The state of the status. Can be: pending, running, success, failed or canceled - # target_url (optional) - The target URL to associate with this status - # description (optional) - A short description of the status - # name or context (optional) - A string label to differentiate this status from the status of other systems. Default: "default" - # Examples: - # POST /projects/:id/statuses/:sha + desc 'Post status to a commit' do + success Entities::CommitStatus + end + params do + requires :id, type: String, desc: 'The ID of a project' + requires :sha, type: String, desc: 'The commit hash' + requires :state, type: String, desc: 'The state of the status', + values: ['pending', 'running', 'success', 'failed', 'canceled'] + optional :ref, type: String, desc: 'The ref' + optional :target_url, type: String, desc: 'The target URL to associate with this status' + optional :description, type: String, desc: 'A short description of the status' + optional :name, type: String, desc: 'A string label to differentiate this status from the status of other systems. Default: "default"' + optional :context, type: String, desc: 'A string label to differentiate this status from the status of other systems. Default: "default"' + end post ':id/statuses/:sha' do authorize! :create_commit_status, user_project - required_attributes! [:state] - attrs = attributes_for_keys [:target_url, :description] + commit = @project.commit(params[:sha]) not_found! 'Commit' unless commit @@ -66,9 +67,14 @@ module API pipeline = @project.ensure_pipeline(ref, commit.sha, current_user) status = GenericCommitStatus.running_or_pending.find_or_initialize_by( - project: @project, pipeline: pipeline, - user: current_user, name: name, ref: ref) - status.attributes = attrs + project: @project, + pipeline: pipeline, + user: current_user, + name: name, + ref: ref, + target_url: params[:target_url], + description: params[:description] + ) begin case params[:state].to_s |