From d708def49472e76c243ec18f007809a0d92675e3 Mon Sep 17 00:00:00 2001 From: Akash Srivastava Date: Tue, 25 Dec 2018 19:40:39 +0530 Subject: [PATCH 1/2] Protected tags API --- lib/gitlab/client.rb | 1 + lib/gitlab/client/protected_tags.rb | 59 +++++++++++++++++++++ spec/fixtures/protected_tag.json | 9 ++++ spec/fixtures/protected_tags.json | 11 ++++ spec/gitlab/client/protected_tags_spec.rb | 62 +++++++++++++++++++++++ 5 files changed, 142 insertions(+) create mode 100644 lib/gitlab/client/protected_tags.rb create mode 100644 spec/fixtures/protected_tag.json create mode 100644 spec/fixtures/protected_tags.json create mode 100644 spec/gitlab/client/protected_tags_spec.rb diff --git a/lib/gitlab/client.rb b/lib/gitlab/client.rb index ea698d31a..b4d382f7a 100644 --- a/lib/gitlab/client.rb +++ b/lib/gitlab/client.rb @@ -32,6 +32,7 @@ class Client < API include PipelineTriggers include Pipelines include Projects + include ProtectedTags include Repositories include RepositoryFiles include Runners diff --git a/lib/gitlab/client/protected_tags.rb b/lib/gitlab/client/protected_tags.rb new file mode 100644 index 000000000..d8410c8c8 --- /dev/null +++ b/lib/gitlab/client/protected_tags.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +class Gitlab::Client + # Defines methods related to Protected Tags. + # @see https://docs.gitlab.com/ce/api/protected_tags.html + module ProtectedTags + # Gets a list of protected tags from a project + # + # @example + # Gitlab.protected_tags(1) + # + # @param [Integer, String] project(required) The ID or name of a project. + # @option options [Integer] :page The page number. + # @option options [Integer] :per_page The number of results per page. + # @return [Array] List of all protected tags requested + def protected_tags(project, options = {}) + get("/projects/#{url_encode project}/protected_tags", query: options) + end + + # Gets a single protected tag or wildcard protected tag. + # + # @example + # Gitlab.protected_tag(1, 'release-1-0') + # + # @param [Integer, String] project(required) The ID or name of a project. + # @param [String] name(required) The name of the tag or wildcard + # @return Date: Wed, 26 Dec 2018 12:54:15 +0530 Subject: [PATCH 2/2] Removed unused variable assignment in protected_tags_spec --- spec/gitlab/client/protected_tags_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/gitlab/client/protected_tags_spec.rb b/spec/gitlab/client/protected_tags_spec.rb index e84b61d3c..415d02627 100644 --- a/spec/gitlab/client/protected_tags_spec.rb +++ b/spec/gitlab/client/protected_tags_spec.rb @@ -52,7 +52,7 @@ describe '.unprotect_repository_tag' do before do stub_delete('/projects/1/protected_tags/release-1-0', 'empty') - @unprotected_tag = Gitlab.unprotect_repository_tag(1, 'release-1-0') + Gitlab.unprotect_repository_tag(1, 'release-1-0') end it 'gets the correct resource' do