cocoapods-tag 0.0.4 → 0.0.5
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 +4 -4
- data/README.md +1 -1
- data/lib/cocoapods-tag/command/tag/auto.rb +3 -1
- data/lib/cocoapods-tag/gem_version.rb +1 -1
- data/lib/cocoapods-tag/tag.rb +40 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bcf6776d9aecce496fc5ee724891375b4244907a9cec5dc0cc68e0bec72e9b1
|
4
|
+
data.tar.gz: 47e3f0020ec0f2ebd1be45ae35fdf49f94d7f185a9f46b0186abd0681fe0fd2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dec037cdb109bb8396ff9871f3ca00b89c83da4f1574f1e2df71d65eecec348523205d93a206819bd7c39882fd4a991e8b65903b95892e9599bf2db6d39dec9
|
7
|
+
data.tar.gz: 3e8190ebe75421b767616c7590646f8679fce382cf87bd3546d703643d6144a400df0fe6878e5a83a09c36b43717affb12a3cdaec6a2fa19b1559d1eb61436a4
|
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
|
|
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
|
@@ -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
|
|
114
|
-
|
115
|
-
|
116
|
-
raise Informative, "本地已经存在tag:#{@tag}" if `git tag`.split("\n").include?(@tag)
|
104
|
+
# # 是否有未提交的改动
|
105
|
+
# raise Informative, "本地有未提交的改动,请先提交或暂存" unless `git status --porcelain`.split("\n").empty?
|
117
106
|
|
107
|
+
# 检查本地是否已经有该 tag
|
108
|
+
print "\n检查本地仓库是否有tag:`#{@tag}`\n".yellow
|
109
|
+
raise Informative, "本地仓库已经存在tag:#{@tag}" if `git tag`.split("\n").include?(@tag)
|
110
|
+
|
111
|
+
unless @quick
|
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
|
@@ -161,7 +178,7 @@ module Pod
|
|
161
178
|
def modify_podspec_ruby(file)
|
162
179
|
org_source = @spec_hash['source']
|
163
180
|
des_source = "{ :git => '#{org_source['git']}', :tag => '#{@tag}' }"
|
164
|
-
File.open(file, 'r') do |f|
|
181
|
+
File.open(file, 'r:utf-8') do |f|
|
165
182
|
lines = []
|
166
183
|
f.each_line do |line|
|
167
184
|
if line =~ /(^\s*.+\.version\s*=\s*).*/
|
@@ -172,7 +189,7 @@ module Pod
|
|
172
189
|
end
|
173
190
|
lines << line
|
174
191
|
end
|
175
|
-
File.open(file, 'w') do |f|
|
192
|
+
File.open(file, 'w:utf-8') do |f|
|
176
193
|
f.write(lines.join(""))
|
177
194
|
end
|
178
195
|
end
|
@@ -185,7 +202,7 @@ module Pod
|
|
185
202
|
'git'=> @spec_hash['source']['git'],
|
186
203
|
'tag'=> "#{@tag}"
|
187
204
|
}
|
188
|
-
File.open(file, 'w') do |f|
|
205
|
+
File.open(file, 'w:utf-8') do |f|
|
189
206
|
f.write(@spec_hash)
|
190
207
|
end
|
191
208
|
end
|
@@ -196,7 +213,7 @@ module Pod
|
|
196
213
|
begin
|
197
214
|
`git add #{podspec}`
|
198
215
|
`git commit -m "#{@commit_msg}"`
|
199
|
-
`git push #{remote} #{current_branch}`
|
216
|
+
`git push #{remote} #{current_branch}` unless @skip_push_commit
|
200
217
|
rescue Pod::StandardError => e
|
201
218
|
@error = e
|
202
219
|
print "推送commit到远端git仓库`#{remote}/#{current_branch}`失败:#{e}".red
|
@@ -249,7 +266,7 @@ module Pod
|
|
249
266
|
# 获取当前分支
|
250
267
|
def current_branch
|
251
268
|
@current_branch ||= begin
|
252
|
-
`git
|
269
|
+
`git rev-parse --abbrev-ref HEAD`.chomp
|
253
270
|
end
|
254
271
|
end
|
255
272
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|