pixab 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad65d5472da045a81067a41d705fea247f8458977f72aa7ba61224f3c2d155da
4
- data.tar.gz: 7c283ff51d7166f658e72ed9afb7de9693a79889b9f6c0b4e5015c30958a2824
3
+ metadata.gz: 465c3b05af7e8d11f5fd4b439052fa3dbe29f4e3bc8c16e1299d19fb7dc278e7
4
+ data.tar.gz: 4c3dd3ef7d60511a00bb9fc57df5ff35e40b9faf3686e1c4d4f131d6d6aefd34
5
5
  SHA512:
6
- metadata.gz: 3c7228c287049cf5f006559481862a67b09abe1d743628b57d4909c3c188a93f136c07c4e4fbd1f8893d5ccd3b98b4935f89d3569659d2244e6370d83b8aa391
7
- data.tar.gz: 7b66f1118681b026bcb0e525279e00e16bf16295efd0132ba80066bb9c5de81cf799ec1c999ab7eff4864e7ce97bbf5e2c9224768b71a85b86d341506f8e375d
6
+ metadata.gz: 78ca01d716329db426c40ff7103b03ebee3cbb4b09b9c8467ccd822cc60de4a48b4b9473516cbdfcd3bee824963425b1104669fa82ed5b94d1ae991643edc5c6
7
+ data.tar.gz: cdc919b196b24c97040c8cde8118a09aeae0f27be69cc8d2e5e07ff73f5c062aea70469e82c5a288e793ba700ae5b083415c23be10354f8eff5476a5a30eec12
@@ -57,12 +57,14 @@ module Pixab
57
57
  def replace_local_to_remote
58
58
  active_repo_names = ""
59
59
  repos.each do |repo|
60
- components = repo["components"]
61
60
  is_avtive = true
62
- components.each do |component|
63
- if component["tool"] == "CocoaPods"
64
- is_avtive = !component["active"].empty?
65
- break
61
+ components = repo["components"]
62
+ if !components.nil?
63
+ components.each do |component|
64
+ if component["tool"] == "CocoaPods"
65
+ is_avtive = !component["active"].empty?
66
+ break
67
+ end
66
68
  end
67
69
  end
68
70
  if is_avtive
data/lib/GitUtils.rb CHANGED
@@ -82,7 +82,7 @@ module Pixab
82
82
 
83
83
  # 获取当前分支
84
84
  def current_branch
85
- branch = `git rev-parse --abbrev-ref HEAD`
85
+ branch = `git rev-parse --abbrev-ref HEAD`.chomp
86
86
  return branch
87
87
  end
88
88
 
data/lib/MergeRequest.rb CHANGED
@@ -5,30 +5,38 @@ require "fileutils"
5
5
  require 'colored2'
6
6
  require_relative './Utilities.rb'
7
7
  require_relative './RepoManager.rb'
8
+ require_relative './GitUtils.rb'
8
9
 
9
10
  module Pixab
10
11
 
11
12
  class MergeRequest
12
13
 
13
- attr_accessor :repo_type, :default_commit_msg
14
+ attr_accessor :repo_type, :default_commit_msg, :need_merge_origin, :need_creat_mr
14
15
  attr_reader :repo_manager, :repos, :command_options
15
16
 
16
17
  def initialize(repo_manager = RepoManager.new, commands = nil)
17
18
  @repo_manager = repo_manager
18
19
  @repo_type = 2
19
20
  @default_commit_msg = "[Feature]"
21
+ @need_merge_origin = true
22
+ @need_creat_mr = true
23
+
20
24
  if commands.nil?
21
25
  return
22
26
  end
23
27
  commands.each_index do |index|
24
28
  command = commands[index]
25
29
  case command
26
- when "-a"
30
+ when "-a"
27
31
  @repo_type = 0
28
32
  when "-m"
29
33
  @repo_type = 1
30
34
  when "--commit-m"
31
35
  @default_commit_msg = commands[index + 1]
36
+ when "--no-merge-origin"
37
+ @need_merge_origin = false
38
+ when "--no-mr"
39
+ @need_creat_mr = false
32
40
  else
33
41
  end
34
42
  end
@@ -85,8 +93,7 @@ module Pixab
85
93
 
86
94
  # 合并代码
87
95
  def merge()
88
- is_need_merge = Utilities.display_default_dialog("是否需要合并远程代码到本地?")
89
- if is_need_merge
96
+ if need_merge_origin
90
97
  repos.each do |repo|
91
98
  system "mbox merge --repo #{repo["name"]}"
92
99
  end
@@ -95,30 +102,43 @@ module Pixab
95
102
 
96
103
  # 推送MR
97
104
  def push_and_create_mr()
98
- is_need_creat_mr = Utilities.display_default_dialog("是否需要推送到远程并创建MR?")
99
- if is_need_creat_mr
100
- reviewers = Utilities.display_dialog("请输入审核人员ID:\n子琰(979) 丕臻(1385) 再润(1569) 思保(1922)", "979 1385").split()
101
- mr_request_assign = ""
102
- reviewers.each do |reviewer|
105
+ if !need_creat_mr
106
+ return
107
+ end
108
+
109
+ feature_branch = repo_manager.feature_branch
110
+
111
+ reviewers = Utilities.display_dialog("正在创建Merge Request\n请输入审核人员ID:\n子琰(979) 丕臻(1385) 再润(1569) 思保(1922)", "979 1385").split()
112
+ mr_request_assign = ""
113
+ reviewers.each do |reviewer|
103
114
  mr_request_assign += " -o merge_request.assign=#{reviewer}"
115
+ end
116
+ mr_source_branch = "-o merge_request.remove_source_branch"
117
+
118
+ repos.each do |repo|
119
+ repo_name = repo["name"]
120
+ puts "\n[#{repo_name}]"
121
+ FileUtils.cd("#{repo_manager.root_path}/#{repo_name}")
122
+ current_branch = GitUtils.current_branch
123
+ if current_branch != feature_branch
124
+ puts "\n[!] The repo #{repo_name} is not in feature branch `#{feature_branch}`. Skip it.".yellow
125
+ next
104
126
  end
105
-
106
- mr_source_branch = "-o merge_request.remove_source_branch"
107
- repos.each do |repo|
108
- repo_name = repo["name"]
109
- puts repo_name
110
- repo_target_branch = repo["target_branch"]
111
- repo_last_branch = repo["last_branch"]
112
127
 
113
- FileUtils.cd("#{repo_manager.root_path}/#{repo_name}")
114
- log_content = `git log origin/#{repo_target_branch}..#{repo_last_branch} --pretty=format:"%H"`
115
- if log_content.empty?
116
- next
117
- end
118
- mr_target = "-o merge_request.target=#{repo_target_branch}"
119
- # mr_title = "-o merge_request.title=#{repo_last_branch}"
120
- `git push -o merge_request.create #{mr_target} #{mr_source_branch} #{mr_request_assign}`
128
+ repo_target_branch = repo["target_branch"]
129
+
130
+ log_content = `git log origin/#{repo_target_branch}..#{current_branch} --pretty=format:"%H"`
131
+ if log_content.empty?
132
+ puts "\n[!] branch `#{current_branch}` is same as branch `origin/#{repo_target_branch}`. Skip it.".yellow
133
+ next
134
+ end
135
+ mr_target = "-o merge_request.target=#{repo_target_branch}"
136
+ # mr_title = "-o merge_request.title=#{repo_last_branch}"
137
+ commad = "git push"
138
+ if repo["last_branch"].nil?
139
+ commad += " --set-upstream origin #{current_branch}"
121
140
  end
141
+ `#{commad} -o merge_request.create #{mr_target} #{mr_source_branch} #{mr_request_assign}`
122
142
  end
123
143
  end
124
144
 
data/lib/RepoManager.rb CHANGED
@@ -8,7 +8,7 @@ module Pixab
8
8
 
9
9
  class RepoManager
10
10
 
11
- attr_reader :root_path, :repos
11
+ attr_reader :root_path, :feature
12
12
 
13
13
  def initialize()
14
14
  read_repo_infos
@@ -27,10 +27,13 @@ module Pixab
27
27
  puts "Error: You are currently in Free Mode".red
28
28
  exit(1)
29
29
  end
30
- feature = obj["features"][current_feature_name.downcase]
31
- @repos = feature["repos"]
30
+ @feature = obj["features"][current_feature_name.downcase]
32
31
  end
33
32
 
33
+ def repos
34
+ feature["repos"]
35
+ end
36
+
34
37
  def main_repo
35
38
  repos.first
36
39
  end
@@ -43,6 +46,14 @@ module Pixab
43
46
  end
44
47
  return []
45
48
  end
49
+
50
+ def feature_name
51
+ feature["name"]
52
+ end
53
+
54
+ def feature_branch
55
+ feature["branch_prefix"] + feature_name
56
+ end
46
57
 
47
58
  end
48
59
 
data/lib/pixab/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pixab
4
- VERSION = "1.2.0"
4
+ VERSION = "1.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 廖再润
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-11 00:00:00.000000000 Z
11
+ date: 2023-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2