Class: Commands::Tag
- Inherits:
-
Object
- Object
- Commands::Tag
- Defined in:
- lib/commands/tag.rb
Instance Method Summary collapse
-
#options ⇒ Object
holds the options that were passed you can set any initial defaults here.
- #register(opts, global_options) ⇒ Object
-
#required_options ⇒ Object
required options.
- #run(global_options) ⇒ Object
Instance Method Details
#options ⇒ Object
holds the options that were passed you can set any initial defaults here
13 14 15 16 |
# File 'lib/commands/tag.rb', line 13 def @options ||= { } end |
#register(opts, global_options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/commands/tag.rb', line 25 def register(opts, ) opts. = "Usage: tag [options]" opts.description = "Apply or delete a tag for all taggable repos in a config" opts.on('-t', "--tag name", "Required - Name of the tag.") do |v| [:tag] = v end opts.on('-d', "--delete", "When set causes tag to be deleted.") do |v| [:delete] = v end end |
#required_options ⇒ Object
required options
19 20 21 22 23 |
# File 'lib/commands/tag.rb', line 19 def @required_options ||= Set.new [ :tag, ] end |
#run(global_options) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/commands/tag.rb', line 39 def run() # see if we can open the config file - we append the .config suffix # the file is expected to be in JSON format tag = [:tag] delete_tag = [:delete] # determine config_name by extracting our directory config_name = EbmSharedLib.config_name_from_dir(Dir.pwd) # try to make sure the repo is available EbmSharedLib.prepare_config_repo info = EbmSharedLib.read_repo_config(config_name) # other than prepare, any commands that work across the repos expect you to start # in the containing directory (i.e. if your config is named iphone_3.1, you are expected # to be in that directory when you run the command). top_dir = "#{Dir.pwd}" repos = info[:repos] repos.each do |repo| if repo[:taggable] repo_name = EbmSharedLib.get_repo_name(repo[:git_path]) repo_path = "#{top_dir}/#{repo_name}" if delete_tag == true cmd = "git tag -d #{tag} && git push origin :refs/tags/#{tag}" else cmd = "git tag #{tag} && git push origin refs/tags/#{tag}" end if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0 raise "Tagging operation failed for #{repo_name}. Make sure you are in the top level #{config_name} directory." end end end end |