diff --git a/lib/gitlab/client/repositories.rb b/lib/gitlab/client/repositories.rb index beceb5ce2..ec98d6136 100644 --- a/lib/gitlab/client/repositories.rb +++ b/lib/gitlab/client/repositories.rb @@ -24,9 +24,10 @@ def tags(project, options={}) # @param [Integer] project The ID of a project. # @param [String] tag_name The name of the new tag. # @param [String] ref The ref (commit sha, branch name, or another tag) the tag will point to. + # @param [String] message Optional message for tag, creates annotated tag if specified. # @return [Gitlab::ObjectifiedHash] - def create_tag(project, tag_name, ref) - post("/projects/#{project}/repository/tags", body: {tag_name: tag_name, ref: ref}) + def create_tag(project, tag_name, ref, message='') + post("/projects/#{project}/repository/tags", body: {tag_name: tag_name, ref: ref, message: message}) end alias_method :repo_create_tag, :create_tag diff --git a/spec/gitlab/client/repositories_spec.rb b/spec/gitlab/client/repositories_spec.rb index f58e315d0..c3073459d 100644 --- a/spec/gitlab/client/repositories_spec.rb +++ b/spec/gitlab/client/repositories_spec.rb @@ -26,17 +26,34 @@ end describe ".create_tag" do - before do - stub_post("/projects/3/repository/tags", "tag") - @tag = Gitlab.create_tag(3, 'v1.0.0', '2695effb5807a22ff3d138d593fd856244e155e7') + context "lightweight" do + before do + stub_post("/projects/3/repository/tags", "tag") + @tag = Gitlab.create_tag(3, 'v1.0.0', '2695effb5807a22ff3d138d593fd856244e155e7') + end + + it "should get the correct resource" do + expect(a_post("/projects/3/repository/tags")).to have_been_made + end + + it "should return information about a new repository tag" do + expect(@tag.name).to eq("v1.0.0") + end end - it "should get the correct resource" do - expect(a_post("/projects/3/repository/tags")).to have_been_made - end + context "annotated" do + before do + stub_post("/projects/3/repository/tags", "tag") + @tag = Gitlab.create_tag(3, 'v1.0.0', '2695effb5807a22ff3d138d593fd856244e155e7', 'this is an annotated tag') + end + + it "should get the correct resource" do + expect(a_post("/projects/3/repository/tags")).to have_been_made + end - it "should return information about a new repository tag" do - expect(@tag.name).to eq("v1.0.0") + it "should return information about a new repository tag" do + expect(@tag.name).to eq("v1.0.0") + end end end