Class: MGit::Tag

Inherits:
BaseCommand show all
Defined in:
lib/m-git/command/tag.rb

Constant Summary

Constants inherited from BaseCommand

BaseCommand::HIGH_PRIORITY_OPT_LIST, BaseCommand::SELECTABLE_OPT_LIST

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCommand

#all_repos, cmd, #exec_light_repos, #generate_config_repo, inherited, #initialize, #locked_repos, #run

Constructor Details

This class inherits a constructor from MGit::BaseCommand

Class Method Details

.descriptionObject



57
58
59
# File 'lib/m-git/command/tag.rb', line 57

def self.description
  "增删查或验证标签。增加标签示例:mgit tag -a 'v0.0.1' -m 'Tag description message'"
end

.usageObject



61
62
63
# File 'lib/m-git/command/tag.rb', line 61

def self.usage
  "mgit tag [<git-tag-option>] [(--mrepo|--el-mrepo) <repo>...] [--help]"
end

Instance Method Details

#enable_repo_selectionObject



53
54
55
# File 'lib/m-git/command/tag.rb', line 53

def enable_repo_selection
  true
end

#execute(argv) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/m-git/command/tag.rb', line 9

def execute(argv)
  Workspace.check_branch_consistency

  Output.puts_start_cmd

  exec_repos = all_repos + locked_repos

  if argv.git_opts.empty?
    _, error_repos = Workspace.execute_git_cmd_with_repos(argv.cmd, argv.git_opts, exec_repos)
    Output.puts_succeed_cmd(argv.absolute_cmd) if error_repos.length == 0
    return
  end

  error_repos = {}
  no_tag_repos = []
  exec_repos.each { |repo|
    success, output = repo.execute_git_cmd(argv.cmd, argv.git_opts)
    if success
      tags = output.split("\n")
      if tags.length > 0
        puts Output.generate_title_block(repo.name) {
          Output.generate_table(tags, separator:"")
        }
      else
        no_tag_repos.push(repo.name)
      end
    else
      error_repos[repo.name] = output
    end
  }

  if no_tag_repos.length > 0
    puts "\n"
    Output.puts_remind_block(no_tag_repos, "以上仓库尚未创建tag!")
  end

  if error_repos.length > 0
    Workspace.show_error(error_repos)
  else
    Output.puts_succeed_cmd(argv.absolute_cmd)
  end

end