Class: Pixab::GitlabMRManager

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/GitlabMRManager.rb

Instance Method Summary collapse

Instance Method Details

#run(commands = nil) ⇒ Object



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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/gitlab/GitlabMRManager.rb', line 12

def run(commands = nil)
   = UserInfo.new
  if not commands.nil?
    commands.each_index do |index|
      command = commands[index]
      case command
      when '--android'
        .platform = Platform.android
      when '--iOS'
        .platform = Platform.iOS
      when '--token'
        token = commands[index + 1]
        unless token.nil?
          GitlabInfo.set_user_token(token)
        end
      end
    end
  end

  token = GitlabInfo.get_user_token
  if token.nil?
    puts "未设置 Gitlab Token".red
    return
  end

  git_repos = .git_repos
  if git_repos.empty?
    puts "No Git repositories found.".red
    return
  end

  reviewers = .platform.is_iOS ? GitlabInfo.iOS_reviewers : GitlabInfo.android_reviewers
  selected_reviewers = Utilities.display_choose_list(reviewers, nil, "审核人员", "请选择审核人员:", nil, nil, true)

  if selected_reviewers.empty?
    puts "未选择审核人员".red
    return
  end
  
  reviewer_ids = []
  if .platform.is_iOS
    selected_reviewers.each do |reviewer|
      reviewer_ids << GitlabInfo.iOS_reviewer_id(reviewer)
    end
  else
    selected_reviewers.each do |reviewer|
      reviewer_ids << GitlabInfo.android_reviewer_id(reviewer)
    end
  end

  gitlab_mr = GitlabMR.new(token)
  git_repos.each do |repo|
    gitlab_mr.run(repo, reviewer_ids)
  end

end