abak-flow 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/Gemfile +1 -5
- data/VERSION +1 -1
- data/abak-flow.gemspec +2 -2
- data/lib/abak-flow/pull_request.rb +10 -0
- data/lib/abak-flow/request.rb +58 -0
- data/lib/abak-flow/version.rb +1 -1
- metadata +6 -6
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/abak-flow.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ['lib']
|
20
20
|
|
21
|
-
s.add_runtime_dependency 'hub', '~> 1.
|
21
|
+
s.add_runtime_dependency 'hub', '~> 1.10.3'
|
22
22
|
s.add_runtime_dependency 'commander', '~> 4.1.2'
|
23
|
-
s.add_runtime_dependency 'octokit', '~> 1.
|
23
|
+
s.add_runtime_dependency 'octokit', '~> 1.19.0'
|
24
24
|
end
|
@@ -37,6 +37,14 @@ module Abak::Flow
|
|
37
37
|
"#{upstream_project.owner}/#{upstream_project.name}"
|
38
38
|
end
|
39
39
|
end
|
40
|
+
alias_method :upstream_project, :from_repo
|
41
|
+
|
42
|
+
def origin_project
|
43
|
+
@origin_project ||= begin
|
44
|
+
origin_project = repository.remote_by_name('origin').project
|
45
|
+
"#{origin_project.owner}/#{origin_project.name}"
|
46
|
+
end
|
47
|
+
end
|
40
48
|
|
41
49
|
def origin_repo
|
42
50
|
@origin_repo ||= repository.main_project.remote.name
|
@@ -207,5 +215,7 @@ module Abak::Flow
|
|
207
215
|
[:origin, :upstream, :api_user, :api_token]
|
208
216
|
end
|
209
217
|
end
|
218
|
+
|
219
|
+
class StrategyStatus < StrategyReadycheck; end
|
210
220
|
end
|
211
221
|
end
|
data/lib/abak-flow/request.rb
CHANGED
@@ -173,4 +173,62 @@ module Abak::Flow
|
|
173
173
|
say color('Хм ... кажется у вас все готово к работе', :debug).to_s if request.valid?
|
174
174
|
end
|
175
175
|
end
|
176
|
+
|
177
|
+
command :garbage do |c|
|
178
|
+
c.syntax = 'git request status'
|
179
|
+
c.description = 'Проверить пригодность удаленных (origin) веток и возможность их уничтожения (ветки master, develop игнорируются)'
|
180
|
+
|
181
|
+
c.action do |args, options|
|
182
|
+
config = Abak::Flow::Config.current
|
183
|
+
github_client = Abak::Flow::GithubClient.connect(config)
|
184
|
+
request = Abak::Flow::PullRequest.new(config, :strategy => :status)
|
185
|
+
|
186
|
+
exit unless request.valid?
|
187
|
+
|
188
|
+
messages = {unused: ["отсутствует в upstream репозитории", :notice],
|
189
|
+
differ: ["отличается от origin репозитория", :warning],
|
190
|
+
missing: ["отсутствует в локальном репозитории", :warning]}
|
191
|
+
|
192
|
+
say "=> Обновляю данные о репозитории upstream"
|
193
|
+
%w(origin upstream).each { |remote| Hub::Runner.execute('fetch', remote, '-p') }
|
194
|
+
|
195
|
+
say "=> Загружаю список веток для origin"
|
196
|
+
branches = github_client.branches(request.origin_project).
|
197
|
+
reject { |branch| %w(master develop).include? branch.name }
|
198
|
+
|
199
|
+
say "=> На origin найдено веток: #{branches.count}\n\n"
|
200
|
+
branches.each_with_index do |branch, index|
|
201
|
+
index += 1
|
202
|
+
|
203
|
+
base = Abak::Flow::PullRequest.branch_by_prefix branch.name.split('/').first
|
204
|
+
|
205
|
+
upstream_branch = %x(git branch -r --contain #{branch.commit.sha} | grep upstream/#{base} 2> /dev/null).strip
|
206
|
+
local_sha = %x(git show #{branch.name} --format=%H --no-notes 2> /dev/null | head -n 1).strip
|
207
|
+
|
208
|
+
statuses = {
|
209
|
+
unused: upstream_branch.empty?,
|
210
|
+
differ: !local_sha.empty? && local_sha != branch.commit.sha,
|
211
|
+
missing: local_sha.empty?
|
212
|
+
}
|
213
|
+
|
214
|
+
unless statuses.values.inject &:|
|
215
|
+
say color("#{index}) #{branch.name} → можно удалить", :debug).to_s
|
216
|
+
say "\n"
|
217
|
+
next
|
218
|
+
end
|
219
|
+
|
220
|
+
diagnoses = statuses.select { |_,bool| bool }.
|
221
|
+
map { |name,_| messages[name].first }.
|
222
|
+
map { |msg| "#{' ' * (index.to_s.length + 2)} ↪ #{msg}" }.
|
223
|
+
join("\n")
|
224
|
+
|
225
|
+
if statuses.select { |_,bool| bool }.keys == [:missing]
|
226
|
+
say color("#{index}) #{branch.name} → потенциально можно удалить", :warning).to_s
|
227
|
+
say "#{diagnoses}\n\n"
|
228
|
+
else
|
229
|
+
say "#{index}) #{branch.name}\n#{diagnoses}\n\n"
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
176
234
|
end
|
data/lib/abak-flow/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abak-flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hub
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.10.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: 1.10.3
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: commander
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.
|
53
|
+
version: 1.19.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.19.0
|
62
62
|
description: Простой набор правил и комманд, заточеных для работы в git-flow с использование
|
63
63
|
в качестве удаленного репозитория github
|
64
64
|
email:
|