rfix 1.4.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/exe/rfix +78 -34
  3. data/lib/rfix.rb +17 -28
  4. data/lib/rfix/branch.rb +3 -25
  5. data/lib/rfix/branch/base.rb +27 -0
  6. data/lib/rfix/branch/head.rb +15 -0
  7. data/lib/rfix/branch/main.rb +33 -0
  8. data/lib/rfix/branch/name.rb +21 -0
  9. data/lib/rfix/branch/reference.rb +15 -0
  10. data/lib/rfix/branch/upstream.rb +17 -0
  11. data/lib/rfix/cli/command.rb +19 -0
  12. data/lib/rfix/cli/command/base.rb +61 -0
  13. data/lib/rfix/cli/command/branch.rb +13 -0
  14. data/lib/rfix/cli/command/config.rb +22 -0
  15. data/lib/rfix/cli/command/extension.rb +25 -0
  16. data/lib/rfix/cli/command/help.rb +11 -0
  17. data/lib/rfix/cli/command/info.rb +11 -0
  18. data/lib/rfix/cli/command/lint.rb +17 -0
  19. data/lib/rfix/cli/command/local.rb +11 -0
  20. data/lib/rfix/cli/command/origin.rb +11 -0
  21. data/lib/rfix/cli/command/setup.rb +11 -0
  22. data/lib/rfix/error.rb +5 -1
  23. data/lib/rfix/extension/offense.rb +79 -0
  24. data/lib/rfix/extension/pastel.rb +11 -0
  25. data/lib/rfix/extension/string.rb +12 -0
  26. data/lib/rfix/extension/strings.rb +9 -0
  27. data/lib/rfix/file.rb +6 -41
  28. data/lib/rfix/file/base.rb +73 -0
  29. data/lib/rfix/file/deleted.rb +17 -0
  30. data/lib/rfix/file/ignored.rb +17 -0
  31. data/lib/rfix/file/tracked.rb +42 -0
  32. data/lib/rfix/file/untracked.rb +20 -0
  33. data/lib/rfix/formatter.rb +125 -86
  34. data/lib/rfix/highlighter.rb +118 -0
  35. data/lib/rfix/indicator.rb +19 -0
  36. data/lib/rfix/log.rb +12 -121
  37. data/lib/rfix/rake/gemfile.rb +111 -0
  38. data/lib/rfix/rake/paths.rb +25 -23
  39. data/lib/rfix/rake/support.rb +72 -57
  40. data/lib/rfix/repository.rb +114 -164
  41. data/lib/rfix/types.rb +52 -0
  42. data/lib/rfix/version.rb +1 -1
  43. data/rfix.gemspec +28 -38
  44. data/vendor/dry-cli/CHANGELOG.md +191 -0
  45. data/vendor/dry-cli/CODEOWNERS +1 -0
  46. data/vendor/dry-cli/CODE_OF_CONDUCT.md +13 -0
  47. data/vendor/dry-cli/CONTRIBUTING.md +29 -0
  48. data/vendor/dry-cli/Gemfile +14 -0
  49. data/vendor/dry-cli/Gemfile.devtools +18 -0
  50. data/vendor/dry-cli/LICENSE +20 -0
  51. data/vendor/dry-cli/README.md +29 -0
  52. data/vendor/dry-cli/Rakefile +13 -0
  53. data/vendor/dry-cli/bin/console +15 -0
  54. data/vendor/dry-cli/bin/setup +8 -0
  55. data/vendor/dry-cli/changelog.yml +97 -0
  56. data/vendor/dry-cli/docsite/source/arguments.html.md +57 -0
  57. data/vendor/dry-cli/docsite/source/callbacks.html.md +51 -0
  58. data/vendor/dry-cli/docsite/source/commands-with-subcommands-and-params.md +86 -0
  59. data/vendor/dry-cli/docsite/source/commands.html.md +41 -0
  60. data/vendor/dry-cli/docsite/source/index.html.md +302 -0
  61. data/vendor/dry-cli/docsite/source/options.html.md +51 -0
  62. data/vendor/dry-cli/docsite/source/subcommands.html.md +38 -0
  63. data/vendor/dry-cli/docsite/source/variadic-arguments.html.md +45 -0
  64. data/vendor/dry-cli/dry-cli.gemspec +36 -0
  65. data/vendor/dry-cli/lib/dry/cli.rb +224 -0
  66. data/vendor/dry-cli/lib/dry/cli/banner.rb +135 -0
  67. data/vendor/dry-cli/lib/dry/cli/command.rb +387 -0
  68. data/vendor/dry-cli/lib/dry/cli/command_registry.rb +253 -0
  69. data/vendor/dry-cli/lib/dry/cli/errors.rb +37 -0
  70. data/vendor/dry-cli/lib/dry/cli/inflector.rb +17 -0
  71. data/vendor/dry-cli/lib/dry/cli/inline.rb +75 -0
  72. data/vendor/dry-cli/lib/dry/cli/option.rb +131 -0
  73. data/vendor/dry-cli/lib/dry/cli/parser.rb +138 -0
  74. data/vendor/dry-cli/lib/dry/cli/program_name.rb +21 -0
  75. data/vendor/dry-cli/lib/dry/cli/registry.rb +338 -0
  76. data/vendor/dry-cli/lib/dry/cli/usage.rb +94 -0
  77. data/vendor/dry-cli/lib/dry/cli/version.rb +8 -0
  78. data/vendor/dry-cli/project.yml +13 -0
  79. data/vendor/dry-cli/spec/integration/commands_spec.rb +14 -0
  80. data/vendor/dry-cli/spec/integration/inherited_commands_spec.rb +24 -0
  81. data/vendor/dry-cli/spec/integration/inline_spec.rb +43 -0
  82. data/vendor/dry-cli/spec/integration/processes_errors_spec.rb +29 -0
  83. data/vendor/dry-cli/spec/integration/rendering_spec.rb +31 -0
  84. data/vendor/dry-cli/spec/integration/single_command_spec.rb +81 -0
  85. data/vendor/dry-cli/spec/integration/subcommands_spec.rb +60 -0
  86. data/vendor/dry-cli/spec/integration/third_party_gems_spec.rb +18 -0
  87. data/vendor/dry-cli/spec/spec_helper.rb +15 -0
  88. data/vendor/dry-cli/spec/support/coverage.rb +15 -0
  89. data/vendor/dry-cli/spec/support/files.rb +13 -0
  90. data/vendor/dry-cli/spec/support/fixtures/based +65 -0
  91. data/vendor/dry-cli/spec/support/fixtures/baz +9 -0
  92. data/vendor/dry-cli/spec/support/fixtures/baz_command.rb +19 -0
  93. data/vendor/dry-cli/spec/support/fixtures/foo +588 -0
  94. data/vendor/dry-cli/spec/support/fixtures/infinites +31 -0
  95. data/vendor/dry-cli/spec/support/fixtures/inline +20 -0
  96. data/vendor/dry-cli/spec/support/fixtures/registry.rb +15 -0
  97. data/vendor/dry-cli/spec/support/fixtures/shared_commands.rb +596 -0
  98. data/vendor/dry-cli/spec/support/fixtures/with_block.rb +86 -0
  99. data/vendor/dry-cli/spec/support/fixtures/with_registry.rb +90 -0
  100. data/vendor/dry-cli/spec/support/fixtures/with_zero_arity_block.rb +87 -0
  101. data/vendor/dry-cli/spec/support/helpers.rb +37 -0
  102. data/vendor/dry-cli/spec/support/path.rb +24 -0
  103. data/vendor/dry-cli/spec/support/rspec.rb +26 -0
  104. data/vendor/dry-cli/spec/support/rspec_options.rb +16 -0
  105. data/vendor/dry-cli/spec/support/shared_examples/commands.rb +300 -0
  106. data/vendor/dry-cli/spec/support/shared_examples/inherited_commands.rb +197 -0
  107. data/vendor/dry-cli/spec/support/shared_examples/rendering.rb +181 -0
  108. data/vendor/dry-cli/spec/support/shared_examples/subcommands.rb +226 -0
  109. data/vendor/dry-cli/spec/support/shared_examples/third_party_gems.rb +49 -0
  110. data/vendor/dry-cli/spec/support/warnings.rb +10 -0
  111. data/vendor/dry-cli/spec/unit/dry/cli/cli_spec.rb +123 -0
  112. data/vendor/dry-cli/spec/unit/dry/cli/inflector_spec.rb +26 -0
  113. data/vendor/dry-cli/spec/unit/dry/cli/registry_spec.rb +78 -0
  114. data/vendor/dry-cli/spec/unit/dry/cli/version_spec.rb +7 -0
  115. data/vendor/strings-ansi/CHANGELOG.md +24 -0
  116. data/vendor/strings-ansi/CODE_OF_CONDUCT.md +74 -0
  117. data/vendor/strings-ansi/Gemfile +11 -0
  118. data/{LICENSE.txt → vendor/strings-ansi/LICENSE.txt} +1 -1
  119. data/vendor/strings-ansi/README.md +155 -0
  120. data/vendor/strings-ansi/Rakefile +8 -0
  121. data/vendor/strings-ansi/appveyor.yml +32 -0
  122. data/vendor/strings-ansi/bin/console +14 -0
  123. data/vendor/strings-ansi/bin/setup +8 -0
  124. data/vendor/strings-ansi/lib/strings-ansi.rb +1 -0
  125. data/vendor/strings-ansi/lib/strings/ansi.rb +84 -0
  126. data/vendor/strings-ansi/lib/strings/ansi/extensions.rb +23 -0
  127. data/vendor/strings-ansi/lib/strings/ansi/version.rb +7 -0
  128. data/vendor/strings-ansi/spec/fixtures/ansi_codes.yaml +194 -0
  129. data/vendor/strings-ansi/spec/spec_helper.rb +51 -0
  130. data/vendor/strings-ansi/spec/unit/ansi_spec.rb +15 -0
  131. data/vendor/strings-ansi/spec/unit/extensions_spec.rb +19 -0
  132. data/vendor/strings-ansi/spec/unit/only_ansi_spec.rb +36 -0
  133. data/vendor/strings-ansi/spec/unit/sanitize_spec.rb +53 -0
  134. data/vendor/strings-ansi/strings-ansi.gemspec +34 -0
  135. data/vendor/strings-ansi/tasks/console.rake +11 -0
  136. data/vendor/strings-ansi/tasks/coverage.rake +11 -0
  137. data/vendor/strings-ansi/tasks/spec.rake +29 -0
  138. metadata +274 -188
  139. data/.github/workflows/main.yml +0 -26
  140. data/.gitignore +0 -43
  141. data/.rspec +0 -2
  142. data/.rubocop.yml +0 -87
  143. data/.travis.yml +0 -35
  144. data/Gemfile +0 -2
  145. data/Gemfile.base +0 -14
  146. data/Gemfile.base.lock +0 -172
  147. data/Gemfile.lock +0 -188
  148. data/Guardfile +0 -16
  149. data/Makefile +0 -12
  150. data/README.md +0 -85
  151. data/Rakefile +0 -31
  152. data/bin/bundle +0 -114
  153. data/bin/console +0 -29
  154. data/bin/guard +0 -29
  155. data/bin/rake +0 -29
  156. data/bin/rfix +0 -29
  157. data/bin/rspec +0 -29
  158. data/bin/setup +0 -29
  159. data/ci/Gemfile.rubocop-0.80 +0 -2
  160. data/ci/Gemfile.rubocop-0.80.lock +0 -170
  161. data/ci/Gemfile.rubocop-0.81 +0 -2
  162. data/ci/Gemfile.rubocop-0.81.lock +0 -170
  163. data/ci/Gemfile.rubocop-0.82 +0 -2
  164. data/ci/Gemfile.rubocop-0.82.lock +0 -170
  165. data/ci/Gemfile.rubocop-0.83 +0 -2
  166. data/ci/Gemfile.rubocop-0.83.lock +0 -168
  167. data/ci/Gemfile.rubocop-0.84 +0 -2
  168. data/ci/Gemfile.rubocop-0.84.lock +0 -171
  169. data/ci/Gemfile.rubocop-0.85 +0 -2
  170. data/ci/Gemfile.rubocop-0.85.1 +0 -2
  171. data/ci/Gemfile.rubocop-0.85.1.lock +0 -173
  172. data/ci/Gemfile.rubocop-0.85.lock +0 -173
  173. data/lib/rfix/box.rb +0 -112
  174. data/lib/rfix/branches/base.rb +0 -15
  175. data/lib/rfix/branches/head.rb +0 -13
  176. data/lib/rfix/branches/main.rb +0 -28
  177. data/lib/rfix/branches/name.rb +0 -23
  178. data/lib/rfix/branches/reference.rb +0 -21
  179. data/lib/rfix/branches/upstream.rb +0 -13
  180. data/lib/rfix/cmd.rb +0 -39
  181. data/lib/rfix/commands/branch.rb +0 -15
  182. data/lib/rfix/commands/extensions/options.rb +0 -8
  183. data/lib/rfix/commands/help.rb +0 -7
  184. data/lib/rfix/commands/helper/args.rb +0 -141
  185. data/lib/rfix/commands/helper/help.rb +0 -6
  186. data/lib/rfix/commands/helper/loader.rb +0 -6
  187. data/lib/rfix/commands/helper/option.rb +0 -0
  188. data/lib/rfix/commands/helper/params.rb +0 -0
  189. data/lib/rfix/commands/helper/rubocop.rb +0 -17
  190. data/lib/rfix/commands/info.rb +0 -30
  191. data/lib/rfix/commands/lint.rb +0 -22
  192. data/lib/rfix/commands/local.rb +0 -12
  193. data/lib/rfix/commands/origin.rb +0 -19
  194. data/lib/rfix/commands/setup.rb +0 -29
  195. data/lib/rfix/commands/welcome.rb +0 -24
  196. data/lib/rfix/deleted.rb +0 -13
  197. data/lib/rfix/extensions/extensions.rb +0 -18
  198. data/lib/rfix/extensions/offense.rb +0 -78
  199. data/lib/rfix/extensions/string.rb +0 -8
  200. data/lib/rfix/file_cache.rb +0 -59
  201. data/lib/rfix/git_helper.rb +0 -59
  202. data/lib/rfix/indentation.rb +0 -39
  203. data/lib/rfix/loader/bundler.rb +0 -37
  204. data/lib/rfix/loader/env.rb +0 -33
  205. data/lib/rfix/loader/spec.rb +0 -41
  206. data/lib/rfix/no_file.rb +0 -13
  207. data/lib/rfix/rfix.rb +0 -34
  208. data/lib/rfix/tracked.rb +0 -72
  209. data/lib/rfix/tracked_file.rb +0 -16
  210. data/lib/rfix/untracked.rb +0 -13
  211. data/resources/ps.png +0 -0
  212. data/tasks/bump.rake +0 -11
  213. data/tasks/bundle.rake +0 -17
  214. data/tasks/complex.rake +0 -54
  215. data/tasks/execute.rake +0 -38
  216. data/tasks/libgit2.rake +0 -33
  217. data/tasks/simple.rake +0 -62
  218. data/tasks/travis.rake +0 -74
  219. data/tasks/vendor.rake +0 -34
@@ -1,15 +0,0 @@
1
- r_args = []
2
-
3
- helper("help", binding)
4
- helper("rubocop", binding)
5
- helper("args", binding)
6
-
7
- param :branch
8
- usage "rfix branch BRANCH [opts] [-p path ..]"
9
- option :p, :path, "Path to be passed to RuboCop", argument: :required, multiple: true
10
- summary "Fix changes made between HEAD and <branch>"
11
-
12
- run do |opts, args, _cmd|
13
- branch = Rfix::Branch::Reference.new(args[:branch])
14
- setup(r_args, opts, args, files: opts[:path] || [], reference: branch)
15
- end
@@ -1,8 +0,0 @@
1
- module Rfix::Ext::Opt
2
- def define_options
3
- @define_options ||= super
4
- end
5
- alias opts define_options
6
- end
7
-
8
- RuboCop::Options.prepend(Rfix::Ext::Opt)
@@ -1,7 +0,0 @@
1
- extend Rfix::Log
2
-
3
- summary "Displays help"
4
-
5
- run do |_opts, _args, cmd|
6
- prt cmd.supercommand.help
7
- end
@@ -1,141 +0,0 @@
1
- option :r, :root, "{{*}} Project root path", default: Dir.pwd, argument: :required
2
- option :b, :"main-branch", "{{*}} Branch to use", argument: :required
3
- option :l, :limit, "{{*}} Limit number of files", argument: :required, transform: method(:Integer)
4
-
5
- flag nil, :dry, "{{*}} Run in dry mode"
6
- flag nil, :untracked, "{{*}} Load untracked files"
7
- flag nil, :"clear-cache", "{{*}} Clear Rubocop`s cache"
8
- flag nil, :test, "{{*}} Used in tests"
9
-
10
- def validate!(files:)
11
- return [] unless files.is_a?(Array)
12
-
13
- files.each do |file|
14
- unless File.exist?(file)
15
- say_abort "Passed file {{error:#{file}}} does not exist"
16
- end
17
- end
18
-
19
- files
20
- end
21
-
22
- def setup(r_args = [], opts, _args, files: [], reference:)
23
- # files = validate!(files: files)
24
- options = RuboCop::Options.new
25
- store = RuboCop::ConfigStore.new
26
-
27
- params = {
28
- force_exclusion: true,
29
- formatters: ["Rfix::Formatter"],
30
- auto_correct: true
31
- }
32
-
33
- if opts.key?(:format)
34
- params.delete(:formatters)
35
- end
36
-
37
- if opts.key?(:dry)
38
- params[:auto_correct] = false
39
- end
40
-
41
- if opts.key?(:test)
42
- params.delete(:formatters)
43
- params[:format] = "json"
44
- params[:cache] = "false"
45
- Rfix.test = true
46
-
47
- unless opts.key?(:root)
48
- raise "No --root passed with --test"
49
- end
50
-
51
- unless opts.key?(:config)
52
- raise "No --config passed with --test"
53
- end
54
- end
55
-
56
- if opts[:cache] == "false"
57
- params[:cache] = "false"
58
- end
59
-
60
- begin
61
- Rfix.repo = repo = Rfix::Repository.new(
62
- root_path: opts[:root],
63
- load_untracked: opts[:untracked],
64
- reference: reference,
65
- paths: files || []
66
- )
67
- rescue Rugged::RepositoryError => e
68
- say_abort e.to_s
69
- rescue Rfix::Error => e
70
- say_abort e.to_s
71
- end
72
-
73
- # RuboCop::ResultCache.cleanup(store, true)
74
-
75
- if opts[:"clear-cache"]
76
- RuboCop::ResultCache.cleanup(store, true)
77
- params[:cache] = "false"
78
- say_debug "Cleared Rubocop`s cache"
79
- end
80
-
81
- if opts[:debug]
82
- Rfix.test = true
83
- end
84
-
85
- if block_given?
86
- yield(repo, [])
87
- end
88
-
89
- begin
90
- params2, paths = options.parse(r_args)
91
- rescue OptionParser::MissingArgument => e
92
- say_abort e.to_s
93
- end
94
-
95
- params2.merge!(params)
96
-
97
- begin
98
- if config = opts[:config]
99
- store.options_config = config
100
- elsif root_path = opts[:root]
101
- store.for(root_path)
102
- end
103
- rescue RuboCop::Error => e
104
- say_abort e.to_s
105
- rescue TypeError => e
106
- say_abort e.to_s
107
- rescue Psych::SyntaxError => e
108
- say_abort e.to_s
109
- end
110
-
111
- # unless files.empty?
112
- # say "Loading files from {{italic:#{files.join(', ')}}}"
113
- # end
114
-
115
- if !files.empty?
116
- paths = files
117
- elsif paths.empty? && repo.paths.empty?
118
- if opts[:format] == "json"
119
- prt JSON.pretty_generate({ "files": [] })
120
- exit 0
121
- else
122
- say_exit "Everything looks good, nothing to lint"
123
- end
124
- elsif paths.empty?
125
- paths = repo.paths
126
- end
127
-
128
- if limit = opts[:limit]
129
- paths = paths.take(limit)
130
- end
131
-
132
- env = RuboCop::CLI::Environment.new(params2, store, paths)
133
-
134
- begin
135
- exit RuboCop::CLI::Command::ExecuteRunner.new(env).run
136
- rescue RuboCop::Runner::InfiniteCorrectionLoop => e
137
- say_abort e.to_s
138
- rescue RuboCop::Error => e
139
- say_abort e.to_s
140
- end
141
- end
@@ -1,6 +0,0 @@
1
- extend Rfix::Log
2
-
3
- flag :h, :help, "show help for this command" do |_value, cmd|
4
- prt cmd.help
5
- exit 0
6
- end
@@ -1,6 +0,0 @@
1
- module Rfix::Loader
2
- def helper(file, bind)
3
- path = File.join(__dir__, file + ".rb")
4
- eval(IO.read(path), bind, path)
5
- end
6
- end
File without changes
File without changes
@@ -1,17 +0,0 @@
1
- RuboCop::Options.new.opts.instance_eval("@stack", __FILE__, __LINE__).map(&:list).flatten.each do |opt|
2
- short = opt.short.map { |arg| arg.delete_prefix("-") }
3
- long = opt.long.map { |arg| arg.delete_prefix("--") }
4
-
5
- short.unshift(nil) if opt.short.empty?
6
- long.unshift(nil) if opt.long.empty?
7
-
8
- if opt.arg
9
- option(*short, *long, opt.desc.join(" "), argument: :optional) do |value|
10
- r_args.append(*opt.long, value)
11
- end
12
- else
13
- flag(*short, *long, opt.desc.join(" ")) do
14
- r_args.append(*opt.long)
15
- end
16
- end
17
- end
@@ -1,30 +0,0 @@
1
- require "rbconfig"
2
- require "rugged"
3
-
4
- extend Rfix::Log
5
- extend Rfix::Cmd
6
-
7
- def git_version
8
- cmd("git --version").last.split(/\s+/, 3).last
9
- end
10
-
11
- def ruby_version
12
- RbConfig::CONFIG["ruby_version"] || "<unknown>"
13
- end
14
-
15
- def current_os
16
- RbConfig::CONFIG["host_os"] || "<unknown>"
17
- end
18
-
19
- helper("help", binding)
20
-
21
- summary "Display runtime dependencies and their version"
22
-
23
- run do |_opts, _args|
24
- say "Using RuboCop {{info:#{RuboCop::Version.version}}}"
25
- say "Using Rugged {{info:#{Rugged::VERSION}}}"
26
- say "Using Rfix {{info:#{Rfix::VERSION}}}"
27
- say "Using OS {{info:#{current_os}}}"
28
- say "Using Git {{info:#{git_version}}}"
29
- say "Using Ruby {{info:#{ruby_version}}}"
30
- end
@@ -1,22 +0,0 @@
1
- r_args = []
2
-
3
- helper("help", binding)
4
- helper("rubocop", binding)
5
- helper("args", binding)
6
-
7
- summary "Lints commits and untracked files not yet pushed to upstream"
8
- usage "rfix lint [opts] [path ..]"
9
- description "Lint (read-only) files"
10
-
11
- run do |opts, args, _cmd|
12
- opts[:dry] = true
13
- opts[:untracked] = true
14
-
15
- if main = opts[:"main-branch"]
16
- branch = Rfix::Branch::Name.new(main)
17
- else
18
- branch = Rfix::Branch::MAIN
19
- end
20
-
21
- setup(r_args, opts, args, files: args.each.to_a, reference: branch)
22
- end
@@ -1,12 +0,0 @@
1
- r_args = []
2
-
3
- helper("help", binding)
4
- helper("rubocop", binding)
5
- helper("args", binding)
6
-
7
- summary "Auto-fixes commits not yet pushed to upstream"
8
- usage "rfix local [opts] [path ..]"
9
-
10
- run do |opts, args, _cmd|
11
- setup(r_args, opts, args, files: args.each.to_a, reference: Rfix::Branch::UPSTREAM)
12
- end
@@ -1,19 +0,0 @@
1
- r_args = []
2
-
3
- helper("help", binding)
4
- helper("rubocop", binding)
5
- helper("args", binding)
6
-
7
- summary "Auto-fixes commits between HEAD and origin branch"
8
- usage "rfix origin [opts] [path ..]"
9
-
10
- run do |opts, args, _cmd|
11
- if main = opts[:"main-branch"]
12
- branch = Rfix::Branch::Name.new(main)
13
- else
14
- branch = Rfix::Branch::MAIN
15
- end
16
-
17
- # say "Using {{red:#{branch}}} as main branch"
18
- setup(r_args, opts, args, files: args.each.to_a, reference: branch)
19
- end
@@ -1,29 +0,0 @@
1
- helper("help", binding)
2
-
3
- option :r, :root, "{{*}} Project root path", default: Dir.pwd, argument: :required
4
- option :b, :"main-branch", "{{*}} Branch to use", argument: :optional
5
-
6
- summary "Sets the default branch for {{command:rfix local}}"
7
-
8
- def set_branch(root_path, branch)
9
- Rfix::Branch::Main.set(branch, at: root_path)
10
- say "Main branch was set to {{italic:#{branch}}}"
11
- end
12
-
13
- run do |opts, _args|
14
- if branch = Rfix::Branch::Main.get(at: opts[:root])
15
- say "Current main branch set to {{info:#{branch}}}"
16
- end
17
-
18
- if branch = opts[:"main-branch"]
19
- next set_branch(opts[:root], branch)
20
- end
21
-
22
- CLI::UI::Prompt.ask("Which one is your main branch?") do |handler|
23
- Rfix::Branch.local(at: opts[:root]).each do |branch|
24
- handler.option(branch) do |selection|
25
- set_branch(opts[:root], selection)
26
- end
27
- end
28
- end
29
- end
@@ -1,24 +0,0 @@
1
- r_args = []
2
-
3
- helper("help", binding)
4
-
5
- summary "This is how you get started with {{command:rfix}}"
6
-
7
- run do |_opts, _args, _cmd|
8
- indent = " " * 2
9
- prt "{{v}} Thank you for installing {{green:rfix v#{Rfix::VERSION}}}!\n"
10
- prt ""
11
- prt "{{i}} Run {{command:rfix help}} for avalible commands or any of the following to get started:"
12
- prt ""
13
- prt "#{indent}{{command:$ rfix local}} {{italic:# Auto-fixes commits not yet pushed to upstream}}"
14
- prt "#{indent}{{command:$ rfix origin}} {{italic:# Auto-fixes commits between HEAD and origin branch}}"
15
- prt "#{indent}{{command:$ rfix lint}} {{italic:# Lints commits and untracked files not yet pushed to upstream}}"
16
- prt ""
17
- prt "{{*}} {{bold:ProTip:}} Append {{command:--dry}} to run {{command:rfix}} in {{warning:read-only}} mode"
18
- prt ""
19
- prt "{{i}} {{bold:Issues}} {{italic:https://github.com/oleander/rfix-rb/issues}}"
20
- prt "{{i}} {{bold:Readme}} {{italic:https://github.com/oleander/rfix-rb/blob/master/README.md}}"
21
- prt "{{i}} {{bold:Travis}} {{italic:https://travis-ci.org/github/oleander/rfix-rb}}"
22
- prt ""
23
- prt "{{italic:~ Linus}}\n"
24
- end
data/lib/rfix/deleted.rb DELETED
@@ -1,13 +0,0 @@
1
- class Rfix::Deleted < Rfix::File
2
- def include?(_)
3
- return false
4
- end
5
-
6
- def refresh!
7
- # NOP
8
- end
9
-
10
- def inspect
11
- "<Deleted({{info:#{path}}})>"
12
- end
13
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubocop"
4
- require "rainbow"
5
- require "rfix/log"
6
-
7
- module Rfix::Ext
8
- module CommentConfig
9
- include Rfix::Log # TODO: Remove
10
- # Called by RuboCop on every line to see
11
- # if its suppose to run against it or not
12
- def cop_enabled_at_line?(_cop, line)
13
- Rfix.enabled?(processed_source.file_path, line) && super
14
- rescue StandardError
15
- say_abort "[Rfix::Enabled] #{$ERROR_INFO}"
16
- end
17
- end
18
- end
@@ -1,78 +0,0 @@
1
- module Rfix::Ext
2
- module Offense
3
- def where
4
- line.to_s + ":" + real_column.to_s
5
- end
6
-
7
- def info
8
- message.split(": ", 2).last.delete("\n")
9
- end
10
-
11
- def msg
12
- CLI::UI.resolve_text("{{italic:#{info}}}", truncate_to: CLI::UI::Terminal.width - 10)
13
- end
14
-
15
- def code
16
- message.split(": ", 2).first
17
- end
18
-
19
- def star
20
- Rainbow("⭑")
21
- end
22
-
23
- def cross
24
- Rainbow("✗").red
25
- end
26
-
27
- def check
28
- Rainbow("✓").green
29
- end
30
-
31
- def circle
32
- Rainbow("⍟")
33
- end
34
-
35
- def relative_path
36
- # TODO: Fix this, do not use Dir.getwd, use git root
37
- location.source_buffer.name.sub(File.join(Dir.getwd, "/"), "")
38
- end
39
-
40
- def clickable_path
41
- "{{italic:#{relative_path}:#{where}}}"
42
- end
43
-
44
- def clickable_plain_severity
45
- to_url("https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/#{code}", code)
46
- end
47
-
48
- def clickable_severity
49
- "{{#{severity.code}}} {{italic:#{clickable_plain_severity}}}"
50
- end
51
-
52
- def icon
53
- return check.green if corrected?
54
- return star.yellow if correctable?
55
-
56
- cross.red
57
- end
58
-
59
- def to_clickable(url, title)
60
- esc = CLI::UI::ANSI::ESC
61
- cmd = esc + "]8;;"
62
- slash = "\x07"
63
- cmd + "#{escape(url)}#{slash}#{escape(title)}" + cmd + slash
64
- end
65
-
66
- def to_path(path, title)
67
- to_clickable("file://#{path}", title)
68
- end
69
-
70
- def to_url(url, title)
71
- to_clickable(url, title)
72
- end
73
-
74
- def escape(str)
75
- Shellwords.escape(str)
76
- end
77
- end
78
- end