rfix 1.0.8.pre.108 → 1.0.8.pre.109

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: 537cb3de2248f7c030873f1435b0e4b0a8b7568e9bebfc6055a3efca5e126f06
4
- data.tar.gz: 104a7dbbe3bbbc108a79629cc81de2d341ddea2a74fc68716e07a38e3d3cf2c3
3
+ metadata.gz: 4097e2bfdc301c182d0b04d369576a35ffa391f1afa4b7e8643daa52e1dc1aeb
4
+ data.tar.gz: c324d50979ea839dae4d3738971e23c69e601f05c049d72bc5ebe6cb9dc5cb53
5
5
  SHA512:
6
- metadata.gz: 72d111d79b2bc9a7420d78f0efa388730b7adf66545280a91af5f3fc3f69d0a234c6ccbab984cd01d800233aa7a6de3e5b7a8f7639e7df067b3bb528fd4885a4
7
- data.tar.gz: dfef4fb22d0757f4bf1259d96309358111fd7eeacc08d621c52175d9e39cc4a395e3225a7420293bea7f870c5016918f0da80d852eb066d7c91e265f5c6ef509
6
+ metadata.gz: 39d7ffdf2ef3d46b6a7e5c9eb19e5942331c0dcf010524c49a8a0ff59c25290998d5196c2199f76cd80dbd5a151d5f0fe9d20d8b7d2de1527824eaeea7e0576e
7
+ data.tar.gz: 7efe96eef04ec0dc1cf3344db5b5d68a2a88cd56cc2aea8211566d1350053e2a209a19e586a6559274a8853ae34cd8478109bc3d85a01ac2afdec75acaa01395
data/exe/rfix CHANGED
@@ -20,6 +20,10 @@ extend Rfix::Log
20
20
  Rfix.init!
21
21
  CLI::UI::StdoutRouter.enable
22
22
 
23
+ if ARGV.include?("--debug")
24
+ Rfix.debug!
25
+ end
26
+
23
27
  say "Using RuboCop {{yellow:#{RuboCop::Version.version}}}"
24
28
  say_debug "Current directory {{italic:#{Dir.pwd}}}"
25
29
  say_debug "[Ruby] {{italic:#{RbConfig.ruby}}}"
@@ -55,6 +59,8 @@ when "info"
55
59
  say "Using OS {{yellow:#{Rfix.current_os}}}"
56
60
  say "Using Git {{yellow:#{Rfix.git_version}}}"
57
61
  say "Using Ruby {{yellow:#{Rfix.ruby_version}}}"
62
+ say "Current Git branch {{yellow:#{Rfix.current_branch}}}"
63
+ say "Number of commits {{yellow:#{Rfix.number_of_commits_since}}}"
58
64
  exit 0
59
65
  when "lint"
60
66
  Rfix.lint_mode!
data/file.rb ADDED
@@ -0,0 +1 @@
1
+ "hello"
@@ -7,11 +7,13 @@ require "rfix/log"
7
7
  module Rfix::Cmd
8
8
  include Rfix::Log
9
9
 
10
- def cmd(*args)
10
+ def cmd(*args, quiet: false)
11
11
  out, err, status = Open3.capture3(*args)
12
12
 
13
+ # say "[Cmd] {{italic:#{args.join(' ')}}}"
13
14
  unless status.success?
14
15
  return yield if block_given?
16
+ return if quiet
15
17
 
16
18
  say_error "[Cmd] {{italic:#{args.join(' ')}}}"
17
19
  say_error "[Pwd] {{italic:#{Dir.pwd}}}"
@@ -9,8 +9,20 @@ module Rfix::GitHelper
9
9
  include Rfix::Log
10
10
  include Rfix::Cmd
11
11
 
12
- def git(*args, &block)
13
- cmd("git", *args, &block)
12
+ def git(*args, root: Dir.pwd, quiet: false, &block)
13
+ args.unshift *["--git-dir", File.join(root, ".git")]
14
+ args.unshift *["--work-tree", root]
15
+ cmd("git", *args, quiet: quiet, &block)
16
+ end
17
+
18
+ def has_branch?(branch)
19
+ cmd_succeeded?("git", "cat-file", "-t", branch)
20
+ end
21
+
22
+ def dirty?(path)
23
+ Dir.chdir(path) do
24
+ !cmd_succeeded?("git diff --quiet")
25
+ end
14
26
  end
15
27
 
16
28
  def params
@@ -28,3 +40,8 @@ module Rfix::GitHelper
28
40
  ]
29
41
  end
30
42
  end
43
+
44
+ # TODO: Rename above to just ::Git
45
+ module Rfix::Git
46
+ extend Rfix::GitHelper
47
+ end
@@ -17,7 +17,9 @@ module Rfix::Log
17
17
  end
18
18
 
19
19
  def say_debug(message)
20
- CLI::UI.puts("{{*}} [{{info:Debug}}] #{message}")
20
+ unless Rfix.debug?
21
+ CLI::UI.puts("{{*}} [{{info:Debug}}] #{message}")
22
+ end
21
23
  end
22
24
 
23
25
  def say_abort(message)
@@ -48,6 +48,22 @@ module Rfix
48
48
  CLI::UI.fmt(cmds.join("\n"), enable_color: true)
49
49
  end
50
50
 
51
+ def current_branch
52
+ git("rev-parse", "--abbrev-ref", "HEAD").first
53
+ end
54
+
55
+ def debug?
56
+ @debug
57
+ end
58
+
59
+ def debug!
60
+ @debug = true
61
+ end
62
+
63
+ def number_of_commits_since
64
+ cmd("git rev-list master..HEAD | wc -l").first
65
+ end
66
+
51
67
  def config
52
68
  @config
53
69
  end
@@ -112,6 +128,7 @@ module Rfix
112
128
  }
113
129
 
114
130
  @store = RuboCop::ConfigStore.new
131
+ @debug = false
115
132
  auto_correct!
116
133
  end
117
134
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8.pre.108
4
+ version: 1.0.8.pre.109
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander
@@ -141,6 +141,7 @@ files:
141
141
  - ci/Gemfile.rubocop-0.85.1.lock
142
142
  - ci/Gemfile.rubocop-0.85.lock
143
143
  - exe/rfix
144
+ - file.rb
144
145
  - lib/rfix.rb
145
146
  - lib/rfix/cmd.rb
146
147
  - lib/rfix/extensions/extensions.rb