module GitCli::Tags
Public Instance Methods
checkout_tag(tag, branch)
click to toggle source
# File lib/git_cli/tags.rb, line 304 def checkout_tag(tag, branch) raise_if_empty(tag, "Tag name cannot be empty", GitCliException) check_vcs cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "checkout" cmd << "tags/#{tag}" cmd << "-b" cmd << branch cmdln = cmd.join(" ") log_debug "Checkout tag '#{tag}' into branch '#{branch}': #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? [true, res.strip!] else [false, res] end end end
create_tag(tag, msg = nil, branch= nil)
click to toggle source
end # tags
# File lib/git_cli/tags.rb, line 112 def create_tag(tag, msg = nil, branch= nil) raise_if_empty(tag, "Tag name cannot be empty", GitCliException) check_vcs cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "tag" if not_empty?(msg) msg2 = msg.gsub("\"","\\\"").gsub("\\","\\\\") cmd << "-a" #cmd << "\"#{tag}\"" cmd << tag cmd << "-m" cmd << "\"#{msg2}\"" else cmd << tag end if not_empty?(branch) cmd << branch end cmdln = cmd.join(" ") log_debug "New tag : #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? [true, res.strip!] else [false, res] end end end
create_tag_from_commit(tag, commit, msg = nil)
click to toggle source
# File lib/git_cli/tags.rb, line 155 def create_tag_from_commit(tag, commit, msg = nil) raise_if_empty(tag, "Tag name cannot be empty", GitCliException) raise_if_empty(commit, "Commit ID cannot be empty", GitCliException) check_vcs cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "tag" if not_empty?(msg) msg2 = msg.gsub("\"","\\\"").gsub("\\","\\\\") cmd << "-a" cmd << tag cmd << "-m" cmd << msg2 else cmd << "-a" cmd << tag end cmd << commit cmdln = cmd.join(" ") log_debug "New tag from commit ID : #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? [true, res.strip!] else [false, res] end end end
delete_remote_tag(repos,tag)
click to toggle source
# File lib/git_cli/tags.rb, line 277 def delete_remote_tag(repos,tag) raise_if_empty(repos, "Repos name cannot be empty", GitCliException) raise_if_empty(tag, "Tag name cannot be empty", GitCliException) check_vcs cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "push origin --delete" cmd << tag cmdln = cmd.join(" ") log_debug "Delete remote tag '#{tag}' at '#{repos}': #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? [true, res.strip!] else [false, res] end end end
delete_tag(tag)
click to toggle source
# File lib/git_cli/tags.rb, line 252 def delete_tag(tag) raise_if_empty(tag, "Tag name cannot be empty", GitCliException) check_vcs cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "tag -d" cmd << tag cmdln = cmd.join(" ") log_debug "Delete tag '#{tag}' : #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? [true, res.strip!] else [false, res] end end end
fetch_tag_to_local()
click to toggle source
# File lib/git_cli/tags.rb, line 197 def fetch_tag_to_local check_vcs #check_repos cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "fetch --all --tags" cmdln = cmd.join(" ") log_debug "Fetch tags from repository : #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? [true, res.strip!] else [false, res] end end end
show_tag_detail(tag, format = nil)
click to toggle source
# File lib/git_cli/tags.rb, line 222 def show_tag_detail(tag, format = nil) raise_if_empty(tag, "Tag name cannot be empty", GitCliException) check_vcs cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "show" cmd << tag if not_empty?(format) cmd << "--format=\"#{format}\"" end cmdln = cmd.join(" ") log_debug "Show tag '#{tag}' #{not_empty?(format) ? "[#{format}]" : ""} : #{cmdln}" res = os_exec(cmdln) do |st, res| if st.success? [true, res.strip!] else [false, res] end end end
tag_info(tag, format = "%H|%ad|%an|%s")
click to toggle source
# File lib/git_cli/tags.rb, line 47 def tag_info(tag, format = "%H|%ad|%an|%s") raise_if_empty(tag, "Tag name cannot be empty", GitCliException) check_vcs tagInfo = { } cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path #cmd << "log -1 --format=%ai" cmd << "show" cmd << tag # git show <tag> with format # doesn't really portray the actual date # the creation of tag in history commit list # the date is refers to the commit date, # not the date the tag was created if not_empty?(format) cmd << "--format=\"#{format}\"" end cmdln = cmd.join(" ") log_debug "Tag '#{tag}' with info : #{cmdln}" res = os_exec(cmdln) do |st, res| [st.success?, res] end end