Skip to content

Commit

Permalink
Add support for annotated tag creation. Update tests for create_tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
asedge committed Sep 22, 2014
1 parent 38ad27f commit 76e29e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lib/gitlab/client/repositories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 25 additions & 8 deletions spec/gitlab/client/repositories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 76e29e6

Please sign in to comment.