cocoapods-tag 0.0.4 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/cocoapods-tag/command/tag/auto.rb +3 -1
- data/lib/cocoapods-tag/command/tag/repo_list.rb +77 -0
- data/lib/cocoapods-tag/command/tag.rb +1 -0
- data/lib/cocoapods-tag/gem_version.rb +1 -1
- data/lib/cocoapods-tag/tag.rb +46 -25
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a72f4e68daa2d911dd619108de273824072102bcf41474da0744952efb9f481f
|
4
|
+
data.tar.gz: 5aaf617407f0136aca11b65d8e9aff5d59c3ee3775f63f7bebff40ebaadbc7ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 578caf1cdb4c0954091e2ae9ed3a1f0974bed2daca2860b2edac05f1c1d887573c7ee1344c9a918fc84b6f30e9527b57fd218c5b31cd1b12b63ea25a8f7fc521
|
7
|
+
data.tar.gz: e2229325f9eb5a15b0c6b7a18f838efe7ad9abd7a59451673d6281d0ba7a9f3e008dc191245d2ee3be37a07fdf9f657928a9aa8bd5a0e69e2b715db19c240664
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ $ gem install cocoapods-tag
|
|
53
53
|
$ pod tag 0.1.7 "修改podspec版本号为0.1.7" --work-dir=xxx
|
54
54
|
```
|
55
55
|
|
56
|
-
* 为tag
|
56
|
+
* 为tag添加前后缀 **(前后缀与版本号中间会自动用`-`分隔,不需要手动添加)**
|
57
57
|
|
58
58
|
以下面这行命令为例,`podspec`中的`version`为`0.1.7`,`source`字段中的`tag`为`mtxx-0.1.7-beta1`,最终推送到远端仓库的`tag`也是`mtxx-0.1.7-beta1`
|
59
59
|
|
@@ -41,6 +41,7 @@ DESC
|
|
41
41
|
def self.options
|
42
42
|
[
|
43
43
|
['--quick', '跳过一些耗时校验,如:远端仓库是否已经有该tag'],
|
44
|
+
['--skip-push-commit', '跳过推送commit到对应分支'],
|
44
45
|
['--remote=REMOTE', '指定tag推送到的远端仓库,可以通过`git remote -v`查看'],
|
45
46
|
['--spec-repo=SPECREPO', 'podspec推送到的repo,可以通过`pod repo list`查看'],
|
46
47
|
['--work-dir=WORKDIR', '执行命令的工作区'],
|
@@ -54,6 +55,7 @@ DESC
|
|
54
55
|
@commit_msg = argv.shift_argument
|
55
56
|
@tag_msg = argv.shift_argument
|
56
57
|
@quick = argv.flag?('quick', false)
|
58
|
+
@skip_push_commit = argv.flag?('skip-push-commit', false)
|
57
59
|
@remote = argv.option('remote', false)
|
58
60
|
@spec_repo = argv.option('spec-repo', nil)
|
59
61
|
@work_dir = argv.option('work-dir', nil)
|
@@ -75,7 +77,7 @@ DESC
|
|
75
77
|
raise Informative, "不存在工作目录`#{@work_dir}`" unless File.exist?(@work_dir)
|
76
78
|
Dir.chdir(@work_dir)
|
77
79
|
end
|
78
|
-
tag = Pod::Tag.new(@version, @tag, @commit_msg, @tag_msg, @spec_repo, @quick, @remote)
|
80
|
+
tag = Pod::Tag.new(@version, @tag, @commit_msg, @tag_msg, @spec_repo, @quick, @remote, @skip_push_commit)
|
79
81
|
tag.create
|
80
82
|
end
|
81
83
|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
|
2
|
+
module Pod
|
3
|
+
class Command
|
4
|
+
class Tag < Command
|
5
|
+
class RepoList < Tag
|
6
|
+
include Pod
|
7
|
+
|
8
|
+
self.summary = '打印本地的 podspec 仓库'
|
9
|
+
|
10
|
+
self.description = <<-DESC
|
11
|
+
#{self.summary}
|
12
|
+
DESC
|
13
|
+
|
14
|
+
def self.options
|
15
|
+
[
|
16
|
+
['--format=FORMAT', '输出结果格式化,可选项为`json/yml(yaml)/plain`'],
|
17
|
+
].concat(super)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(argv)
|
21
|
+
@format = argv.option('format', 'plain')
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def run
|
26
|
+
@sources = config.sources_manager.all
|
27
|
+
if @format == 'json'
|
28
|
+
print_json
|
29
|
+
elsif @format == 'yml' || @format == 'yaml'
|
30
|
+
print_yml
|
31
|
+
else
|
32
|
+
print_plain
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def print_json
|
39
|
+
require 'json'
|
40
|
+
UI.puts JSON.pretty_generate(sources)
|
41
|
+
end
|
42
|
+
|
43
|
+
def print_yml
|
44
|
+
require 'yaml'
|
45
|
+
UI.puts sources.to_yaml
|
46
|
+
end
|
47
|
+
|
48
|
+
def print_plain
|
49
|
+
list = Pod::Command::Repo::List.new(CLAide::ARGV.new([]))
|
50
|
+
list.validate!
|
51
|
+
list.run
|
52
|
+
end
|
53
|
+
|
54
|
+
def sources
|
55
|
+
result = []
|
56
|
+
@sources.each do |source|
|
57
|
+
type = source.type
|
58
|
+
if source.is_a?(Pod::CDNSource)
|
59
|
+
type = 'CDN'
|
60
|
+
elsif source.git?
|
61
|
+
type = 'git'
|
62
|
+
end
|
63
|
+
source_hash = {
|
64
|
+
'name' => source.name,
|
65
|
+
'url' => source.url,
|
66
|
+
'path' => source.repo.to_s,
|
67
|
+
'type' => type
|
68
|
+
}
|
69
|
+
result << source_hash
|
70
|
+
end
|
71
|
+
result
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/cocoapods-tag/tag.rb
CHANGED
@@ -8,7 +8,7 @@ module Pod
|
|
8
8
|
GIT_REPO = ".git".freeze
|
9
9
|
PODSPEC_EXT = %w[podspec podspec.json].freeze
|
10
10
|
|
11
|
-
def initialize(version, tag, commit_msg, tag_msg, spec_repo = nil, quick = false, remote_name = nil)
|
11
|
+
def initialize(version, tag, commit_msg, tag_msg, spec_repo = nil, quick = false, remote_name = nil, skip_push_commit = false )
|
12
12
|
@version = version || raise(Informative, "缺少必填参数`version`")
|
13
13
|
@tag = tag || raise(Informative, "缺少必填参数`tag`")
|
14
14
|
@commit_msg = commit_msg || raise(Informative, "缺少必填参数`commit_msg`")
|
@@ -16,6 +16,7 @@ module Pod
|
|
16
16
|
@spec_repo = spec_repo
|
17
17
|
@quick = quick
|
18
18
|
@remote = remote_name
|
19
|
+
@skip_push_commit = skip_push_commit
|
19
20
|
end
|
20
21
|
|
21
22
|
public
|
@@ -28,7 +29,7 @@ module Pod
|
|
28
29
|
# 正则校验版本号
|
29
30
|
check_version
|
30
31
|
# 检查本地是否有 spec_repo
|
31
|
-
check_spec_repo if @spec_repo
|
32
|
+
# check_spec_repo if @spec_repo
|
32
33
|
# 检查 git repo
|
33
34
|
check_git_repo
|
34
35
|
# 加载 podspec
|
@@ -97,28 +98,44 @@ module Pod
|
|
97
98
|
# 是否与远端仓库关联
|
98
99
|
raise Informative, "本地git仓库没有与远端仓库关联,请先使用`git remote add`关联远端仓库" if remote.nil?
|
99
100
|
|
100
|
-
|
101
|
-
|
102
|
-
print "\n检查本地git仓库是否与远端仓库同步\n".yellow
|
103
|
-
local_commit = `git rev-parse #{remote}/HEAD`.chomp
|
104
|
-
remote_commit = `git ls-remote --head #{remote} #{current_branch}`.split("\t")[0]
|
105
|
-
unless local_commit == remote_commit
|
106
|
-
msg = <<-MSG
|
107
|
-
本地git仓库没有与远端仓库同步,请先执行以下操作:
|
108
|
-
1.`git pull`或`git fetch + git rebase`拉取最新代码
|
109
|
-
2.`git push`推送本地仓库commit
|
110
|
-
MSG
|
111
|
-
raise Informative, msg
|
112
|
-
end
|
101
|
+
# 是否处于 detached 状态
|
102
|
+
raise Informative, "当前处于detached状态,请先切到分支再进行操作" if current_branch == "HEAD"
|
113
103
|
|
104
|
+
# # 是否有未提交的改动
|
105
|
+
# raise Informative, "本地有未提交的改动,请先提交或暂存" unless `git status --porcelain`.split("\n").empty?
|
106
|
+
|
107
|
+
unless @quick
|
114
108
|
# 检查本地是否已经有该 tag
|
115
109
|
print "\n检查本地仓库是否有tag:`#{@tag}`\n".yellow
|
116
|
-
raise Informative, "
|
110
|
+
raise Informative, "本地仓库已经存在tag:#{@tag}" if `git tag`.split("\n").include?(@tag)
|
117
111
|
|
118
112
|
# 判断远端是否已经有该 tag
|
119
113
|
print "\n检查远端仓库是否有tag:`#{@tag}`\n".yellow
|
120
114
|
tags = `git ls-remote --tags #{remote}`.split("\n").select { |tag| tag.include?("refs/tags/#{@tag}") }
|
121
|
-
raise Informative, "
|
115
|
+
raise Informative, "远端仓库已经有tag:#{@tag}" unless tags.empty?
|
116
|
+
|
117
|
+
# 校验本地 git 是否与远端仓库同步
|
118
|
+
print "\n检查本地git仓库是否与远端仓库同步\n".yellow
|
119
|
+
`git fetch #{remote}`
|
120
|
+
remote_br = `git rev-parse --abbrev-ref #{current_branch}@{u}`
|
121
|
+
unless remote_br == ''
|
122
|
+
remote_commit_count = `git rev-list --right-only --count #{current_branch}...#{remote_br}`.chomp.to_i
|
123
|
+
local_commit_count = `git rev-list --left-only --count #{current_branch}...#{remote_br}`.chomp.to_i
|
124
|
+
# 本地落后远端
|
125
|
+
unless remote_commit_count == 0
|
126
|
+
msg = <<-MSG
|
127
|
+
本地git仓库落后于远端仓库`#{remote_commit_count}`个提交
|
128
|
+
请先执行`git pull`或`git fetch #{remote} + git rebase #{remote_br}`拉取最新代码
|
129
|
+
MSG
|
130
|
+
raise Informative, msg
|
131
|
+
end
|
132
|
+
|
133
|
+
# 本地有未 push 的 commit
|
134
|
+
unless local_commit_count == 0
|
135
|
+
msg = "本地git仓库有`#{local_commit_count}`个commit未提交,请先执行`git push`提交"
|
136
|
+
raise Informative, msg
|
137
|
+
end
|
138
|
+
end
|
122
139
|
end
|
123
140
|
|
124
141
|
end
|
@@ -140,6 +157,10 @@ module Pod
|
|
140
157
|
if source['git'] && source['git'].strip == ''
|
141
158
|
raise Informative, "source中git字段不能为空"
|
142
159
|
end
|
160
|
+
# git字段只能是ssh
|
161
|
+
if source['git'] && source['git'] =~ /^(http|https)/
|
162
|
+
raise Informative, "source中git字段不能是http或https,只能是ssh"
|
163
|
+
end
|
143
164
|
end
|
144
165
|
|
145
166
|
# 修改podspec
|
@@ -161,8 +182,8 @@ module Pod
|
|
161
182
|
def modify_podspec_ruby(file)
|
162
183
|
org_source = @spec_hash['source']
|
163
184
|
des_source = "{ :git => '#{org_source['git']}', :tag => '#{@tag}' }"
|
164
|
-
|
165
|
-
|
185
|
+
lines = []
|
186
|
+
File.open(file, 'r:utf-8') do |f|
|
166
187
|
f.each_line do |line|
|
167
188
|
if line =~ /(^\s*.+\.version\s*=\s*).*/
|
168
189
|
line = line.sub(/(^\s*.+\.version\s*=\s*).*/, "#{$1}'#{@version}'")
|
@@ -172,9 +193,9 @@ module Pod
|
|
172
193
|
end
|
173
194
|
lines << line
|
174
195
|
end
|
175
|
-
|
176
|
-
|
177
|
-
|
196
|
+
end
|
197
|
+
File.open(file, 'w:utf-8') do |f|
|
198
|
+
f.write(lines.join(""))
|
178
199
|
end
|
179
200
|
end
|
180
201
|
|
@@ -185,7 +206,7 @@ module Pod
|
|
185
206
|
'git'=> @spec_hash['source']['git'],
|
186
207
|
'tag'=> "#{@tag}"
|
187
208
|
}
|
188
|
-
File.open(file, 'w') do |f|
|
209
|
+
File.open(file, 'w:utf-8') do |f|
|
189
210
|
f.write(@spec_hash)
|
190
211
|
end
|
191
212
|
end
|
@@ -196,7 +217,7 @@ module Pod
|
|
196
217
|
begin
|
197
218
|
`git add #{podspec}`
|
198
219
|
`git commit -m "#{@commit_msg}"`
|
199
|
-
`git push #{remote} #{current_branch}`
|
220
|
+
`git push #{remote} #{current_branch}` unless @skip_push_commit
|
200
221
|
rescue Pod::StandardError => e
|
201
222
|
@error = e
|
202
223
|
print "推送commit到远端git仓库`#{remote}/#{current_branch}`失败:#{e}".red
|
@@ -249,7 +270,7 @@ module Pod
|
|
249
270
|
# 获取当前分支
|
250
271
|
def current_branch
|
251
272
|
@current_branch ||= begin
|
252
|
-
`git
|
273
|
+
`git rev-parse --abbrev-ref HEAD`.chomp
|
253
274
|
end
|
254
275
|
end
|
255
276
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/cocoapods-tag/command/tag.rb
|
67
67
|
- lib/cocoapods-tag/command/tag/auto.rb
|
68
68
|
- lib/cocoapods-tag/command/tag/create.rb
|
69
|
+
- lib/cocoapods-tag/command/tag/repo_list.rb
|
69
70
|
- lib/cocoapods-tag/command/tag/spec_push.rb
|
70
71
|
- lib/cocoapods-tag/gem_version.rb
|
71
72
|
- lib/cocoapods-tag/helper/asker.rb
|