rfix 1.2.4 → 1.4.0
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/.github/workflows/main.yml +1 -15
- data/.travis.yml +0 -3
- data/Gemfile.lock +12 -5
- data/Makefile +12 -4
- data/README.md +2 -2
- data/exe/rfix +22 -1
- data/lib/rfix.rb +1 -0
- data/lib/rfix/branches/base.rb +3 -17
- data/lib/rfix/branches/main.rb +3 -9
- data/lib/rfix/branches/name.rb +2 -2
- data/lib/rfix/branches/reference.rb +1 -1
- data/lib/rfix/commands/helper/args.rb +1 -1
- data/lib/rfix/commands/lint.rb +0 -1
- data/lib/rfix/file.rb +3 -3
- data/lib/rfix/formatter.rb +4 -2
- data/lib/rfix/indentation.rb +39 -0
- data/lib/rfix/loader/bundler.rb +37 -0
- data/lib/rfix/loader/env.rb +33 -0
- data/lib/rfix/loader/spec.rb +41 -0
- data/lib/rfix/log.rb +2 -1
- data/lib/rfix/repository.rb +4 -6
- data/lib/rfix/tracked.rb +3 -3
- data/lib/rfix/version.rb +1 -1
- data/rfix.gemspec +5 -3
- data/tasks/execute.rake +3 -3
- data/tasks/simple.rake +1 -1
- metadata +55 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b9e1b92f9c823b4c5611ab9b4aef81804a51d922c03e7ed2d6a9d6409fde3cb7
|
|
4
|
+
data.tar.gz: 9101874ef60f1b7ec42762b0f52e7cf7c81dc8547c57c6faed47f241a0adee06
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d157a070581180aa1425ecfb0098e82a213889f7cf913676b95ef3ddb06ccee0941d57766102b7c813263bc3390a2f3de1531dda120487963958b37a1d127802
|
|
7
|
+
data.tar.gz: edc6454139b56ad1d91a13f6989142d71494e647dfdcd3e4688d0e4a50fe66b6bdde6678e5e0858b0012f197b05fd432242da33efa37de5a41b14fbcab25cb38
|
data/.github/workflows/main.yml
CHANGED
|
@@ -5,7 +5,7 @@ env:
|
|
|
5
5
|
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
|
6
6
|
GITHUB_API_TOKEN: ${{secrets.API_KEY}}
|
|
7
7
|
jobs:
|
|
8
|
-
|
|
8
|
+
build:
|
|
9
9
|
container: ruby:2.7
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
steps:
|
|
@@ -22,17 +22,3 @@ jobs:
|
|
|
22
22
|
|
|
23
23
|
- run: bundle install --path vendor/bundle
|
|
24
24
|
- run: rake execute:local execute:origin execute:lint execute:branch
|
|
25
|
-
|
|
26
|
-
- run: git config user.email "linus@oleander.io"
|
|
27
|
-
- run: git config user.name "Linus Oleander"
|
|
28
|
-
|
|
29
|
-
- name: Publish to RubyGems
|
|
30
|
-
run: |
|
|
31
|
-
mkdir -p $HOME/.gem
|
|
32
|
-
touch $HOME/.gem/credentials
|
|
33
|
-
chmod 0600 $HOME/.gem/credentials
|
|
34
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
|
35
|
-
gem build *.gemspec
|
|
36
|
-
gem push *.gem
|
|
37
|
-
env:
|
|
38
|
-
GEM_HOST_API_KEY: "Bearer ${{secrets.RUBYGEMS_API_KEY}}"
|
data/.travis.yml
CHANGED
|
@@ -8,11 +8,8 @@ os:
|
|
|
8
8
|
- linux
|
|
9
9
|
gemfile:
|
|
10
10
|
- ci/Gemfile.rubocop-0.80
|
|
11
|
-
- ci/Gemfile.rubocop-0.81
|
|
12
11
|
- ci/Gemfile.rubocop-0.82
|
|
13
|
-
- ci/Gemfile.rubocop-0.83
|
|
14
12
|
- ci/Gemfile.rubocop-0.84
|
|
15
|
-
- ci/Gemfile.rubocop-0.85
|
|
16
13
|
- ci/Gemfile.rubocop-0.85.1
|
|
17
14
|
before_install:
|
|
18
15
|
- yes | gem update --system --force
|
data/Gemfile.lock
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rfix (1.
|
|
4
|
+
rfix (1.4.0)
|
|
5
5
|
cri (~> 2.15.10)
|
|
6
|
+
dry-core (~> 0.5.0)
|
|
6
7
|
listen (~> 3.0)
|
|
7
8
|
rainbow (~> 3.0)
|
|
8
9
|
require_all (~> 3.0.0)
|
|
9
10
|
rouge (~> 3.20)
|
|
10
|
-
rubocop (>= 0.80)
|
|
11
|
+
rubocop (>= 0.80, < 0.90)
|
|
11
12
|
rugged (~> 1.0.0)
|
|
12
13
|
|
|
13
14
|
GEM
|
|
@@ -33,7 +34,7 @@ GEM
|
|
|
33
34
|
colorize (0.8.1)
|
|
34
35
|
concurrent-ruby (1.1.6)
|
|
35
36
|
contracts (0.16.0)
|
|
36
|
-
cri (2.15.
|
|
37
|
+
cri (2.15.11)
|
|
37
38
|
cucumber (4.0.1)
|
|
38
39
|
builder (~> 3.2, >= 3.2.3)
|
|
39
40
|
cucumber-core (~> 7.0, >= 7.0.0)
|
|
@@ -62,6 +63,8 @@ GEM
|
|
|
62
63
|
cucumber-cucumber-expressions (~> 10.1, >= 10.1.0)
|
|
63
64
|
cucumber-messages (~> 12.1, >= 12.1.1)
|
|
64
65
|
diff-lcs (1.3)
|
|
66
|
+
dry-core (0.5.0)
|
|
67
|
+
concurrent-ruby (~> 1.0)
|
|
65
68
|
faker (2.13.0)
|
|
66
69
|
i18n (>= 1.6, < 2)
|
|
67
70
|
ffi (1.13.1)
|
|
@@ -121,7 +124,7 @@ GEM
|
|
|
121
124
|
regexp_parser (1.7.1)
|
|
122
125
|
require_all (3.0.0)
|
|
123
126
|
rexml (3.2.4)
|
|
124
|
-
rouge (3.
|
|
127
|
+
rouge (3.26.0)
|
|
125
128
|
rspec (3.9.0)
|
|
126
129
|
rspec-core (~> 3.9.0)
|
|
127
130
|
rspec-expectations (~> 3.9.0)
|
|
@@ -131,6 +134,9 @@ GEM
|
|
|
131
134
|
rspec-expectations (3.9.2)
|
|
132
135
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
133
136
|
rspec-support (~> 3.9.0)
|
|
137
|
+
rspec-its (1.3.0)
|
|
138
|
+
rspec-core (>= 3.0.0)
|
|
139
|
+
rspec-expectations (>= 3.0.0)
|
|
134
140
|
rspec-mocks (3.9.1)
|
|
135
141
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
136
142
|
rspec-support (~> 3.9.0)
|
|
@@ -175,7 +181,8 @@ DEPENDENCIES
|
|
|
175
181
|
rake (~> 12.3)
|
|
176
182
|
rfix!
|
|
177
183
|
rspec (~> 3.0)
|
|
184
|
+
rspec-its (~> 1.3.0)
|
|
178
185
|
rubocop (~> 0.85)
|
|
179
186
|
|
|
180
187
|
BUNDLED WITH
|
|
181
|
-
2.
|
|
188
|
+
2.2.5
|
data/Makefile
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
rake
|
|
1
|
+
bundle:
|
|
2
|
+
cd tmp && bundle install
|
|
3
|
+
install: bundle
|
|
4
|
+
bundle exec rake install:local
|
|
5
|
+
# brew install cmake pkg-config libgit2 safe-rm
|
|
6
|
+
# gem install colorize rake
|
|
7
|
+
# rake build
|
|
8
|
+
|
|
9
|
+
test: install
|
|
10
|
+
cd tmp && rfix info || true
|
|
11
|
+
# cd tmp && bundle exec rfix --help || true
|
|
12
|
+
# cd tmp && bundle exec ./exe/rfix --debug --help || true
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# :bug:
|
|
1
|
+
# :bug: rfix [](https://travis-ci.org/oleander/rfix-rb) [](https://rubygems.org/gems/rfix)
|
|
2
2
|
|
|
3
3
|
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`).
|
|
4
4
|
|
|
@@ -46,8 +46,8 @@ $ rfix # Displays this list of supported commands
|
|
|
46
46
|
- `$ git clone https://github.com/oleander/rfix-rb`
|
|
47
47
|
- `$ cd rfix-rb`
|
|
48
48
|
2. Downloads fixtures and run time dependencies
|
|
49
|
-
- `$ make dir fetch`
|
|
50
49
|
- `$ bundle install`
|
|
50
|
+
- `$ rake rebuild
|
|
51
51
|
|
|
52
52
|
### Install from repository
|
|
53
53
|
|
data/exe/rfix
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
1
|
+
# #!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler"
|
|
4
|
+
|
|
5
|
+
require_relative "../lib/rfix/loader/spec.rb"
|
|
6
|
+
require_relative "../lib/rfix/loader/bundler.rb"
|
|
7
|
+
require_relative "../lib/rfix/loader/env.rb"
|
|
8
|
+
|
|
9
|
+
if spec = Bundler.find_locked("rubocop")
|
|
10
|
+
Gem::Specification.deactivate(spec.name)
|
|
11
|
+
unless spec.__materialize__&.activation
|
|
12
|
+
abort "Could not load rubocop spec file"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
if spec = Gem.loaded_specs.fetch("rubocop")
|
|
17
|
+
unless Env.requirement === spec.version
|
|
18
|
+
abort "RuboCop version #{Env.pretty_req} required by rfix but #{spec.version} was found in Gemfile"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
2
21
|
|
|
3
22
|
require "cri"
|
|
4
23
|
require "rfix"
|
|
@@ -27,4 +46,6 @@ begin
|
|
|
27
46
|
end
|
|
28
47
|
rescue RuntimeError => e
|
|
29
48
|
say_abort e.to_s
|
|
49
|
+
rescue Rfix::Error => e
|
|
50
|
+
say_abort e.to_s
|
|
30
51
|
end
|
data/lib/rfix.rb
CHANGED
data/lib/rfix/branches/base.rb
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
class Rfix::Branch::Base
|
|
2
2
|
def resolve(with:)
|
|
3
|
-
raise Rfix::NotYetImplementedError
|
|
3
|
+
raise Rfix::NotYetImplementedError, "#resolved"
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
def to_s
|
|
7
|
-
raise Rfix::NotYetImplementedError
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def branch(using:)
|
|
11
|
-
names(using: using).last or raise Rfix::Error.new("No named branch found for {{error:#{self}}}")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def names(using:)
|
|
15
|
-
oid = resolve(with: using).oid
|
|
16
|
-
locals = using.branches.each_name(:local).to_a
|
|
17
|
-
|
|
18
|
-
using.branches.select do |branch|
|
|
19
|
-
next false unless locals.include?(branch.name)
|
|
20
|
-
branch.target_id == oid
|
|
21
|
-
end
|
|
7
|
+
raise Rfix::NotYetImplementedError, "#to_s"
|
|
22
8
|
end
|
|
23
9
|
|
|
24
10
|
def revparse(using:, ref:)
|
|
25
11
|
using.rev_parse(ref)
|
|
26
12
|
rescue Rugged::InvalidError
|
|
27
|
-
raise Rfix::Branch::UnknownBranchError
|
|
13
|
+
raise Rfix::Branch::UnknownBranchError, "Could not find reference {{error:#{ref}}}"
|
|
28
14
|
end
|
|
29
15
|
end
|
data/lib/rfix/branches/main.rb
CHANGED
|
@@ -3,24 +3,18 @@ require_relative "base"
|
|
|
3
3
|
|
|
4
4
|
module Rfix
|
|
5
5
|
class Branch::Main < Branch::Base
|
|
6
|
-
KEY = "rfix.main.branch"
|
|
6
|
+
KEY = "rfix.main.branch".freeze
|
|
7
7
|
|
|
8
8
|
def resolve(with:)
|
|
9
9
|
unless name = with.config[KEY]
|
|
10
|
-
raise Error
|
|
10
|
+
raise Error, "Please run {{command:rfix setup}} first"
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
Branch::Name.new(name).resolve(with: with)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def self.set(branch, at: Dir.pwd)
|
|
17
|
-
|
|
18
|
-
raise Rfix::Error.new("Branch must be a string, got {{error:#{branch.class}}}")
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
check = Branch::Name.new(branch)
|
|
22
|
-
repo = Branch.repo(at: at)
|
|
23
|
-
Branch.repo(at: at).config[KEY] = check.branch(using: repo).name
|
|
17
|
+
Branch.repo(at: at).config[KEY] = branch
|
|
24
18
|
end
|
|
25
19
|
|
|
26
20
|
def self.get(at: Dir.pwd)
|
data/lib/rfix/branches/name.rb
CHANGED
|
@@ -10,12 +10,12 @@ module Rfix
|
|
|
10
10
|
|
|
11
11
|
def resolve(with:)
|
|
12
12
|
unless branch = with.branches[name]
|
|
13
|
-
raise Branch::UnknownBranchError
|
|
13
|
+
raise Branch::UnknownBranchError, "Could not find branch {{error:#{name}}}"
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
with.lookup(with.merge_base(branch.target_id, with.head.target_id))
|
|
17
17
|
rescue Rugged::ReferenceError
|
|
18
|
-
raise Branch::UnknownBranchError
|
|
18
|
+
raise Branch::UnknownBranchError, "Could not find branch {{error:#{name}}}"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
alias to_s name
|
|
@@ -13,7 +13,7 @@ module Rfix
|
|
|
13
13
|
rescue Branch::UnknownBranchError
|
|
14
14
|
revparse(using: with, ref: reference)
|
|
15
15
|
rescue Rugged::InvalidError
|
|
16
|
-
raise Branch::UnknownBranchError
|
|
16
|
+
raise Branch::UnknownBranchError, "Branch with reference {{error:#{reference}}} not found"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
alias to_s reference
|
|
@@ -116,7 +116,7 @@ def setup(r_args = [], opts, _args, files: [], reference:)
|
|
|
116
116
|
paths = files
|
|
117
117
|
elsif paths.empty? && repo.paths.empty?
|
|
118
118
|
if opts[:format] == "json"
|
|
119
|
-
prt JSON.pretty_generate({"files": []})
|
|
119
|
+
prt JSON.pretty_generate({ "files": [] })
|
|
120
120
|
exit 0
|
|
121
121
|
else
|
|
122
122
|
say_exit "Everything looks good, nothing to lint"
|
data/lib/rfix/commands/lint.rb
CHANGED
data/lib/rfix/file.rb
CHANGED
|
@@ -18,15 +18,15 @@ class Rfix::File < Struct.new(:path, :repo, :ref)
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def include?(_)
|
|
21
|
-
raise Rfix::Error
|
|
21
|
+
raise Rfix::Error, "#include? not implemented"
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def refresh!
|
|
25
|
-
raise Rfix::Error
|
|
25
|
+
raise Rfix::Error, "#refresh! not implemented"
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def inspect
|
|
29
|
-
raise Rfix::Error
|
|
29
|
+
raise Rfix::Error, "#inspect not implemented"
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def git_path
|
data/lib/rfix/formatter.rb
CHANGED
|
@@ -113,11 +113,13 @@ module Rfix
|
|
|
113
113
|
def report_line(_file, offense, _location, highlighted_area)
|
|
114
114
|
extra = " "
|
|
115
115
|
src = highlighted_source_line(offense).lines.map { |line| extra + line }.join("\n")
|
|
116
|
+
indent = Indentation.new(src, extra_indentation: 2)
|
|
117
|
+
src = indent.call
|
|
116
118
|
lines = @formatter.format(@lexer.lex(src)).gsub('\\e', CLI::UI::ANSI::ESC).lines.map(&:chomp)
|
|
117
119
|
out("\n\n")
|
|
118
120
|
out(lines.join("\n"), format: false)
|
|
119
|
-
b_pos = highlighted_area.begin_pos + extra.length
|
|
120
|
-
e_pos = highlighted_area.end_pos + extra.length
|
|
121
|
+
b_pos = highlighted_area.begin_pos + extra.length * 2 - indent.min_indentation
|
|
122
|
+
e_pos = highlighted_area.end_pos + extra.length * 2 - indent.min_indentation
|
|
121
123
|
size = e_pos - b_pos
|
|
122
124
|
out((" " * b_pos) + Rainbow((" " * size)).underline.bold)
|
|
123
125
|
out("\n\n")
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require "dry/core/memoizable"
|
|
2
|
+
|
|
3
|
+
module Rfix
|
|
4
|
+
class Indentation
|
|
5
|
+
include Dry::Core::Memoizable
|
|
6
|
+
SPACE = " ".freeze
|
|
7
|
+
|
|
8
|
+
attr_reader :extra_indentation, :input
|
|
9
|
+
|
|
10
|
+
def initialize(input, extra_indentation: 0)
|
|
11
|
+
@input = input
|
|
12
|
+
@extra_indentation = extra_indentation
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def stripped
|
|
16
|
+
lines.map do |line|
|
|
17
|
+
line.sub(/^\s{#{min_indentation}}/, "")
|
|
18
|
+
end.map do |line|
|
|
19
|
+
[SPACE * extra_indentation, line].join
|
|
20
|
+
end.join
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
alias call stripped
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def min_indentation
|
|
28
|
+
lines.map do |line|
|
|
29
|
+
line.match(/^\s*/)[0].length
|
|
30
|
+
end.min || 0
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def lines
|
|
34
|
+
input.lines
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
memoize :min_indentation, :lines
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require "bundler"
|
|
3
|
+
|
|
4
|
+
module Bundler
|
|
5
|
+
class Null
|
|
6
|
+
def __materialize__
|
|
7
|
+
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def version
|
|
11
|
+
raise "#version not impl."
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def activation
|
|
15
|
+
raise "#activation not impl."
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.locked_specs
|
|
20
|
+
locked_gems&.specs || []
|
|
21
|
+
rescue Bundler::GemfileNotFound
|
|
22
|
+
[]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.find_locked(name)
|
|
26
|
+
locked_specs.select do |spec|
|
|
27
|
+
spec.name.casecmp(name).zero?
|
|
28
|
+
end.first
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.activate_locked(name)
|
|
32
|
+
find_locked(name).__materialize__.tap(&:activation)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
rescue LoadError
|
|
36
|
+
require_relative "null_bundler"
|
|
37
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# require "pry"
|
|
2
|
+
class Env
|
|
3
|
+
KEY = "__RFIX_LOOP".freeze
|
|
4
|
+
|
|
5
|
+
def self.spec
|
|
6
|
+
Gem.loaded_specs.fetch("rfix")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.requirement
|
|
10
|
+
spec.dependencies.select do |gem|
|
|
11
|
+
gem.name == "rubocop"
|
|
12
|
+
end.first&.requirement || Env.log!("RuboCop requirement not found")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.pretty_req
|
|
16
|
+
requirement.as_list.join(" to ")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.bundle_path
|
|
20
|
+
Gem.bin_path("bundler", "bundle")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.log(msg)
|
|
24
|
+
# return unless ARGV.include?("--debug")
|
|
25
|
+
|
|
26
|
+
$stderr.puts ["==>", msg].join(" ")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.log!(msg)
|
|
30
|
+
$stderr.puts ["==>", msg].join(" ")
|
|
31
|
+
exit(1)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
class Gem::Specification
|
|
2
|
+
def self.deactivate(name)
|
|
3
|
+
Gem.loaded_specs[name]&.deactivate
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def deactivate
|
|
7
|
+
loaded_paths.each do |path|
|
|
8
|
+
$:.delete(path)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Gem.loaded_specs.delete(name)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def activation
|
|
15
|
+
self.class.deactivate(name)
|
|
16
|
+
activate
|
|
17
|
+
rescue Gem::ConflictError => error
|
|
18
|
+
abort error.to_s
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def loaded_paths(spec = self, prev = [])
|
|
24
|
+
return root_loaded_path unless loaded_into_path?
|
|
25
|
+
return root_loaded_path if prev == root_loaded_path
|
|
26
|
+
|
|
27
|
+
root_loaded_path + dependent_specs.map do |spec|
|
|
28
|
+
loaded_paths(spec, root_loaded_path)
|
|
29
|
+
end.flatten
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def loaded_into_path?
|
|
33
|
+
@lip ||= root_loaded_path.any? do |path|
|
|
34
|
+
$:.include?(path)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def root_loaded_path
|
|
39
|
+
@root ||= Dir.glob(lib_dirs_glob)
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/rfix/log.rb
CHANGED
|
@@ -31,7 +31,7 @@ module Rfix::Log
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def say_debug(message)
|
|
34
|
-
if debug?
|
|
34
|
+
if debug? || test?
|
|
35
35
|
prt("{{i}} #{strip(message)}", to: $stderr)
|
|
36
36
|
end
|
|
37
37
|
end
|
|
@@ -43,6 +43,7 @@ module Rfix::Log
|
|
|
43
43
|
|
|
44
44
|
def debug?
|
|
45
45
|
return false unless defined?(RSpec)
|
|
46
|
+
|
|
46
47
|
return RSpec.configuration.debug?
|
|
47
48
|
end
|
|
48
49
|
|
data/lib/rfix/repository.rb
CHANGED
|
@@ -18,7 +18,7 @@ class Rfix::Repository
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
unless reference.is_a?(Rfix::Branch::Base)
|
|
21
|
-
raise Rfix::Error
|
|
21
|
+
raise Rfix::Error, "Need Branch::Base, got {{error:#{reference.class}}}"
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
@files = FileCache.new(root_path)
|
|
@@ -35,12 +35,10 @@ class Rfix::Repository
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def load_tracked?
|
|
38
|
-
|
|
38
|
+
!!@reference
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
@reference
|
|
43
|
-
end
|
|
41
|
+
attr_reader :reference
|
|
44
42
|
|
|
45
43
|
def refresh!(path)
|
|
46
44
|
@files.get(path).refresh!
|
|
@@ -108,7 +106,7 @@ class Rfix::Repository
|
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
unless @paths.empty?
|
|
111
|
-
say_debug("Use @paths #{@paths.join(
|
|
109
|
+
say_debug("Use @paths #{@paths.join(', ')}")
|
|
112
110
|
params[:disable_pathspec_match] = false
|
|
113
111
|
params[:paths] = @paths
|
|
114
112
|
end
|
data/lib/rfix/tracked.rb
CHANGED
|
@@ -4,7 +4,7 @@ class Rfix::Tracked < Rfix::File
|
|
|
4
4
|
include Rfix::Log
|
|
5
5
|
|
|
6
6
|
def include?(line)
|
|
7
|
-
set = diff.each_line.to_a.map
|
|
7
|
+
set = diff.each_line.to_a.map(&:new_lineno).reject { |l| l == -1 }.to_set
|
|
8
8
|
say_debug "Does {{yellow:#{set}}} contain {{red:#{line}}}"
|
|
9
9
|
set.include?(line)
|
|
10
10
|
end
|
|
@@ -54,14 +54,14 @@ class Rfix::Tracked < Rfix::File
|
|
|
54
54
|
|
|
55
55
|
def diff
|
|
56
56
|
upstream.diff_workdir({
|
|
57
|
-
|
|
57
|
+
include_untracked_content: true,
|
|
58
58
|
recurse_untracked_dirs: true,
|
|
59
59
|
include_untracked: true,
|
|
60
60
|
ignore_submodules: true,
|
|
61
61
|
include_ignored: false,
|
|
62
62
|
context_lines: 0,
|
|
63
63
|
paths: [path]
|
|
64
|
-
|
|
64
|
+
}).tap do |diff|
|
|
65
65
|
diff.find_similar!(
|
|
66
66
|
renames_from_rewrites: true,
|
|
67
67
|
renames: true,
|
data/lib/rfix/version.rb
CHANGED
data/rfix.gemspec
CHANGED
|
@@ -52,17 +52,19 @@ Gem::Specification.new do |spec|
|
|
|
52
52
|
spec.requirements << "git, v2.0+"
|
|
53
53
|
|
|
54
54
|
spec.add_runtime_dependency "cri", "~> 2.15.10"
|
|
55
|
+
spec.add_runtime_dependency "dry-core", "~> 0.5.0"
|
|
55
56
|
spec.add_runtime_dependency "listen", "~> 3.0"
|
|
56
57
|
spec.add_runtime_dependency "rainbow", "~> 3.0"
|
|
58
|
+
spec.add_runtime_dependency "require_all", "~> 3.0.0"
|
|
57
59
|
spec.add_runtime_dependency "rouge", "~> 3.20"
|
|
58
|
-
spec.add_runtime_dependency "rubocop", ">= 0.80"
|
|
60
|
+
spec.add_runtime_dependency "rubocop", ">= 0.80", "< 0.90"
|
|
59
61
|
spec.add_runtime_dependency "rugged", "~> 1.0.0"
|
|
60
|
-
spec.add_runtime_dependency "require_all", "~> 3.0.0"
|
|
61
62
|
|
|
62
63
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
64
|
+
spec.add_development_dependency "rspec-its", "~> 1.3.0"
|
|
63
65
|
spec.add_development_dependency "aruba", "~> 1.0"
|
|
64
66
|
spec.add_development_dependency "colorize", "~> 0.8.1"
|
|
65
67
|
spec.add_development_dependency "git", "~> 1.7.0"
|
|
66
|
-
spec.add_development_dependency "rake", "~> 12.3"
|
|
67
68
|
spec.add_development_dependency "pry", "~> 0.13.1"
|
|
69
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
|
68
70
|
end
|
data/tasks/execute.rake
CHANGED
|
@@ -9,7 +9,7 @@ CLEAN.include(repo_path)
|
|
|
9
9
|
namespace :execute do
|
|
10
10
|
task local: [repo_path, :install] do
|
|
11
11
|
chdir(repo_path) do
|
|
12
|
-
sh "rfix local"
|
|
12
|
+
sh "rfix local --main-branch master"
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
@@ -21,13 +21,13 @@ namespace :execute do
|
|
|
21
21
|
|
|
22
22
|
task origin: [repo_path, :install] do
|
|
23
23
|
chdir(repo_path) do
|
|
24
|
-
sh "rfix origin"
|
|
24
|
+
sh "rfix origin --main-branch master"
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
task lint: [repo_path, :install] do
|
|
29
29
|
chdir(repo_path) do
|
|
30
|
-
sh "rfix lint"
|
|
30
|
+
sh "rfix lint --main-branch master"
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
data/tasks/simple.rake
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rfix
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Linus Oleander
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-02-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cri
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 2.15.10
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: dry-core
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 0.5.0
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 0.5.0
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
42
|
name: listen
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,6 +66,20 @@ dependencies:
|
|
|
52
66
|
- - "~>"
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
68
|
version: '3.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: require_all
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 3.0.0
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 3.0.0
|
|
55
83
|
- !ruby/object:Gem::Dependency
|
|
56
84
|
name: rouge
|
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -73,6 +101,9 @@ dependencies:
|
|
|
73
101
|
- - ">="
|
|
74
102
|
- !ruby/object:Gem::Version
|
|
75
103
|
version: '0.80'
|
|
104
|
+
- - "<"
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: '0.90'
|
|
76
107
|
type: :runtime
|
|
77
108
|
prerelease: false
|
|
78
109
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -80,6 +111,9 @@ dependencies:
|
|
|
80
111
|
- - ">="
|
|
81
112
|
- !ruby/object:Gem::Version
|
|
82
113
|
version: '0.80'
|
|
114
|
+
- - "<"
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0.90'
|
|
83
117
|
- !ruby/object:Gem::Dependency
|
|
84
118
|
name: rugged
|
|
85
119
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -95,33 +129,33 @@ dependencies:
|
|
|
95
129
|
- !ruby/object:Gem::Version
|
|
96
130
|
version: 1.0.0
|
|
97
131
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
132
|
+
name: rspec
|
|
99
133
|
requirement: !ruby/object:Gem::Requirement
|
|
100
134
|
requirements:
|
|
101
135
|
- - "~>"
|
|
102
136
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 3.0
|
|
104
|
-
type: :
|
|
137
|
+
version: '3.0'
|
|
138
|
+
type: :development
|
|
105
139
|
prerelease: false
|
|
106
140
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
141
|
requirements:
|
|
108
142
|
- - "~>"
|
|
109
143
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 3.0
|
|
144
|
+
version: '3.0'
|
|
111
145
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: rspec
|
|
146
|
+
name: rspec-its
|
|
113
147
|
requirement: !ruby/object:Gem::Requirement
|
|
114
148
|
requirements:
|
|
115
149
|
- - "~>"
|
|
116
150
|
- !ruby/object:Gem::Version
|
|
117
|
-
version:
|
|
151
|
+
version: 1.3.0
|
|
118
152
|
type: :development
|
|
119
153
|
prerelease: false
|
|
120
154
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
155
|
requirements:
|
|
122
156
|
- - "~>"
|
|
123
157
|
- !ruby/object:Gem::Version
|
|
124
|
-
version:
|
|
158
|
+
version: 1.3.0
|
|
125
159
|
- !ruby/object:Gem::Dependency
|
|
126
160
|
name: aruba
|
|
127
161
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -165,33 +199,33 @@ dependencies:
|
|
|
165
199
|
- !ruby/object:Gem::Version
|
|
166
200
|
version: 1.7.0
|
|
167
201
|
- !ruby/object:Gem::Dependency
|
|
168
|
-
name:
|
|
202
|
+
name: pry
|
|
169
203
|
requirement: !ruby/object:Gem::Requirement
|
|
170
204
|
requirements:
|
|
171
205
|
- - "~>"
|
|
172
206
|
- !ruby/object:Gem::Version
|
|
173
|
-
version:
|
|
207
|
+
version: 0.13.1
|
|
174
208
|
type: :development
|
|
175
209
|
prerelease: false
|
|
176
210
|
version_requirements: !ruby/object:Gem::Requirement
|
|
177
211
|
requirements:
|
|
178
212
|
- - "~>"
|
|
179
213
|
- !ruby/object:Gem::Version
|
|
180
|
-
version:
|
|
214
|
+
version: 0.13.1
|
|
181
215
|
- !ruby/object:Gem::Dependency
|
|
182
|
-
name:
|
|
216
|
+
name: rake
|
|
183
217
|
requirement: !ruby/object:Gem::Requirement
|
|
184
218
|
requirements:
|
|
185
219
|
- - "~>"
|
|
186
220
|
- !ruby/object:Gem::Version
|
|
187
|
-
version:
|
|
221
|
+
version: '12.3'
|
|
188
222
|
type: :development
|
|
189
223
|
prerelease: false
|
|
190
224
|
version_requirements: !ruby/object:Gem::Requirement
|
|
191
225
|
requirements:
|
|
192
226
|
- - "~>"
|
|
193
227
|
- !ruby/object:Gem::Version
|
|
194
|
-
version:
|
|
228
|
+
version: '12.3'
|
|
195
229
|
description: |
|
|
196
230
|
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`).
|
|
197
231
|
|
|
@@ -275,6 +309,10 @@ files:
|
|
|
275
309
|
- lib/rfix/file_cache.rb
|
|
276
310
|
- lib/rfix/formatter.rb
|
|
277
311
|
- lib/rfix/git_helper.rb
|
|
312
|
+
- lib/rfix/indentation.rb
|
|
313
|
+
- lib/rfix/loader/bundler.rb
|
|
314
|
+
- lib/rfix/loader/env.rb
|
|
315
|
+
- lib/rfix/loader/spec.rb
|
|
278
316
|
- lib/rfix/log.rb
|
|
279
317
|
- lib/rfix/no_file.rb
|
|
280
318
|
- lib/rfix/rake/paths.rb
|
|
@@ -342,7 +380,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
342
380
|
version: '0'
|
|
343
381
|
requirements:
|
|
344
382
|
- git, v2.0+
|
|
345
|
-
|
|
383
|
+
rubyforge_project:
|
|
384
|
+
rubygems_version: 2.7.6.2
|
|
346
385
|
signing_key:
|
|
347
386
|
specification_version: 4
|
|
348
387
|
summary: RuboCop CLI that only lints and auto-fixes code you committed by utilizing
|