autowow 0.16.0 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70a57e753c44cf9f997b913dc482efb02cb3aeecb83f2c10a0188266213e1d85
4
- data.tar.gz: 680c9293783c4aceee7202e26ffafdce6e343930a7e015edb15a6da194d5750c
3
+ metadata.gz: 1f55bfd872a119778b302703a39cefb379d5338b3fe7e7bdab919d70d73fe350
4
+ data.tar.gz: a1194055e1a2ffa4e0c813a98e7e71e002a971a0cbeaa0615862bd5960f131f6
5
5
  SHA512:
6
- metadata.gz: 3456ebc8902996a1fbe51f4a180c75dd47118af1f3f38c88aef7bba6dff02802a3f0c7547bfe2a90d1480713d0e483594c5ef23278ec3bbcba4ebbff61b35685
7
- data.tar.gz: 456e92d320ce52568ea579ab1670b08f3d336eca9d5e9e77567f2907b9637c1607470f25463b35c234357536847bf2f3109dd2c76844c8ad2f02cb37c5d42211
6
+ metadata.gz: 1b912bfef14595af0c6900b51d6e36471b7cd1224dc0af0d6df8501610ef1cefe6019bde1082156bf4f26200c164e074c4b2bb1ef62abb0a8e85f3f7cee5fe1b
7
+ data.tar.gz: bf0a0804a2223c4472d8d4276f3b0af60a9de92494903c7a2671db1aba886d01b03a4c9ce364dce429ee98e515fb7b67daafcd174cef8d926adfd9b2c1ac7535
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  .idea
14
14
 
15
15
  *.gem
16
+ notes.*
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  #### Set of commands to [auto]mate [w]ay [o]f [w]orking
4
4
 
5
5
  <!--- Version informartion -->
6
- *You are viewing the README of version [v0.16.0](https://github.com/thisismydesign/autowow/releases/tag/v0.16.0). You can find other releases [here](https://github.com/thisismydesign/autowow/releases).*
6
+ *You are viewing the README of version [v0.16.1](https://github.com/thisismydesign/autowow/releases/tag/v0.16.1). You can find other releases [here](https://github.com/thisismydesign/autowow/releases).*
7
7
  <!--- Version informartion end -->
8
8
 
9
9
  | Branch | Status |
@@ -1,6 +1,10 @@
1
1
  module Autowow
2
2
  module Commands
3
3
  module Rbenv
4
+ def rbenv
5
+ ["rbenv"]
6
+ end
7
+
4
8
  def version
5
9
  ["rbenv", "local"]
6
10
  end
@@ -14,11 +14,11 @@ module Autowow
14
14
  end
15
15
 
16
16
  def changes_not_on_remote(branch)
17
- cmd + terminal_options + ["log", branch, "--not", "--remotes"]
17
+ cmd + terminal_options + ["log", "--not", "--remotes", branch]
18
18
  end
19
19
 
20
20
  def branch_list
21
- cmd + ["for-each-ref", "--format=%(refname)", "refs/heads/"]
21
+ cmd + ["for-each-ref", "--format='%(refname:short)'", "refs/heads/"]
22
22
  end
23
23
 
24
24
  def push(branch = nil, remote = nil)
@@ -93,9 +93,16 @@ module Autowow
93
93
  cmd + ["reset", "--hard", branch]
94
94
  end
95
95
 
96
- # Doesn't work on Windows
97
- def current_branch_remote
98
- cmd + ["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"]
96
+ def upstream_tracking(branch)
97
+ cmd + ["for-each-ref", "--format=%'(upstream:short)'", "refs/heads/#{branch}"]
98
+ end
99
+
100
+ def current_ref
101
+ cmd + ["symbolic-ref", "--quiet", "HEAD"]
102
+ end
103
+
104
+ def show_ref(branch)
105
+ cmd + ["show-ref", branch]
99
106
  end
100
107
 
101
108
  include ReflectionUtils::CreateModuleFunctions
@@ -12,6 +12,14 @@ module Autowow
12
12
  include Executor
13
13
  include StringDecorator
14
14
 
15
+ def exists?
16
+ begin
17
+ quiet.run!(rbenv).success?
18
+ rescue SystemCallError
19
+ false
20
+ end
21
+ end
22
+
15
23
  def ruby_versions
16
24
  logger.info(used_versions)
17
25
  end
@@ -46,6 +46,10 @@ module Autowow
46
46
  greet(latest_project_info)
47
47
  end
48
48
 
49
+ def is_tracked?(branch)
50
+ !quiet.run!(Vcs.upstream_tracking(branch).join(" ")).out.strip.empty?
51
+ end
52
+
49
53
  def self.force_pull
50
54
  pretty_with_output.run(git_status)
51
55
  branch = working_branch
@@ -199,7 +203,11 @@ module Autowow
199
203
  end
200
204
 
201
205
  def branch_pushed(branch)
202
- quiet.run(changes_not_on_remote(branch)).out.empty?
206
+ is_tracked?(branch) && commits_pushed?(branch)
207
+ end
208
+
209
+ def commits_pushed?(branch)
210
+ quiet.run(changes_not_on_remote(branch)).out.strip.empty?
203
211
  end
204
212
 
205
213
  def greet(latest_project_info = nil)
@@ -211,6 +219,9 @@ module Autowow
211
219
  logger.info(latest_project_info)
212
220
  check_projects_older_than(1, :months)
213
221
  end
222
+
223
+ return unless Rbenv.exists?
224
+
214
225
  obsolete_rubies = Rbenv.obsolete_versions
215
226
  if obsolete_rubies.any?
216
227
  logger.info("\nThe following Ruby versions are not used by any projects, maybe consider removing them?")
@@ -223,7 +234,7 @@ module Autowow
223
234
  def check_projects_older_than(quantity, unit)
224
235
  old_projects = Fs.older_than(git_projects, quantity, unit)
225
236
  deprecated_projects = old_projects.reject do |project|
226
- Dir.chdir(project) { branches.reject { |branch| branch_pushed(branch) }.any? }
237
+ Dir.chdir(project) { any_branch_not_pushed? || uncommitted_changes?(quiet.run(git_status).out) }
227
238
  end
228
239
 
229
240
  logger.info("The following projects have not been touched for more than #{quantity} #{unit} and all changes have been pushed, maybe consider removing them?") unless deprecated_projects.empty?
@@ -233,6 +244,10 @@ module Autowow
233
244
  end
234
245
  end
235
246
 
247
+ def any_branch_not_pushed?
248
+ branches.reject { |branch| branch_pushed(branch) }.any?
249
+ end
250
+
236
251
  def get_latest_repo_info
237
252
  latest = latest_repo
238
253
  time_diff = TimeDifference.between(File.mtime(latest), Time.now).humanize_higher_than(:days).downcase
@@ -245,7 +260,7 @@ module Autowow
245
260
  end
246
261
 
247
262
  def branches
248
- quiet.run(branch_list).out.clean_lines.map { |line| line[%r{(?<=refs/heads/)(.*)}] }
263
+ quiet.run(branch_list.join(" ")).out.clean_lines
249
264
  end
250
265
 
251
266
  def uncommitted_changes?(status)
@@ -1,3 +1,3 @@
1
1
  module Autowow
2
- VERSION = "0.16.0"
2
+ VERSION = "0.16.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autowow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thisismydesign
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-18 00:00:00.000000000 Z
11
+ date: 2019-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: easy_logging