rfix 1.0.7.pre.65 → 1.0.8.pre.108

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ require "bundler"
2
+
3
+ module GemHelper
4
+ def source_for(name:, &block)
5
+ bundle_root = Bundler.bundle_path.join('bundler/gems')
6
+ path = Dir.glob(bundle_root.join("#{name}-*").to_s).first
7
+ path or raise "Could not find source for #{name}, run bundle install first"
8
+ block(path)
9
+ rescue StandardError => e
10
+ puts "[Bundler] #{e}"
11
+ end
12
+ end
@@ -19,7 +19,9 @@ module Rfix::GitHelper
19
19
  "--no-renames",
20
20
  "--no-merges",
21
21
  "--first-parent",
22
- "--diff-filter=AM",
22
+ "--find-renames",
23
+ "--find-copies",
24
+ "--diff-filter=AMCR",
23
25
  "-U0",
24
26
  "--no-color",
25
27
  "-p"
@@ -13,11 +13,11 @@ module Rfix::Log
13
13
  end
14
14
 
15
15
  def say_error_sub(message)
16
- CLI::UI.puts("#{message}")
16
+ CLI::UI.puts(message.to_s)
17
17
  end
18
18
 
19
19
  def say_debug(message)
20
- CLI::UI.puts("{{*}} #{message}")
20
+ CLI::UI.puts("{{*}} [{{info:Debug}}] #{message}")
21
21
  end
22
22
 
23
23
  def say_abort(message)
@@ -0,0 +1,56 @@
1
+ require "tmpdir"
2
+
3
+ module RakeHelper
4
+ include Rfix::Log
5
+ include Rfix::Cmd
6
+ include Rfix::GitHelper
7
+
8
+ def dirty?
9
+ !cmd_succeeded?("git diff --quiet")
10
+ end
11
+
12
+ def clone(github:, ref:)
13
+ Dir.mktmpdir(github.split("/")) do |src|
14
+ say "Clone {{info:#{github}}}, hold on ..."
15
+ git("clone", "https://github.com/#{github}", src)
16
+ Dir.chdir(src) do
17
+ say "Check out {{info:#{ref}}}"
18
+ git("reset", "--hard", ref)
19
+ git("clean", "-f", "-d")
20
+ end
21
+
22
+ dest = File.join("vendor", github)
23
+ say "Copy files to {{info:#{dest}}}"
24
+ FileUtils.mkdir_p(dest)
25
+ FileUtils.copy_entry(src, dest, true, true, true)
26
+ end
27
+ end
28
+
29
+ def gemfiles
30
+ Dir.glob("ci/Gemfile*").unshift("Gemfile").reject do |path|
31
+ [".lock", ".base"].include?(File.extname(path))
32
+ end
33
+ end
34
+
35
+ def gemlocks
36
+ Dir.glob("ci/Gemfile*.lock").unshift("Gemfile.lock")
37
+ end
38
+
39
+ def source_for(name:)
40
+ bundle_root = Bundler.bundle_path.join('bundler/gems')
41
+ path = Dir.glob(bundle_root.join("#{name}-*").to_s).first
42
+ path or raise "Could not find source for #{name}, run bundle install first"
43
+ end
44
+
45
+ def dest_for(name:)
46
+ File.join(__dir__, 'vendor', name)
47
+ end
48
+
49
+ def osx?
50
+ ENV.fetch("TRAVIS_OS_NAME") == "osx"
51
+ end
52
+
53
+ def brew_url(ref:)
54
+ "https://raw.githubusercontent.com/Homebrew/homebrew-core/#{ref}/Formula/git.rb"
55
+ end
56
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Layout/LineLength
4
+
3
5
  require "rubocop"
4
6
  require "optparse"
5
7
  require "rbconfig"
@@ -13,6 +15,66 @@ module Rfix
13
15
  include GitHelper
14
16
  include Log
15
17
 
18
+ def thanks
19
+ tx = []
20
+ tx << "\n{{v}} Thank you for installing {{green:rfix v#{Rfix::VERSION}}}!\n"
21
+ tx << "{{i}} Run {{command:rfix}} for avalible commands or any of the following to get started:"
22
+ tx << ""
23
+ # tx << "Here are a few examples that might be useful:"
24
+ indent = " " * 3
25
+ tx << "#{indent}{{command:rfix local}} {{italic:# Auto-fixes commits not yet pushed to upstream}}"
26
+ tx << "#{indent}{{command:rfix origin}} {{italic:# Auto-fixes commits between HEAD and origin branch}}"
27
+ tx << "#{indent}{{command:rfix lint}} {{italic:# Lints commits and untracked files not yet pushed to upstream}}"
28
+ tx << ""
29
+ tx << "{{*}} {{bold:ProTip:}} Append {{command:--dry}} to run {{command:rfix}} in read-only mode"
30
+ tx << ""
31
+ tx << "{{i}} {{bold:Issues}} {{italic:https://github.com/oleander/rfix-rb/issues}}"
32
+ tx << "{{i}} {{bold:Readme}} {{italic:https://github.com/oleander/rfix-rb/blob/master/README.md}}"
33
+ tx << "{{i}} {{bold:Travis}} {{italic:https://travis-ci.org/github/oleander/rfix-rb}}"
34
+ tx << ""
35
+ tx << "{{italic:~ Linus}}\n\n"
36
+ CLI::UI.fmt(tx.join("\n"), enable_color: true)
37
+ end
38
+
39
+ def help
40
+ cmds = []
41
+ cmds << "\t{{bold:rfix [cmd] [options]}} -- {{italic:--dry --help --list-files --limit-files --config --untracked}}"
42
+ cmds << "\t{{bold:rfix branch <branch>}} -- {{italic:Fix changes made between HEAD and <branch>}}"
43
+ cmds << "\t{{bold:rfix origin}} -- {{italic:Fix changes made between HEAD and origin branch}}"
44
+ cmds << "\t{{bold:rfix local}} -- {{italic:Fix changes not yet pushed to upstream branch}}"
45
+ cmds << "\t{{bold:rfix info}} -- {{italic:Display runtime dependencies and their versions}}"
46
+ cmds << "\t{{bold:rfix all}} -- {{italic:Fix all files in this repository}} {{warning:(not recommended)}}"
47
+ cmds << "\t{{bold:rfix lint}} -- {{italic:Shortcut for 'local --dry --untracked'}}"
48
+ CLI::UI.fmt(cmds.join("\n"), enable_color: true)
49
+ end
50
+
51
+ def config
52
+ @config
53
+ end
54
+
55
+ def no_auto_correct!
56
+ @config[:auto_correct] = false
57
+ end
58
+
59
+ def auto_correct!
60
+ @config[:auto_correct] = true
61
+ end
62
+
63
+ def load_config
64
+ yield @store
65
+ rescue RuboCop::Error => e
66
+ say_abort "[Config:RuboCop] #{e}"
67
+ rescue TypeError => e
68
+ say_abort "[Config:Type] #{e}"
69
+ rescue Psych::SyntaxError => e
70
+ say_abort "[Config:Syntax] #{e}"
71
+ end
72
+
73
+ def lint_mode!
74
+ no_auto_correct!
75
+ load_untracked!
76
+ end
77
+
16
78
  def git_version
17
79
  cmd("git --version").last.split(/\s+/, 3).last
18
80
  end
@@ -33,9 +95,24 @@ module Rfix
33
95
  @global_enable
34
96
  end
35
97
 
98
+ def store
99
+ @store
100
+ end
101
+
102
+ def clear_cache!
103
+ RuboCop::ResultCache.cleanup(@store, true)
104
+ end
105
+
36
106
  def init!
37
107
  @files ||= {}
38
108
  @global_enable = false
109
+ @config = {
110
+ force_exclusion: true,
111
+ formatters: ["Rfix::Formatter"]
112
+ }
113
+
114
+ @store = RuboCop::ConfigStore.new
115
+ auto_correct!
39
116
  end
40
117
 
41
118
  def files
@@ -83,7 +160,7 @@ module Rfix
83
160
  end
84
161
 
85
162
  def has_branch?(name)
86
- Open3.capture2e("git", "cat-file", "-t", name).last.success?
163
+ cmd_succeeded?("git", "cat-file", "-t", name)
87
164
  end
88
165
 
89
166
  # Ref since last push
@@ -100,6 +177,12 @@ module Rfix
100
177
 
101
178
  private
102
179
 
180
+ def old?
181
+ # For version 0.80.x .. 0.83.x:
182
+ # Otherwise it will exit with status code = 1
183
+ (0.80..0.83).include?(RuboCop::Version::STRING.to_f)
184
+ end
185
+
103
186
  def get_file(path, &block)
104
187
  if file = @files[path]
105
188
  block.call(file)
@@ -107,9 +190,7 @@ module Rfix
107
190
  end
108
191
 
109
192
  def list_untrack_files
110
- git("status", "-u", "--porcelain", "--no-column").map do |line|
111
- line.split(" ", 2).map(&:strip)
112
- end.select { |el| el.first == "??" }.map(&:last)
193
+ git("ls-files", "--exclude-standard", "--others")
113
194
  end
114
195
 
115
196
  def cached(files)
@@ -119,3 +200,5 @@ module Rfix
119
200
  end
120
201
  end
121
202
  end
203
+
204
+ # rubocop:enable Layout/LineLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rfix
4
- VERSION = "1.0.7"
4
+ VERSION = "1.0.8"
5
5
  end
Binary file
@@ -2,8 +2,11 @@
2
2
 
3
3
  require "pathname"
4
4
  require_relative "lib/rfix/version"
5
+ # require_relative "lib/rfix/gem_helper"
5
6
 
6
7
  Gem::Specification.new do |spec|
8
+ # extend GemHelper
9
+
7
10
  spec.name = "rfix"
8
11
 
9
12
  if ENV["TRAVIS"]
@@ -17,18 +20,16 @@ Gem::Specification.new do |spec|
17
20
  spec.authors = ["Linus Oleander"]
18
21
  spec.email = ["linus@oleander.nu"]
19
22
 
20
- spec.summary = "RuboCop CLI that only complains about your latest changes"
23
+ # rubocop:disable Layout/LineLength
24
+ spec.summary = "RuboCop CLI that only lints and auto-fixes code you committed by utilizing `git-log` and `git-diff`"
25
+ # rubocop:enable Layout/LineLength
26
+
21
27
  spec.description = <<~TEXT
22
- #{spec.summary}
23
- Uses 'git diff' to determine what changes were made then runs RuboCop against them
28
+ RuboCop CLI that only lints and auto-fixes code you committed by utilizing `git-log` and `git-diff`. Rfix CLI makes it possible to lint (`rfix lint`) and auto-fix (`rfix local|origin|branch`) code changes since a certain point in history. You can auto-fix code committed since creating the current branch (`rfix origin`) or since pushing to upstream (`rfix local`).
24
29
 
25
- $ rfix branch <branch> -- Fix changes made between HEAD and <branch>
26
- $ rfix origin -- Fix changes made between HEAD and origin branch
27
- $ rfix local -- Fix changes not yet pushed to upstream branch
28
- $ rfix info -- Display runtime dependencies and their versions
29
- $ rfix all -- Fix all files in this repository (not recommended)
30
+ Includes a RuboCop formatter with syntax highlighting and build in hyperlinks for offense documentation.
30
31
 
31
- Optional args: --dry --help --list-files --limit-files --config --untracked
32
+ Holds the same CLI arguments as RuboCop. Run `rfix --help` for a complete list or `rfix` for supported commands.
32
33
  TEXT
33
34
  spec.homepage = "https://github.com/oleander/rfix-rb"
34
35
  spec.license = "MIT"
@@ -42,15 +43,19 @@ Gem::Specification.new do |spec|
42
43
  `git ls-files -z`.split("\x0").reject(&validate_file)
43
44
  end
44
45
 
45
- spec.files += Dir.glob("vendor/cli-ui/lib/**/*").reject(&validate_file)
46
+ spec.files += Dir.glob("vendor/shopify/cli-ui/lib/**/*").reject(&validate_file)
46
47
 
47
48
  spec.bindir = "exe"
48
49
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
49
- spec.require_paths = ["lib", "vendor/cli-ui/lib"]
50
+ spec.require_paths = ["lib", "vendor/shopify/cli-ui/lib"]
50
51
 
51
52
  spec.requirements << "git, v2.0+"
52
53
 
53
54
  spec.add_runtime_dependency "rainbow", "~> 3.0"
54
55
  spec.add_runtime_dependency "rouge", "~> 3.20"
55
- spec.add_runtime_dependency "rubocop", "~> 0.80"
56
+ spec.add_runtime_dependency "rubocop", ">= 0.80"
57
+
58
+ spec.add_development_dependency "rspec", "~> 3.0"
59
+ spec.add_development_dependency "aruba", "~> 1.0"
60
+ spec.add_development_dependency "rake", "~> 12.3"
56
61
  end
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.7.pre.65
4
+ version: 1.0.8.pre.108
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander
@@ -42,24 +42,64 @@ dependencies:
42
42
  name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.80'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.80'
55
- description: "RuboCop CLI that only complains about your latest changes\nUses 'git
56
- diff' to determine what changes were made then runs RuboCop against them\n\n\t$
57
- rfix branch <branch> -- Fix changes made between HEAD and <branch>\n\t$ rfix origin
58
- \ -- Fix changes made between HEAD and origin branch\n\t$ rfix local --
59
- Fix changes not yet pushed to upstream branch\n\t$ rfix info -- Display
60
- runtime dependencies and their versions\n\t$ rfix all -- Fix all files
61
- in this repository (not recommended)\n\nOptional args: --dry --help --list-files
62
- --limit-files --config --untracked\n"
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: aruba
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '12.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '12.3'
97
+ description: |
98
+ RuboCop CLI that only lints and auto-fixes code you committed by utilizing `git-log` and `git-diff`. Rfix CLI makes it possible to lint (`rfix lint`) and auto-fix (`rfix local|origin|branch`) code changes since a certain point in history. You can auto-fix code committed since creating the current branch (`rfix origin`) or since pushing to upstream (`rfix local`).
99
+
100
+ Includes a RuboCop formatter with syntax highlighting and build in hyperlinks for offense documentation.
101
+
102
+ Holds the same CLI arguments as RuboCop. Run `rfix --help` for a complete list or `rfix` for supported commands.
63
103
  email:
64
104
  - linus@oleander.nu
65
105
  executables:
@@ -72,12 +112,19 @@ files:
72
112
  - ".rubocop.yml"
73
113
  - ".travis.yml"
74
114
  - Gemfile
115
+ - Gemfile.base
75
116
  - Gemfile.lock
76
117
  - Guardfile
77
118
  - LICENSE.txt
119
+ - Makefile
78
120
  - README.md
79
121
  - Rakefile
122
+ - bin/bundle
80
123
  - bin/console
124
+ - bin/guard
125
+ - bin/rake
126
+ - bin/rfix
127
+ - bin/rspec
81
128
  - bin/setup
82
129
  - ci/Gemfile.rubocop-0.80
83
130
  - ci/Gemfile.rubocop-0.80.lock
@@ -99,39 +146,42 @@ files:
99
146
  - lib/rfix/extensions/extensions.rb
100
147
  - lib/rfix/extensions/offense.rb
101
148
  - lib/rfix/formatter.rb
149
+ - lib/rfix/gem_helper.rb
102
150
  - lib/rfix/git_file.rb
103
151
  - lib/rfix/git_helper.rb
104
152
  - lib/rfix/log.rb
153
+ - lib/rfix/rake_helper.rb
105
154
  - lib/rfix/rfix.rb
106
155
  - lib/rfix/tracked_file.rb
107
156
  - lib/rfix/untracked_file.rb
108
157
  - lib/rfix/version.rb
158
+ - resources/ps.png
109
159
  - rfix.gemspec
110
- - vendor/cli-ui/lib/cli/ui.rb
111
- - vendor/cli-ui/lib/cli/ui/ansi.rb
112
- - vendor/cli-ui/lib/cli/ui/color.rb
113
- - vendor/cli-ui/lib/cli/ui/formatter.rb
114
- - vendor/cli-ui/lib/cli/ui/frame.rb
115
- - vendor/cli-ui/lib/cli/ui/frame/frame_stack.rb
116
- - vendor/cli-ui/lib/cli/ui/frame/frame_style.rb
117
- - vendor/cli-ui/lib/cli/ui/frame/frame_style/box.rb
118
- - vendor/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb
119
- - vendor/cli-ui/lib/cli/ui/glyph.rb
120
- - vendor/cli-ui/lib/cli/ui/printer.rb
121
- - vendor/cli-ui/lib/cli/ui/progress.rb
122
- - vendor/cli-ui/lib/cli/ui/prompt.rb
123
- - vendor/cli-ui/lib/cli/ui/prompt/interactive_options.rb
124
- - vendor/cli-ui/lib/cli/ui/prompt/options_handler.rb
125
- - vendor/cli-ui/lib/cli/ui/spinner.rb
126
- - vendor/cli-ui/lib/cli/ui/spinner/async.rb
127
- - vendor/cli-ui/lib/cli/ui/spinner/spin_group.rb
128
- - vendor/cli-ui/lib/cli/ui/stdout_router.rb
129
- - vendor/cli-ui/lib/cli/ui/terminal.rb
130
- - vendor/cli-ui/lib/cli/ui/truncater.rb
131
- - vendor/cli-ui/lib/cli/ui/version.rb
132
- - vendor/cli-ui/lib/cli/ui/widgets.rb
133
- - vendor/cli-ui/lib/cli/ui/widgets/base.rb
134
- - vendor/cli-ui/lib/cli/ui/widgets/status.rb
160
+ - vendor/shopify/cli-ui/lib/cli/ui.rb
161
+ - vendor/shopify/cli-ui/lib/cli/ui/ansi.rb
162
+ - vendor/shopify/cli-ui/lib/cli/ui/color.rb
163
+ - vendor/shopify/cli-ui/lib/cli/ui/formatter.rb
164
+ - vendor/shopify/cli-ui/lib/cli/ui/frame.rb
165
+ - vendor/shopify/cli-ui/lib/cli/ui/frame/frame_stack.rb
166
+ - vendor/shopify/cli-ui/lib/cli/ui/frame/frame_style.rb
167
+ - vendor/shopify/cli-ui/lib/cli/ui/frame/frame_style/box.rb
168
+ - vendor/shopify/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb
169
+ - vendor/shopify/cli-ui/lib/cli/ui/glyph.rb
170
+ - vendor/shopify/cli-ui/lib/cli/ui/printer.rb
171
+ - vendor/shopify/cli-ui/lib/cli/ui/progress.rb
172
+ - vendor/shopify/cli-ui/lib/cli/ui/prompt.rb
173
+ - vendor/shopify/cli-ui/lib/cli/ui/prompt/interactive_options.rb
174
+ - vendor/shopify/cli-ui/lib/cli/ui/prompt/options_handler.rb
175
+ - vendor/shopify/cli-ui/lib/cli/ui/spinner.rb
176
+ - vendor/shopify/cli-ui/lib/cli/ui/spinner/async.rb
177
+ - vendor/shopify/cli-ui/lib/cli/ui/spinner/spin_group.rb
178
+ - vendor/shopify/cli-ui/lib/cli/ui/stdout_router.rb
179
+ - vendor/shopify/cli-ui/lib/cli/ui/terminal.rb
180
+ - vendor/shopify/cli-ui/lib/cli/ui/truncater.rb
181
+ - vendor/shopify/cli-ui/lib/cli/ui/version.rb
182
+ - vendor/shopify/cli-ui/lib/cli/ui/widgets.rb
183
+ - vendor/shopify/cli-ui/lib/cli/ui/widgets/base.rb
184
+ - vendor/shopify/cli-ui/lib/cli/ui/widgets/status.rb
135
185
  homepage: https://github.com/oleander/rfix-rb
136
186
  licenses:
137
187
  - MIT
@@ -141,7 +191,7 @@ post_install_message:
141
191
  rdoc_options: []
142
192
  require_paths:
143
193
  - lib
144
- - vendor/cli-ui/lib
194
+ - vendor/shopify/cli-ui/lib
145
195
  required_ruby_version: !ruby/object:Gem::Requirement
146
196
  requirements:
147
197
  - - ">="
@@ -157,5 +207,6 @@ requirements:
157
207
  rubygems_version: 3.0.3
158
208
  signing_key:
159
209
  specification_version: 4
160
- summary: RuboCop CLI that only complains about your latest changes
210
+ summary: RuboCop CLI that only lints and auto-fixes code you committed by utilizing
211
+ `git-log` and `git-diff`
161
212
  test_files: []