rfix 1.4.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/rfix +78 -34
- data/lib/rfix.rb +17 -28
- data/lib/rfix/branch.rb +3 -25
- data/lib/rfix/branch/base.rb +27 -0
- data/lib/rfix/branch/head.rb +15 -0
- data/lib/rfix/branch/main.rb +33 -0
- data/lib/rfix/branch/name.rb +21 -0
- data/lib/rfix/branch/reference.rb +15 -0
- data/lib/rfix/branch/upstream.rb +17 -0
- data/lib/rfix/cli/command.rb +19 -0
- data/lib/rfix/cli/command/base.rb +61 -0
- data/lib/rfix/cli/command/branch.rb +13 -0
- data/lib/rfix/cli/command/config.rb +22 -0
- data/lib/rfix/cli/command/extension.rb +25 -0
- data/lib/rfix/cli/command/help.rb +11 -0
- data/lib/rfix/cli/command/info.rb +11 -0
- data/lib/rfix/cli/command/lint.rb +17 -0
- data/lib/rfix/cli/command/local.rb +11 -0
- data/lib/rfix/cli/command/origin.rb +11 -0
- data/lib/rfix/cli/command/setup.rb +11 -0
- data/lib/rfix/error.rb +5 -1
- data/lib/rfix/extension/offense.rb +79 -0
- data/lib/rfix/extension/pastel.rb +11 -0
- data/lib/rfix/extension/string.rb +12 -0
- data/lib/rfix/extension/strings.rb +9 -0
- data/lib/rfix/file.rb +6 -41
- data/lib/rfix/file/base.rb +73 -0
- data/lib/rfix/file/deleted.rb +17 -0
- data/lib/rfix/file/ignored.rb +17 -0
- data/lib/rfix/file/tracked.rb +42 -0
- data/lib/rfix/file/untracked.rb +20 -0
- data/lib/rfix/formatter.rb +125 -86
- data/lib/rfix/highlighter.rb +118 -0
- data/lib/rfix/indicator.rb +19 -0
- data/lib/rfix/log.rb +12 -121
- data/lib/rfix/rake/gemfile.rb +111 -0
- data/lib/rfix/rake/paths.rb +25 -23
- data/lib/rfix/rake/support.rb +72 -57
- data/lib/rfix/repository.rb +114 -164
- data/lib/rfix/types.rb +52 -0
- data/lib/rfix/version.rb +1 -1
- data/rfix.gemspec +28 -38
- data/vendor/dry-cli/CHANGELOG.md +191 -0
- data/vendor/dry-cli/CODEOWNERS +1 -0
- data/vendor/dry-cli/CODE_OF_CONDUCT.md +13 -0
- data/vendor/dry-cli/CONTRIBUTING.md +29 -0
- data/vendor/dry-cli/Gemfile +14 -0
- data/vendor/dry-cli/Gemfile.devtools +18 -0
- data/vendor/dry-cli/LICENSE +20 -0
- data/vendor/dry-cli/README.md +29 -0
- data/vendor/dry-cli/Rakefile +13 -0
- data/vendor/dry-cli/bin/console +15 -0
- data/vendor/dry-cli/bin/setup +8 -0
- data/vendor/dry-cli/changelog.yml +97 -0
- data/vendor/dry-cli/docsite/source/arguments.html.md +57 -0
- data/vendor/dry-cli/docsite/source/callbacks.html.md +51 -0
- data/vendor/dry-cli/docsite/source/commands-with-subcommands-and-params.md +86 -0
- data/vendor/dry-cli/docsite/source/commands.html.md +41 -0
- data/vendor/dry-cli/docsite/source/index.html.md +302 -0
- data/vendor/dry-cli/docsite/source/options.html.md +51 -0
- data/vendor/dry-cli/docsite/source/subcommands.html.md +38 -0
- data/vendor/dry-cli/docsite/source/variadic-arguments.html.md +45 -0
- data/vendor/dry-cli/dry-cli.gemspec +36 -0
- data/vendor/dry-cli/lib/dry/cli.rb +224 -0
- data/vendor/dry-cli/lib/dry/cli/banner.rb +135 -0
- data/vendor/dry-cli/lib/dry/cli/command.rb +387 -0
- data/vendor/dry-cli/lib/dry/cli/command_registry.rb +253 -0
- data/vendor/dry-cli/lib/dry/cli/errors.rb +37 -0
- data/vendor/dry-cli/lib/dry/cli/inflector.rb +17 -0
- data/vendor/dry-cli/lib/dry/cli/inline.rb +75 -0
- data/vendor/dry-cli/lib/dry/cli/option.rb +131 -0
- data/vendor/dry-cli/lib/dry/cli/parser.rb +138 -0
- data/vendor/dry-cli/lib/dry/cli/program_name.rb +21 -0
- data/vendor/dry-cli/lib/dry/cli/registry.rb +338 -0
- data/vendor/dry-cli/lib/dry/cli/usage.rb +94 -0
- data/vendor/dry-cli/lib/dry/cli/version.rb +8 -0
- data/vendor/dry-cli/project.yml +13 -0
- data/vendor/dry-cli/spec/integration/commands_spec.rb +14 -0
- data/vendor/dry-cli/spec/integration/inherited_commands_spec.rb +24 -0
- data/vendor/dry-cli/spec/integration/inline_spec.rb +43 -0
- data/vendor/dry-cli/spec/integration/processes_errors_spec.rb +29 -0
- data/vendor/dry-cli/spec/integration/rendering_spec.rb +31 -0
- data/vendor/dry-cli/spec/integration/single_command_spec.rb +81 -0
- data/vendor/dry-cli/spec/integration/subcommands_spec.rb +60 -0
- data/vendor/dry-cli/spec/integration/third_party_gems_spec.rb +18 -0
- data/vendor/dry-cli/spec/spec_helper.rb +15 -0
- data/vendor/dry-cli/spec/support/coverage.rb +15 -0
- data/vendor/dry-cli/spec/support/files.rb +13 -0
- data/vendor/dry-cli/spec/support/fixtures/based +65 -0
- data/vendor/dry-cli/spec/support/fixtures/baz +9 -0
- data/vendor/dry-cli/spec/support/fixtures/baz_command.rb +19 -0
- data/vendor/dry-cli/spec/support/fixtures/foo +588 -0
- data/vendor/dry-cli/spec/support/fixtures/infinites +31 -0
- data/vendor/dry-cli/spec/support/fixtures/inline +20 -0
- data/vendor/dry-cli/spec/support/fixtures/registry.rb +15 -0
- data/vendor/dry-cli/spec/support/fixtures/shared_commands.rb +596 -0
- data/vendor/dry-cli/spec/support/fixtures/with_block.rb +86 -0
- data/vendor/dry-cli/spec/support/fixtures/with_registry.rb +90 -0
- data/vendor/dry-cli/spec/support/fixtures/with_zero_arity_block.rb +87 -0
- data/vendor/dry-cli/spec/support/helpers.rb +37 -0
- data/vendor/dry-cli/spec/support/path.rb +24 -0
- data/vendor/dry-cli/spec/support/rspec.rb +26 -0
- data/vendor/dry-cli/spec/support/rspec_options.rb +16 -0
- data/vendor/dry-cli/spec/support/shared_examples/commands.rb +300 -0
- data/vendor/dry-cli/spec/support/shared_examples/inherited_commands.rb +197 -0
- data/vendor/dry-cli/spec/support/shared_examples/rendering.rb +181 -0
- data/vendor/dry-cli/spec/support/shared_examples/subcommands.rb +226 -0
- data/vendor/dry-cli/spec/support/shared_examples/third_party_gems.rb +49 -0
- data/vendor/dry-cli/spec/support/warnings.rb +10 -0
- data/vendor/dry-cli/spec/unit/dry/cli/cli_spec.rb +123 -0
- data/vendor/dry-cli/spec/unit/dry/cli/inflector_spec.rb +26 -0
- data/vendor/dry-cli/spec/unit/dry/cli/registry_spec.rb +78 -0
- data/vendor/dry-cli/spec/unit/dry/cli/version_spec.rb +7 -0
- data/vendor/strings-ansi/CHANGELOG.md +24 -0
- data/vendor/strings-ansi/CODE_OF_CONDUCT.md +74 -0
- data/vendor/strings-ansi/Gemfile +11 -0
- data/{LICENSE.txt → vendor/strings-ansi/LICENSE.txt} +1 -1
- data/vendor/strings-ansi/README.md +155 -0
- data/vendor/strings-ansi/Rakefile +8 -0
- data/vendor/strings-ansi/appveyor.yml +32 -0
- data/vendor/strings-ansi/bin/console +14 -0
- data/vendor/strings-ansi/bin/setup +8 -0
- data/vendor/strings-ansi/lib/strings-ansi.rb +1 -0
- data/vendor/strings-ansi/lib/strings/ansi.rb +84 -0
- data/vendor/strings-ansi/lib/strings/ansi/extensions.rb +23 -0
- data/vendor/strings-ansi/lib/strings/ansi/version.rb +7 -0
- data/vendor/strings-ansi/spec/fixtures/ansi_codes.yaml +194 -0
- data/vendor/strings-ansi/spec/spec_helper.rb +51 -0
- data/vendor/strings-ansi/spec/unit/ansi_spec.rb +15 -0
- data/vendor/strings-ansi/spec/unit/extensions_spec.rb +19 -0
- data/vendor/strings-ansi/spec/unit/only_ansi_spec.rb +36 -0
- data/vendor/strings-ansi/spec/unit/sanitize_spec.rb +53 -0
- data/vendor/strings-ansi/strings-ansi.gemspec +34 -0
- data/vendor/strings-ansi/tasks/console.rake +11 -0
- data/vendor/strings-ansi/tasks/coverage.rake +11 -0
- data/vendor/strings-ansi/tasks/spec.rake +29 -0
- metadata +274 -188
- data/.github/workflows/main.yml +0 -26
- data/.gitignore +0 -43
- data/.rspec +0 -2
- data/.rubocop.yml +0 -87
- data/.travis.yml +0 -35
- data/Gemfile +0 -2
- data/Gemfile.base +0 -14
- data/Gemfile.base.lock +0 -172
- data/Gemfile.lock +0 -188
- data/Guardfile +0 -16
- data/Makefile +0 -12
- data/README.md +0 -85
- data/Rakefile +0 -31
- data/bin/bundle +0 -114
- data/bin/console +0 -29
- data/bin/guard +0 -29
- data/bin/rake +0 -29
- data/bin/rfix +0 -29
- data/bin/rspec +0 -29
- data/bin/setup +0 -29
- data/ci/Gemfile.rubocop-0.80 +0 -2
- data/ci/Gemfile.rubocop-0.80.lock +0 -170
- data/ci/Gemfile.rubocop-0.81 +0 -2
- data/ci/Gemfile.rubocop-0.81.lock +0 -170
- data/ci/Gemfile.rubocop-0.82 +0 -2
- data/ci/Gemfile.rubocop-0.82.lock +0 -170
- data/ci/Gemfile.rubocop-0.83 +0 -2
- data/ci/Gemfile.rubocop-0.83.lock +0 -168
- data/ci/Gemfile.rubocop-0.84 +0 -2
- data/ci/Gemfile.rubocop-0.84.lock +0 -171
- data/ci/Gemfile.rubocop-0.85 +0 -2
- data/ci/Gemfile.rubocop-0.85.1 +0 -2
- data/ci/Gemfile.rubocop-0.85.1.lock +0 -173
- data/ci/Gemfile.rubocop-0.85.lock +0 -173
- data/lib/rfix/box.rb +0 -112
- data/lib/rfix/branches/base.rb +0 -15
- data/lib/rfix/branches/head.rb +0 -13
- data/lib/rfix/branches/main.rb +0 -28
- data/lib/rfix/branches/name.rb +0 -23
- data/lib/rfix/branches/reference.rb +0 -21
- data/lib/rfix/branches/upstream.rb +0 -13
- data/lib/rfix/cmd.rb +0 -39
- data/lib/rfix/commands/branch.rb +0 -15
- data/lib/rfix/commands/extensions/options.rb +0 -8
- data/lib/rfix/commands/help.rb +0 -7
- data/lib/rfix/commands/helper/args.rb +0 -141
- data/lib/rfix/commands/helper/help.rb +0 -6
- data/lib/rfix/commands/helper/loader.rb +0 -6
- data/lib/rfix/commands/helper/option.rb +0 -0
- data/lib/rfix/commands/helper/params.rb +0 -0
- data/lib/rfix/commands/helper/rubocop.rb +0 -17
- data/lib/rfix/commands/info.rb +0 -30
- data/lib/rfix/commands/lint.rb +0 -22
- data/lib/rfix/commands/local.rb +0 -12
- data/lib/rfix/commands/origin.rb +0 -19
- data/lib/rfix/commands/setup.rb +0 -29
- data/lib/rfix/commands/welcome.rb +0 -24
- data/lib/rfix/deleted.rb +0 -13
- data/lib/rfix/extensions/extensions.rb +0 -18
- data/lib/rfix/extensions/offense.rb +0 -78
- data/lib/rfix/extensions/string.rb +0 -8
- data/lib/rfix/file_cache.rb +0 -59
- data/lib/rfix/git_helper.rb +0 -59
- data/lib/rfix/indentation.rb +0 -39
- data/lib/rfix/loader/bundler.rb +0 -37
- data/lib/rfix/loader/env.rb +0 -33
- data/lib/rfix/loader/spec.rb +0 -41
- data/lib/rfix/no_file.rb +0 -13
- data/lib/rfix/rfix.rb +0 -34
- data/lib/rfix/tracked.rb +0 -72
- data/lib/rfix/tracked_file.rb +0 -16
- data/lib/rfix/untracked.rb +0 -13
- data/resources/ps.png +0 -0
- data/tasks/bump.rake +0 -11
- data/tasks/bundle.rake +0 -17
- data/tasks/complex.rake +0 -54
- data/tasks/execute.rake +0 -38
- data/tasks/libgit2.rake +0 -33
- data/tasks/simple.rake +0 -62
- data/tasks/travis.rake +0 -74
- data/tasks/vendor.rake +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a31f67814cde7855a4bd826d9825c942cd11841690fb6f2ffaedaf3e64a04ab
|
4
|
+
data.tar.gz: 6f9dea0ec8da3c8ce5074ad47d45d56ec0ad0219a958f9ee04db5a1f1cae4e81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09ef5d35b5bd597e3d0314a5b7d1184991f257bd954f8083b056a563f02e101897bb32ab615f8b0b2e881b7a787651f80d4395dbfd263a9f8460b700ac7d9b81'
|
7
|
+
data.tar.gz: 9ec45b74b60114e0d65debc6aba9a9569d407705e7e05555e38771a3fad3a3147a0f57d67a1966b165a78c68f935742f6084d72cacf5e2079633935463bfe7ce
|
data/exe/rfix
CHANGED
@@ -1,51 +1,95 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env -S ruby -W0 --disable-all
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
4
|
+
require "rubygems"
|
5
|
+
require "pathname"
|
3
6
|
require "bundler"
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
+
module Path
|
9
|
+
HOME = Pathname("~").expand_path
|
10
|
+
DIR = Pathname(__dir__)
|
11
|
+
LOCK = "Gemfile.lock"
|
12
|
+
PWD = Pathname.getwd
|
13
|
+
PROJECT = DIR.join("..").expand_path
|
14
|
+
end
|
15
|
+
|
16
|
+
def lock_path
|
17
|
+
Path::PWD.ascend.find do |path|
|
18
|
+
return if (path <=> Path::HOME) == -1
|
19
|
+
|
20
|
+
path.join(Path::LOCK).file?
|
21
|
+
end.join(Path::LOCK)
|
22
|
+
end
|
23
|
+
|
24
|
+
def find(name, env: Bundler.rubygems)
|
25
|
+
env.loaded_specs(name) || env.find_name(name).max_by(&:version)
|
26
|
+
end
|
27
|
+
|
28
|
+
def deactivate(spec)
|
29
|
+
Gem.loaded_specs.delete(spec.name)
|
8
30
|
|
9
|
-
|
10
|
-
|
11
|
-
unless spec.__materialize__&.activation
|
12
|
-
abort "Could not load rubocop spec file"
|
31
|
+
$LOAD_PATH.reject! do |path|
|
32
|
+
spec.load_paths.include?(path)
|
13
33
|
end
|
14
34
|
end
|
15
35
|
|
16
|
-
|
17
|
-
unless
|
18
|
-
|
36
|
+
def specs
|
37
|
+
return [] unless (path = lock_path)
|
38
|
+
|
39
|
+
Bundler::LockfileParser.new(path.read).specs
|
40
|
+
end
|
41
|
+
|
42
|
+
def overlapping_specs
|
43
|
+
specs.select do |spec|
|
44
|
+
spec.name.start_with?("rubocop")
|
19
45
|
end
|
20
46
|
end
|
21
47
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
require "rubocop"
|
26
|
-
require "rfix/extensions/string"
|
27
|
-
require "rfix/commands/extensions/options"
|
28
|
-
require "rfix/commands/helper/loader"
|
29
|
-
require "rfix/branch"
|
48
|
+
def rfix
|
49
|
+
find("rfix")
|
50
|
+
end
|
30
51
|
|
31
|
-
|
32
|
-
|
52
|
+
def dev?
|
53
|
+
# $PROGRAM_NAME.end_with?("exe/rfix")
|
54
|
+
false
|
55
|
+
end
|
33
56
|
|
34
|
-
|
57
|
+
def rfix_path
|
58
|
+
return Pathname(__dir__).parent if dev?
|
35
59
|
|
36
|
-
|
37
|
-
root.add_command(Cri::Command.load_file(command, infer_name: true))
|
60
|
+
Pathname(rfix.full_gem_path)
|
38
61
|
end
|
39
62
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
else
|
44
|
-
prt root.help
|
45
|
-
exit 1
|
63
|
+
def commands
|
64
|
+
rfix_path.glob("lib/rfix/commands/*.rb").map do |command|
|
65
|
+
Cri::Command.load_file(command.to_path, infer_name: true)
|
46
66
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
67
|
+
end
|
68
|
+
|
69
|
+
def deactivate_all!
|
70
|
+
Gem.loaded_specs.each do |_name, spec|
|
71
|
+
deactivate(spec)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
deactivate_all!
|
76
|
+
|
77
|
+
require "bundler/inline"
|
78
|
+
gemfile(false, ui: Bundler::UI::Silent.new) do
|
79
|
+
overlapping_specs.each do |spec|
|
80
|
+
gem spec.name, spec.version
|
81
|
+
end
|
82
|
+
|
83
|
+
path rfix_path do
|
84
|
+
gem "rfix"
|
85
|
+
end
|
86
|
+
|
87
|
+
path rfix_path.join("vendor") do
|
88
|
+
gem "dry-cli", require: "dry/cli"
|
89
|
+
gem "strings-ansi"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
module Rfix
|
94
|
+
Dry::CLI.new(CLI::Command).call
|
51
95
|
end
|
data/lib/rfix.rb
CHANGED
@@ -1,35 +1,24 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
$LOAD_PATH.push Pathname(__dir__).join("../vendor/strings-ansi/lib")
|
4
|
+
$LOAD_PATH.push Pathname(__dir__).join("../vendor/dry-cli/lib")
|
5
5
|
|
6
|
-
require "
|
7
|
-
require "
|
8
|
-
require "
|
9
|
-
require "
|
10
|
-
require "rfix/cmd"
|
11
|
-
require "rfix/repository"
|
12
|
-
require "rfix/formatter"
|
13
|
-
require "rfix/indentation"
|
14
|
-
require "rfix/extensions/extensions"
|
15
|
-
require "rfix/extensions/offense"
|
16
|
-
require "rfix/branch"
|
17
|
-
require "rfix/rfix"
|
18
|
-
require "rfix/box"
|
19
|
-
require "rfix/error"
|
6
|
+
require "active_support/core_ext/module/attribute_accessors"
|
7
|
+
require "rubocop-ast"
|
8
|
+
require "zeitwerk"
|
9
|
+
require "rubocop"
|
20
10
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
11
|
+
loader = Zeitwerk::Loader.for_gem
|
12
|
+
loader.ignore("#{__dir__}/rfix/rake/paths")
|
13
|
+
loader.ignore("#{__dir__}/rfix/rake/support")
|
14
|
+
loader.ignore("#{__dir__}/rfix/loader")
|
15
|
+
loader.ignore("#{__dir__}/rfix/commands")
|
16
|
+
loader.ignore("#{__dir__}/rfix/extension/strings")
|
17
|
+
loader.ignore("#{__dir__}/rfix/extension/pastel")
|
18
|
+
loader.inflector.inflect "cli" => "CLI"
|
25
19
|
|
26
|
-
|
27
|
-
RuboCop::Cop::Offense.prepend(Rfix::Ext::Offense)
|
20
|
+
loader.setup
|
28
21
|
|
29
|
-
|
30
|
-
|
31
|
-
# TODO: Handle cases where color can't be resolved by CLI::UI
|
32
|
-
RuboCop::Formatter::SimpleTextFormatter::COLOR_FOR_SEVERITY.each do |severity, color|
|
33
|
-
id = RuboCop::Cop::Severity::CODE_TABLE.invert.fetch(severity)
|
34
|
-
CLI::UI::Glyph.new(id.to_s, 0x25cf, CLI::UI.resolve_color(color))
|
22
|
+
module Rfix
|
23
|
+
mattr_accessor :repo, :test
|
35
24
|
end
|
data/lib/rfix/branch.rb
CHANGED
@@ -1,31 +1,9 @@
|
|
1
|
-
|
2
|
-
require "rfix/error"
|
3
|
-
autoload_rel "branches/*.rb"
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
6
|
-
module Branch
|
7
|
-
class UnknownBranchError < Rfix::Error
|
8
|
-
end
|
9
|
-
|
10
|
-
class NotYetImplementedError < Rfix::Error
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
Pathname(__dir__).glob("branches/*.rb").each(&method(:require))
|
3
|
+
require "rugged"
|
16
4
|
|
17
5
|
module Rfix
|
18
6
|
module Branch
|
19
|
-
|
20
|
-
MAIN = Branch::Main.new
|
21
|
-
HEAD = Branch::Head.new
|
22
|
-
|
23
|
-
def self.local(at: Dir.pwd)
|
24
|
-
repo(at: at).branches.each_name(:local).sort
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.repo(at:)
|
28
|
-
Rugged::Repository.new(at)
|
29
|
-
end
|
7
|
+
# NOP
|
30
8
|
end
|
31
9
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dry/struct"
|
4
|
+
|
5
|
+
module Rfix
|
6
|
+
module Branch
|
7
|
+
class Base < Dry::Struct
|
8
|
+
attribute? :repository, Types::Rugged.default { Rugged::Repository.discover }
|
9
|
+
|
10
|
+
class UnknownBranchError < Error
|
11
|
+
def initialize(name)
|
12
|
+
super("Could not find branch {{error:#{name}}}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# @abstract
|
17
|
+
def resolve(*)
|
18
|
+
raise NotYetImplementedError, self.class.name
|
19
|
+
end
|
20
|
+
|
21
|
+
# @abstract
|
22
|
+
def to_s
|
23
|
+
raise NotYetImplementedError, self.class.name
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rfix
|
4
|
+
module Branch
|
5
|
+
class Main < Name
|
6
|
+
KEY = "rfix.main.branch"
|
7
|
+
|
8
|
+
class NoMainBranchSetError < Error
|
9
|
+
def initialize
|
10
|
+
super("Run 'rfix setup' to set the main branch")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.call(repository: Rugged::Repository.discover)
|
15
|
+
unless (name = repository.config[KEY])
|
16
|
+
raise NoMainBranchSetError
|
17
|
+
end
|
18
|
+
|
19
|
+
super(repository: repository, name: name)
|
20
|
+
rescue NoMainBranchSetError
|
21
|
+
if repository.head_detached?
|
22
|
+
raise Error, "HEAD is detached"
|
23
|
+
end
|
24
|
+
|
25
|
+
repository.branches[repository.head.name].then do |branch|
|
26
|
+
repository.config[KEY] = branch.name
|
27
|
+
end
|
28
|
+
|
29
|
+
retry
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rfix
|
4
|
+
module Branch
|
5
|
+
class Name < Base
|
6
|
+
attribute :name, Types::String
|
7
|
+
|
8
|
+
def resolve
|
9
|
+
unless (branch = repository.branches[name])
|
10
|
+
raise UnknownBranchError, branch
|
11
|
+
end
|
12
|
+
|
13
|
+
repository.lookup(repository.merge_base(branch.target_id, repository.head.target_id))
|
14
|
+
rescue Rugged::ReferenceError
|
15
|
+
raise UnknownBranchError, name
|
16
|
+
end
|
17
|
+
|
18
|
+
alias to_s name
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rfix
|
4
|
+
module Branch
|
5
|
+
class Reference < Base
|
6
|
+
attribute :name, Types::String
|
7
|
+
|
8
|
+
def resolve
|
9
|
+
repository.lookup(repository.rev_parse(name).oid)
|
10
|
+
rescue Rugged::Error, Rugged::InvalidError
|
11
|
+
raise Error, name
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rfix
|
4
|
+
module Branch
|
5
|
+
class Upstream < Base
|
6
|
+
def resolve
|
7
|
+
repository.rev_parse("@{upstream}")
|
8
|
+
rescue Rugged::ConfigError
|
9
|
+
raise Error, "No upstream branch defined"
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
"upstream"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dry/cli"
|
4
|
+
|
5
|
+
module Rfix
|
6
|
+
module CLI
|
7
|
+
module Command
|
8
|
+
extend Dry::CLI::Registry
|
9
|
+
|
10
|
+
register "origin", Origin
|
11
|
+
register "branch", Branch
|
12
|
+
register "local", Local
|
13
|
+
register "setup", Setup
|
14
|
+
register "lint", Lint
|
15
|
+
register "info", Info
|
16
|
+
register "help", Help
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/module/concerning"
|
4
|
+
require "dry/core/constants"
|
5
|
+
require "rubocop"
|
6
|
+
require "rainbow"
|
7
|
+
require "rugged"
|
8
|
+
|
9
|
+
require "rfix/extension/pastel"
|
10
|
+
require "rfix/extension/strings"
|
11
|
+
|
12
|
+
module Rfix
|
13
|
+
module CLI
|
14
|
+
module Command
|
15
|
+
class Base < Dry::CLI::Command
|
16
|
+
include Log
|
17
|
+
include Dry::Core::Constants
|
18
|
+
|
19
|
+
class RuboCop::CommentConfig
|
20
|
+
concerning :Verification, prepend: true do
|
21
|
+
def cop_enabled_at_line?(cop, line)
|
22
|
+
repository.include?(processed_source.file_path, line) && super(cop, line)
|
23
|
+
rescue StandardError => e
|
24
|
+
abort e.full_message(highlight: true)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
option :formatters, type: :array, default: ["Rfix::Formatter"]
|
30
|
+
option :format, type: :string, default: "Rfix::Formatter"
|
31
|
+
option :auto_correct_all, type: :boolean, default: true
|
32
|
+
option :auto_correct, type: :boolean, default: true
|
33
|
+
option :cache, type: :boolean, default: true
|
34
|
+
option :debug, type: :boolean, default: false
|
35
|
+
option :only_recognized_file_types, type: :boolean, default: true
|
36
|
+
option :force_exclusion, type: :boolean, default: true
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def define(reference, args: Undefined, **params)
|
41
|
+
handler = Rfix::Repository.new(
|
42
|
+
repository: reference.repository,
|
43
|
+
reference: reference
|
44
|
+
)
|
45
|
+
|
46
|
+
RuboCop::CommentConfig.class_eval do
|
47
|
+
concerning :Repository do
|
48
|
+
define_method(:repository, &handler.method(:itself))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
Undefined.default(args, handler.paths).then do |paths|
|
53
|
+
RuboCop::CLI::Environment.new(params, RuboCop::ConfigStore.new, paths)
|
54
|
+
end.then do |env|
|
55
|
+
RuboCop::CLI::Command::ExecuteRunner.new(env).run
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|