summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-15 09:43:17 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-07-15 09:43:17 +0300
commit59bffe6b1ed6ed425723cf6d98259bdee9f75f0a (patch)
tree440fb68731a5ffc145bfc150b85b1f3dfdf3c82d
parentf959bd4d1f80811bb41a9fd6197a44a9ce641157 (diff)
parentdf90f59c25d9d42181af31eb7c9f4219ab7a36ba (diff)
downloadgitlab-shell-59bffe6b1ed6ed425723cf6d98259bdee9f75f0a.tar.gz
Merge pull request #162 from asedge/annotated_tags
Adding support+tests for annotated tags.
-rw-r--r--README.md3
-rw-r--r--lib/gitlab_projects.rb7
-rw-r--r--spec/gitlab_projects_spec.rb36
3 files changed, 37 insertions, 9 deletions
diff --git a/README.md b/README.md
index 5740f3f..1915e5b 100644
--- a/README.md
+++ b/README.md
@@ -58,9 +58,10 @@ Remove branch
./bin/gitlab-projects rm-branch gitlab/gitlab-ci.git 3-0-stable
-Create tag
+Create tag (lightweight & annotated)
./bin/gitlab-projects create-tag gitlab/gitlab-ci.git v3.0.0 3-0-stable
+ ./bin/gitlab-projects create-tag gitlab/gitlab-ci.git v3.0.0 3-0-stable 'annotated message goes here'
Remove tag
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
index 4067d13..a6fa1b5 100644
--- a/lib/gitlab_projects.rb
+++ b/lib/gitlab_projects.rb
@@ -67,7 +67,12 @@ class GitlabProjects
def create_tag
tag_name = ARGV.shift
ref = ARGV.shift || "HEAD"
- cmd = %W(git --git-dir=#{full_path} tag -- #{tag_name} #{ref})
+ cmd = %W(git --git-dir=#{full_path} tag)
+ if ARGV.size > 0
+ msg = ARGV.shift
+ cmd += %W(-a -m #{msg})
+ end
+ cmd += %W(-- #{tag_name} #{ref})
system(*cmd)
end
diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb
index 300029c..3101b0b 100644
--- a/spec/gitlab_projects_spec.rb
+++ b/spec/gitlab_projects_spec.rb
@@ -60,14 +60,36 @@ describe GitlabProjects do
let(:gl_projects_create) {
build_gitlab_projects('import-project', repo_name, 'https://github.com/randx/six.git')
}
- let(:gl_projects) { build_gitlab_projects('create-tag', repo_name, 'test_tag', 'master') }
+ context "lightweight tag" do
+ let(:gl_projects) { build_gitlab_projects('create-tag', repo_name, 'test_tag', 'master') }
- it "should create a tag" do
- gl_projects_create.exec
- gl_projects.exec
- tag_ref = capture_in_tmp_repo(%W(git rev-parse test_tag))
- master_ref = capture_in_tmp_repo(%W(git rev-parse master))
- tag_ref.should == master_ref
+ it "should create a tag" do
+ gl_projects_create.exec
+ gl_projects.exec
+ tag_ref = capture_in_tmp_repo(%W(git rev-parse test_tag))
+ master_ref = capture_in_tmp_repo(%W(git rev-parse master))
+ tag_ref.should == master_ref
+ end
+ end
+ context "annotated tag" do
+ msg = 'some message'
+ tag_name = 'test_annotated_tag'
+
+ let(:gl_projects) { build_gitlab_projects('create-tag', repo_name, tag_name, 'master', msg) }
+
+ it "should create an annotated tag" do
+ gl_projects_create.exec
+ system(*%W(git --git-dir=#{tmp_repo_path} config user.name Joe))
+ system(*%W(git --git-dir=#{tmp_repo_path} config user.email joe@smith.com))
+ gl_projects.exec
+
+ tag_ref = capture_in_tmp_repo(%W(git rev-parse #{tag_name}^{}))
+ master_ref = capture_in_tmp_repo(%W(git rev-parse master))
+ tag_msg = capture_in_tmp_repo(%W(git tag -l -n1 #{tag_name}))
+
+ tag_ref.should == master_ref
+ tag_msg.should == tag_name + ' ' + msg
+ end
end
end