rfix 1.2.2.pre.174 → 1.2.6

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: 21eca1cf7b672049156a68d5b78b205fe3a51356fd005cea3ca7de90b35f8504
4
- data.tar.gz: 01631f5a207dcd3018d55dd7df84d44e4b90985be602270ed242bcba2cc704ed
3
+ metadata.gz: 4963fcdeb152d9e132794d42982797eadf9848ecfcfed8e94f51885003b0ddbb
4
+ data.tar.gz: 8cb32d9c8e17a881eec724678f0e69bc138ca360f24ea6318c733429e09e45f3
5
5
  SHA512:
6
- metadata.gz: 6dcd829c42c554bdf92c0474a397129b66edaa33974554996d0d5bc1b8fc7738510cbffff43c13359b2844e8730693b600f5038c59d54351c14d14dac1a1399a
7
- data.tar.gz: 1f0ea8c9615cfa02cf7022af7514633a9331d42a35d58e759f9d5c8010f2e25d2b976b0dd984aa50045f6f1a7f933bf800b88ff577e1fbfb86cd8518f1e625ac
6
+ metadata.gz: 064c76697d6e5cad1b1e35c52f4ee9b7f52df2697fdf8680f18289130aa8b6f634ed3cf2bcba41cc8d0a27fd95e61e79d2c3a5638620baf61440935471ed784f
7
+ data.tar.gz: 4936c5ca44319492caf7a8556ff5913ca527541b5d7a3453d04db77785bfcb535929153a7a7e11881283dc7e1910c7f4164d4293eae9c4b405de12fc032ccc88
@@ -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.2pre)
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)
11
11
  rugged (~> 1.0.0)
12
12
 
13
13
  GEM
data/exe/rfix CHANGED
@@ -27,4 +27,6 @@ begin
27
27
  end
28
28
  rescue RuntimeError => e
29
29
  say_abort e.to_s
30
+ rescue Rfix::Error => e
31
+ say_abort e.to_s
30
32
  end
@@ -1,29 +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")
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.new("Could not find reference {{error:#{ref}}}")
13
+ raise Rfix::Branch::UnknownBranchError, "Could not find reference {{error:#{ref}}}"
28
14
  end
29
15
  end
@@ -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.new("Please run {{command:rfix setup}} first")
10
+ raise Error, "Please run {{command:rfix setup}} first"
11
11
  end
12
12
 
13
- String.new(name).resolve(with: with)
13
+ Branch::Name.new(name).resolve(with: with)
14
14
  end
15
15
 
16
16
  def self.set(branch, at: Dir.pwd)
17
- unless branch.is_a?(String)
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)
@@ -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
@@ -1,5 +1,5 @@
1
1
  option :r, :root, "{{*}} Project root path", default: Dir.pwd, argument: :required
2
- option :b, :"main-branch", "{{*}} Branch to use", default: "master", argument: :required
2
+ option :b, :"main-branch", "{{*}} Branch to use", argument: :required
3
3
  option :l, :limit, "{{*}} Limit number of files", argument: :required, transform: method(:Integer)
4
4
 
5
5
  flag nil, :dry, "{{*}} Run in dry mode"
@@ -78,6 +78,10 @@ def setup(r_args = [], opts, _args, files: [], reference:)
78
78
  say_debug "Cleared Rubocop`s cache"
79
79
  end
80
80
 
81
+ if opts[:debug]
82
+ Rfix.test = true
83
+ end
84
+
81
85
  if block_given?
82
86
  yield(repo, [])
83
87
  end
@@ -112,7 +116,7 @@ def setup(r_args = [], opts, _args, files: [], reference:)
112
116
  paths = files
113
117
  elsif paths.empty? && repo.paths.empty?
114
118
  if opts[:format] == "json"
115
- prt JSON.pretty_generate({"files": []})
119
+ prt JSON.pretty_generate({ "files": [] })
116
120
  exit 0
117
121
  else
118
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
@@ -31,9 +31,9 @@ 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
- # end
36
+ end
37
37
  end
38
38
 
39
39
  def say_abort(message)
@@ -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,12 +106,12 @@ 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
115
113
 
116
- say_debug("Run diff on #{reference}")
114
+ say_debug("Run diff on {{info:#{reference}}}")
117
115
  upstream.diff(head, **params).tap do |diff|
118
116
  diff.find_similar!(
119
117
  renames_from_rewrites: true,
@@ -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.2"
4
+ VERSION = "1.2.6"
5
5
  end
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.version = "#{Rfix::VERSION}-#{ENV.fetch('GITHUB_RUN_ID')}"
16
16
  else
17
17
  # rubocop:disable Gemspec/DuplicatedAssignment
18
- spec.version = [Rfix::VERSION, "pre"].join
18
+ spec.version = Rfix::VERSION
19
19
  # rubocop:enable Gemspec/DuplicatedAssignment
20
20
  end
21
21
 
@@ -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"
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.2.pre.174
4
+ version: 1.2.6
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-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -53,61 +53,61 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rouge
56
+ name: require_all
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.20'
61
+ version: 3.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.20'
68
+ version: 3.0.0
69
69
  - !ruby/object:Gem::Dependency
70
- name: rubocop
70
+ name: rouge
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.80'
75
+ version: '3.20'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.80'
82
+ version: '3.20'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rugged
84
+ name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.0.0
89
+ version: '0.80'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.0.0
96
+ version: '0.80'
97
97
  - !ruby/object:Gem::Dependency
98
- name: require_all
98
+ name: rugged
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 3.0.0
103
+ version: 1.0.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 3.0.0
110
+ version: 1.0.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -165,33 +165,33 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: 1.7.0
167
167
  - !ruby/object:Gem::Dependency
168
- name: rake
168
+ name: pry
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '12.3'
173
+ version: 0.13.1
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '12.3'
180
+ version: 0.13.1
181
181
  - !ruby/object:Gem::Dependency
182
- name: pry
182
+ name: rake
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: 0.13.1
187
+ version: '12.3'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: 0.13.1
194
+ version: '12.3'
195
195
  description: |
196
196
  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
197
 
@@ -325,7 +325,7 @@ licenses:
325
325
  - MIT
326
326
  metadata:
327
327
  homepage_uri: https://github.com/oleander/rfix-rb
328
- post_install_message:
328
+ post_install_message:
329
329
  rdoc_options: []
330
330
  require_paths:
331
331
  - lib
@@ -337,13 +337,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
337
337
  version: 2.5.0
338
338
  required_rubygems_version: !ruby/object:Gem::Requirement
339
339
  requirements:
340
- - - ">"
340
+ - - ">="
341
341
  - !ruby/object:Gem::Version
342
- version: 1.3.1
342
+ version: '0'
343
343
  requirements:
344
344
  - git, v2.0+
345
345
  rubygems_version: 3.0.3
346
- signing_key:
346
+ signing_key:
347
347
  specification_version: 4
348
348
  summary: RuboCop CLI that only lints and auto-fixes code you committed by utilizing
349
349
  `git-log` and `git-diff`