rfix 1.2.5 → 1.2.6.pre.198

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: 979604266b50448ef2a189a633eda6a6057e179ef67962a850718c07f8e2c726
4
- data.tar.gz: 60b0a5b249baf32b738bde9ae350af154b3bf7862af836b42b960d5c91347b0f
3
+ metadata.gz: 0f49efc581ec20334b8f0e9594959a71185c6a51ae0ca13ab92d5ea3d3db86f6
4
+ data.tar.gz: 73aef727ae29434806a4c573b77fff684e406f2c3f3c0615963c213c3d6d5931
5
5
  SHA512:
6
- metadata.gz: 7efcea3b4f4419c05fca0467bfa1748d2cf1eb2c7771aeaa7f8bb83826016ece746635eb1303b6e881a1e108d4d06f9d6c0730db447314500ff1f30f5259b3b1
7
- data.tar.gz: 3aba1e9526e140517131811ec818edcc437274cf36746b5253bffd86fcf301ffde93d40370264157a7099b30e7fd906f198b765dfb523725e6a752a8cbdb9c1d
6
+ metadata.gz: 06f7708c0d34baf97708409375fc712c8a5cfdce94b44c8acc8a69135ebd2bb9ebe22dd0b7b9587371ddd9eaf718cbfabcf734ac2eb6adbb862cbb6cbe110f01
7
+ data.tar.gz: 6e3e19062b9e6eeadff64c8215229c95e3ab553065922bf920f0ce622edc2cb83feb4d9a156ee9204070b0f74ff0aed76308c026f3dd53b2507b229d9ebddfc7
@@ -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
- setup:
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}}"
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rfix (1.2.5)
4
+ rfix (1.2.6)
5
5
  cri (~> 2.15.10)
6
6
  listen (~> 3.0)
7
7
  rainbow (~> 3.0)
8
8
  require_all (~> 3.0.0)
9
9
  rouge (~> 3.20)
10
- rubocop (>= 0.80)
10
+ rubocop (>= 0.80, < 0.90)
11
11
  rugged (~> 1.0.0)
12
12
 
13
13
  GEM
data/Makefile CHANGED
@@ -1,4 +1,12 @@
1
- install:
2
- brew install cmake pkg-config libgit2 safe-rm
3
- gem install colorize rake
4
- rake build
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/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"
@@ -1,15 +1,15 @@
1
1
  class Rfix::Branch::Base
2
2
  def resolve(with:)
3
- raise Rfix::NotYetImplementedError.new("#resolved")
3
+ raise Rfix::NotYetImplementedError, "#resolved"
4
4
  end
5
5
 
6
6
  def to_s
7
- raise Rfix::NotYetImplementedError.new("#to_s")
7
+ raise Rfix::NotYetImplementedError, "#to_s"
8
8
  end
9
9
 
10
10
  def revparse(using:, ref:)
11
11
  using.rev_parse(ref)
12
12
  rescue Rugged::InvalidError
13
- raise Rfix::Branch::UnknownBranchError.new("Could not find reference {{error:#{ref}}}")
13
+ raise Rfix::Branch::UnknownBranchError, "Could not find reference {{error:#{ref}}}"
14
14
  end
15
15
  end
@@ -3,11 +3,11 @@ 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.new("Please run {{command:rfix setup}} first")
10
+ raise Error, "Please run {{command:rfix setup}} first"
11
11
  end
12
12
 
13
13
  Branch::Name.new(name).resolve(with: with)
@@ -10,12 +10,12 @@ module Rfix
10
10
 
11
11
  def resolve(with:)
12
12
  unless branch = with.branches[name]
13
- raise Branch::UnknownBranchError.new("Could not find branch {{error:#{name}}}")
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.new("Could not find branch {{error:#{name}}}")
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.new("Branch with reference {{error:#{reference}}} not found")
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"
@@ -8,7 +8,6 @@ summary "Lints commits and untracked files not yet pushed to upstream"
8
8
  usage "rfix lint [opts] [path ..]"
9
9
  description "Lint (read-only) files"
10
10
 
11
-
12
11
  run do |opts, args, _cmd|
13
12
  opts[:dry] = true
14
13
  opts[:untracked] = true
@@ -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.new("#include? not implemented")
21
+ raise Rfix::Error, "#include? not implemented"
22
22
  end
23
23
 
24
24
  def refresh!
25
- raise Rfix::Error.new("#refresh! not implemented")
25
+ raise Rfix::Error, "#refresh! not implemented"
26
26
  end
27
27
 
28
28
  def inspect
29
- raise Rfix::Error.new("#inspect not implemented")
29
+ raise Rfix::Error, "#inspect not implemented"
30
30
  end
31
31
 
32
32
  def git_path
@@ -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
@@ -31,7 +31,7 @@ module Rfix::Log
31
31
  end
32
32
 
33
33
  def say_debug(message)
34
- if debug? or test?
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
 
@@ -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.new("Need Branch::Base, got {{error:#{reference.class}}}")
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
- !! @reference
38
+ !!@reference
39
39
  end
40
40
 
41
- def reference
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
@@ -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{ |l| l.new_lineno }.reject { |l| l == -1 }.to_set
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
- include_untracked_content: true,
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
- }).tap do |diff|
64
+ }).tap do |diff|
65
65
  diff.find_similar!(
66
66
  renames_from_rewrites: true,
67
67
  renames: true,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rfix
4
- VERSION = "1.2.5"
4
+ VERSION = "1.2.6"
5
5
  end
@@ -54,15 +54,15 @@ Gem::Specification.new do |spec|
54
54
  spec.add_runtime_dependency "cri", "~> 2.15.10"
55
55
  spec.add_runtime_dependency "listen", "~> 3.0"
56
56
  spec.add_runtime_dependency "rainbow", "~> 3.0"
57
+ spec.add_runtime_dependency "require_all", "~> 3.0.0"
57
58
  spec.add_runtime_dependency "rouge", "~> 3.20"
58
- spec.add_runtime_dependency "rubocop", ">= 0.80"
59
+ spec.add_runtime_dependency "rubocop", ">= 0.80", "< 0.90"
59
60
  spec.add_runtime_dependency "rugged", "~> 1.0.0"
60
- spec.add_runtime_dependency "require_all", "~> 3.0.0"
61
61
 
62
62
  spec.add_development_dependency "rspec", "~> 3.0"
63
63
  spec.add_development_dependency "aruba", "~> 1.0"
64
64
  spec.add_development_dependency "colorize", "~> 0.8.1"
65
65
  spec.add_development_dependency "git", "~> 1.7.0"
66
- spec.add_development_dependency "rake", "~> 12.3"
67
66
  spec.add_development_dependency "pry", "~> 0.13.1"
67
+ spec.add_development_dependency "rake", "~> 12.3"
68
68
  end
@@ -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
 
@@ -45,7 +45,7 @@ namespace :bundle do
45
45
 
46
46
  sh "git config user.email 'you@example.com'"
47
47
  sh "git config user.name 'Your Name'"
48
-
48
+
49
49
  sh "git commit -m 'A Commit Message'"
50
50
 
51
51
  sh "git config push.default current"
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.2.5
4
+ version: 1.2.6.pre.198
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2020-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: require_all
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rouge
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -73,6 +87,9 @@ dependencies:
73
87
  - - ">="
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0.80'
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.90'
76
93
  type: :runtime
77
94
  prerelease: false
78
95
  version_requirements: !ruby/object:Gem::Requirement
@@ -80,6 +97,9 @@ dependencies:
80
97
  - - ">="
81
98
  - !ruby/object:Gem::Version
82
99
  version: '0.80'
100
+ - - "<"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.90'
83
103
  - !ruby/object:Gem::Dependency
84
104
  name: rugged
85
105
  requirement: !ruby/object:Gem::Requirement
@@ -94,20 +114,6 @@ dependencies:
94
114
  - - "~>"
95
115
  - !ruby/object:Gem::Version
96
116
  version: 1.0.0
97
- - !ruby/object:Gem::Dependency
98
- name: require_all
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 3.0.0
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 3.0.0
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: rspec
113
119
  requirement: !ruby/object:Gem::Requirement
@@ -165,33 +171,33 @@ dependencies:
165
171
  - !ruby/object:Gem::Version
166
172
  version: 1.7.0
167
173
  - !ruby/object:Gem::Dependency
168
- name: rake
174
+ name: pry
169
175
  requirement: !ruby/object:Gem::Requirement
170
176
  requirements:
171
177
  - - "~>"
172
178
  - !ruby/object:Gem::Version
173
- version: '12.3'
179
+ version: 0.13.1
174
180
  type: :development
175
181
  prerelease: false
176
182
  version_requirements: !ruby/object:Gem::Requirement
177
183
  requirements:
178
184
  - - "~>"
179
185
  - !ruby/object:Gem::Version
180
- version: '12.3'
186
+ version: 0.13.1
181
187
  - !ruby/object:Gem::Dependency
182
- name: pry
188
+ name: rake
183
189
  requirement: !ruby/object:Gem::Requirement
184
190
  requirements:
185
191
  - - "~>"
186
192
  - !ruby/object:Gem::Version
187
- version: 0.13.1
193
+ version: '12.3'
188
194
  type: :development
189
195
  prerelease: false
190
196
  version_requirements: !ruby/object:Gem::Requirement
191
197
  requirements:
192
198
  - - "~>"
193
199
  - !ruby/object:Gem::Version
194
- version: 0.13.1
200
+ version: '12.3'
195
201
  description: |
196
202
  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
203
 
@@ -275,6 +281,9 @@ files:
275
281
  - lib/rfix/file_cache.rb
276
282
  - lib/rfix/formatter.rb
277
283
  - lib/rfix/git_helper.rb
284
+ - lib/rfix/loader/bundler.rb
285
+ - lib/rfix/loader/env.rb
286
+ - lib/rfix/loader/spec.rb
278
287
  - lib/rfix/log.rb
279
288
  - lib/rfix/no_file.rb
280
289
  - lib/rfix/rake/paths.rb
@@ -325,7 +334,7 @@ licenses:
325
334
  - MIT
326
335
  metadata:
327
336
  homepage_uri: https://github.com/oleander/rfix-rb
328
- post_install_message:
337
+ post_install_message:
329
338
  rdoc_options: []
330
339
  require_paths:
331
340
  - lib
@@ -337,13 +346,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
337
346
  version: 2.5.0
338
347
  required_rubygems_version: !ruby/object:Gem::Requirement
339
348
  requirements:
340
- - - ">="
349
+ - - ">"
341
350
  - !ruby/object:Gem::Version
342
- version: '0'
351
+ version: 1.3.1
343
352
  requirements:
344
353
  - git, v2.0+
345
354
  rubygems_version: 3.0.3
346
- signing_key:
355
+ signing_key:
347
356
  specification_version: 4
348
357
  summary: RuboCop CLI that only lints and auto-fixes code you committed by utilizing
349
358
  `git-log` and `git-diff`