rubocop-changed 0.0.3 → 0.0.5

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: d106bb14da97436a39b5fa35944b7f08133d26cf7647b28e234e04d8feb7ff09
4
- data.tar.gz: d39cd06b0ca38812f01b9e9820423897f519c4f35eef4d4bd861d019a728447c
3
+ metadata.gz: 90c7debb3a9b1fbbfaf2dd660305573bf4506106fa9dc6c0b694b9d059c92cf4
4
+ data.tar.gz: b4d8a89ffe6df757fdea3672875c63e81d088aa607861f27e5147a533ad86019
5
5
  SHA512:
6
- metadata.gz: 63feb9a8367541b5ed1dd919b71216c62c069773d5ed09e53417c6cf8d844f1a70952cbc0b3a91ff66853428a2a629f3f7f0be4b183b7d77e6cf0f03f0d951bd
7
- data.tar.gz: 3bfbd434841f081d79bd134be897d57d2e2dea98a31015002e164562d6155b97ee4ce1b1075a1f20613245fa63836f6d7fde78722dd2a2a025a1d2affece5096
6
+ metadata.gz: 41fea45d587554352c80f91a9ed3196977df75405d0cff2b52efa44cbe1a97ae8be8bc4ee8e7b4a69850a44e6dfcc801f011c2992b739512be3d711d6abec0af
7
+ data.tar.gz: f18b591a52d6d5bfabc4e1cc7986762525935ef8e1cea303d55dd30da66677cd1a4012b73a6c1e5bc825e2ba16da5d08129c8eee476b084e66866f26599c04e3
@@ -6,23 +6,30 @@ module RuboCop
6
6
  class CommandError < StandardError
7
7
  ISSUE_URL = 'https://github.com/dukaev/rubocop-changed/issues'
8
8
  MESSAGES = {
9
- 'git: not found' => 'Git is not installed. Make shure that container has git installed',
10
- 'fatal: not a git repository' => 'Not found .git directory. Make shure that branch is copied',
11
- 'fatal: ambiguous argument' => 'Not found setted branch. Make shure that branch is downladed.'
9
+ 'git: not found' =>
10
+ 'The git binary is not available in the PATH. You may need to install git or update the PATH variable to ' \
11
+ 'include the installation directory.',
12
+ 'fatal: not a git repository' =>
13
+ 'The .git directory was not found. Rubocop-changed only works with projects in a git repository.',
14
+ 'fatal: ambiguous argument' =>
15
+ 'The set branch was not found. Ensure that the branch has a local tracking branch or specify the full ' \
16
+ 'reference in the RUBOCOP_CHANGED_BRANCH_NAME environment variable.'
12
17
  }.freeze
13
18
 
14
19
  def initialize(output, cmd)
15
20
  key = MESSAGES.keys.find { |error| output.include?(error) }
16
- msg = MESSAGES[key] || default_message(cmd, output)
17
-
18
- super(msg)
21
+ message = MESSAGES[key] || "Unknown error. Please, create issue on #{ISSUE_URL}."
22
+ super(exception_message(cmd, output, message))
19
23
  end
20
24
 
21
- def default_message(cmd, output)
25
+ def exception_message(cmd, output, message)
22
26
  <<~HEREDOC
23
- Unknown error. Please, create issue on #{ISSUE_URL}.
24
- Command: #{cmd}
25
- Message: #{output}
27
+ #{message}
28
+ Command:
29
+ #{cmd}
30
+ Output:
31
+ #{output}
32
+
26
33
  HEREDOC
27
34
  end
28
35
  end
@@ -11,7 +11,7 @@ module RuboCop
11
11
  GIT_COMMANDS = {
12
12
  changed_files: 'git diff-tree -r --no-commit-id --name-status %<compared_branch>s %<current_branch>s',
13
13
  current_branch: 'git rev-parse --abbrev-ref HEAD',
14
- default_branch: 'git symbolic-ref refs/remotes/origin/HEAD',
14
+ default_branch: "git remote show origin | sed -n '/HEAD branch/s/.*: //p' | xargs",
15
15
  new_files: 'git status --porcelain=v1'
16
16
  }.freeze
17
17
 
@@ -61,8 +61,10 @@ module RuboCop
61
61
  end
62
62
 
63
63
  def run(cmd)
64
+ warn("COMMAND: #{cmd}") if verbose_logging?
64
65
  output = shell(cmd)
65
- raise Rubocop::Changed::ExecutionError.new(output, cmd) if output.match?(Regexp.union(ERRORS))
66
+ warn("OUTPUT: #{output}\n") if verbose_logging?
67
+ raise CommandError.new(output, cmd) if output.match?(Regexp.union(ERRORS))
66
68
 
67
69
  output
68
70
  end
@@ -70,6 +72,10 @@ module RuboCop
70
72
  def shell(cmd)
71
73
  `#{cmd} 2>&1`
72
74
  end
75
+
76
+ def verbose_logging?
77
+ ENV.fetch('RUBOCOP_CHANGED_VERBOSE_LOGGING', false) != false
78
+ end
73
79
  end
74
80
  end
75
81
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Changed
5
- VERSION = '0.0.3'
5
+ VERSION = '0.0.5'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-changed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslan Dukaev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-25 00:00:00.000000000 Z
11
+ date: 2024-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rspec
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 3.12.0
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 3.12.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rubocop
29
15
  requirement: !ruby/object:Gem::Requirement