rubocop_challenger 1.0.0.pre2 → 1.0.0.pre3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +1 -1
- data/Gemfile.lock +1 -1
- data/bin/create_release_pr +1 -4
- data/lib/rubocop_challenger/cli.rb +15 -10
- data/lib/rubocop_challenger/command_line.rb +16 -3
- data/lib/rubocop_challenger/git/command.rb +3 -1
- data/lib/rubocop_challenger/github/pr_creater.rb +12 -5
- data/lib/rubocop_challenger/rubocop/command.rb +3 -1
- data/lib/rubocop_challenger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b73e8abe85be6a6a8673f84a8d35b4cc664e012c471bfeea3beb8b45d74366d
|
4
|
+
data.tar.gz: ab2c10f577db034299059b197558a675a19e3d69bb497b6cc17be250134dce65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b60e84618d97800b225baf93de7a65d7ff9f94e8ef1f2084686891e46f571df2e29dfe02b08233f377da8c039b7286e07b601d7763136a20e781ee5d184daef2
|
7
|
+
data.tar.gz: 70c231673f5c34dbc1fcf37b6a9fe3c9740b48e05801bf2bdac4ccfc8c706208412376de0db5aac9dbced8dc450f5fd37ede28c4b0deedd739b3ce0bc6c4a509
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2018-11-
|
3
|
+
# on 2018-11-17 00:50:17 +0900 using RuboCop version 0.60.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
data/Gemfile.lock
CHANGED
data/bin/create_release_pr
CHANGED
@@ -15,10 +15,7 @@ VERSION_FORMAT = /\A\d+\.\d+\.\d+(\.(pre|beta|rc)\d?)?\z/.freeze
|
|
15
15
|
version = ARGV[0]
|
16
16
|
rubocop = RubocopChallenger::Rubocop::Command.new
|
17
17
|
pr_creater =
|
18
|
-
RubocopChallenger::Github::PrCreater.new(
|
19
|
-
access_token: ENV['GITHUB_ACCESS_TOKEN'],
|
20
|
-
branch: "update/v#{version}"
|
21
|
-
)
|
18
|
+
RubocopChallenger::Github::PrCreater.new(branch: "update/v#{version}")
|
22
19
|
|
23
20
|
# Verifying
|
24
21
|
exit_process 'usage: bin/create_release_pr VERSION' if version.nil?
|
@@ -5,15 +5,17 @@ require 'thor'
|
|
5
5
|
module RubocopChallenger
|
6
6
|
# To define CLI commands
|
7
7
|
class CLI < Thor
|
8
|
-
|
8
|
+
include CommandLine
|
9
|
+
|
10
|
+
desc 'go', 'Run `$ rubocop --auto-correct` and create a PR to GitHub repo'
|
9
11
|
option :email,
|
10
12
|
required: true,
|
11
13
|
type: :string,
|
12
|
-
desc: 'Pull Request committer email'
|
14
|
+
desc: 'The Pull Request committer email'
|
13
15
|
option :name,
|
14
16
|
required: true,
|
15
17
|
type: :string,
|
16
|
-
desc: 'Pull Request committer name'
|
18
|
+
desc: 'The Pull Request committer name'
|
17
19
|
option :file_path,
|
18
20
|
type: :string,
|
19
21
|
default: '.rubocop_todo.yml',
|
@@ -22,15 +24,14 @@ module RubocopChallenger
|
|
22
24
|
option :template,
|
23
25
|
type: :string,
|
24
26
|
aliases: :t,
|
25
|
-
desc: 'Pull Request template `erb` file path.' \
|
27
|
+
desc: 'A Pull Request template `erb` file path.' \
|
26
28
|
'You can use variable that `title`, `rubydoc_url`, ' \
|
27
29
|
'`description` and `examples` into the erb file.'
|
28
30
|
option :mode,
|
29
31
|
type: :string,
|
30
32
|
default: 'most_occurrence',
|
31
|
-
desc: 'Mode to select deletion target. ' \
|
32
|
-
'
|
33
|
-
'or "random"'
|
33
|
+
desc: 'Mode to select deletion target. You can choice ' \
|
34
|
+
'"most_occurrence", "least_occurrence", or "random"'
|
34
35
|
option :base,
|
35
36
|
type: :string,
|
36
37
|
default: 'master',
|
@@ -53,8 +54,8 @@ module RubocopChallenger
|
|
53
54
|
regenerate_rubocop_todo
|
54
55
|
create_pull_request(target_rule)
|
55
56
|
rescue StandardError => e
|
56
|
-
|
57
|
-
|
57
|
+
color_puts e.message, CommandLine::RED
|
58
|
+
exit_process!
|
58
59
|
end
|
59
60
|
|
60
61
|
desc 'version', 'Show current version'
|
@@ -74,7 +75,6 @@ module RubocopChallenger
|
|
74
75
|
|
75
76
|
def pr_creater
|
76
77
|
@pr_creater ||= Github::PrCreater.new(
|
77
|
-
access_token: ENV['GITHUB_ACCESS_TOKEN'],
|
78
78
|
branch: "rubocop-challenge/#{timestamp}",
|
79
79
|
user_name: options[:name],
|
80
80
|
user_email: options[:email]
|
@@ -120,5 +120,10 @@ module RubocopChallenger
|
|
120
120
|
def timestamp
|
121
121
|
@timestamp ||= Time.now.strftime('%Y%m%d%H%M%S')
|
122
122
|
end
|
123
|
+
|
124
|
+
# Exit process (Mainly for mock when testing)
|
125
|
+
def exit_process!
|
126
|
+
exit!
|
127
|
+
end
|
123
128
|
end
|
124
129
|
end
|
@@ -2,16 +2,29 @@
|
|
2
2
|
|
3
3
|
module RubocopChallenger
|
4
4
|
# To execute command line. You should inherit this class to use.
|
5
|
-
|
5
|
+
module CommandLine
|
6
6
|
private
|
7
7
|
|
8
8
|
# Execute a command
|
9
9
|
#
|
10
10
|
# @param command [String] The command you want to execute
|
11
|
-
# @return [String]
|
11
|
+
# @return [String] The result in the execution
|
12
12
|
def execute(command)
|
13
13
|
puts "$ #{command}"
|
14
|
-
`#{command}`.chomp
|
14
|
+
`#{command}`.chomp.tap do |result|
|
15
|
+
color_code = $CHILD_STATUS.success? ? GREEN : RED
|
16
|
+
color_puts(result, color_code)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RED = 31
|
21
|
+
GREEN = 32
|
22
|
+
YELLOW = 33
|
23
|
+
BLUE = 34
|
24
|
+
PING = 35
|
25
|
+
|
26
|
+
def color_puts(string, color_code)
|
27
|
+
puts "\e[#{color_code}m#{string}\e[0m"
|
15
28
|
end
|
16
29
|
end
|
17
30
|
end
|
@@ -6,13 +6,14 @@ module RubocopChallenger
|
|
6
6
|
class PrCreater
|
7
7
|
# Returns a new instance of Github::PrCreater
|
8
8
|
#
|
9
|
-
# @
|
9
|
+
# @note You have to set ENV['GITHUB_ACCESS_TOKEN']
|
10
10
|
# @param branch [String] The branch where your changes are going to
|
11
11
|
# implement.
|
12
12
|
# @param user_name [String] The username to use for committer and author
|
13
13
|
# @param user_email [String] The email to use for committer and author
|
14
|
-
def initialize(
|
15
|
-
|
14
|
+
def initialize(branch:, user_name: nil, user_email: nil)
|
15
|
+
raise "You have to set ENV['GITHUB_ACCESS_TOKEN']" if access_token.nil?
|
16
|
+
|
16
17
|
@topic_branch = branch
|
17
18
|
@git = Git::Command.new(user_name: user_name, user_email: user_email)
|
18
19
|
@github = Github::Client.new(access_token, git.remote_url('origin'))
|
@@ -55,7 +56,7 @@ module RubocopChallenger
|
|
55
56
|
|
56
57
|
private
|
57
58
|
|
58
|
-
attr_reader :
|
59
|
+
attr_reader :git, :github, :topic_branch, :initial_sha1
|
59
60
|
|
60
61
|
def git_condition_valid?
|
61
62
|
!git.current_sha1?(initial_sha1) && git.current_branch?(topic_branch)
|
@@ -67,8 +68,14 @@ module RubocopChallenger
|
|
67
68
|
yield
|
68
69
|
end
|
69
70
|
|
71
|
+
def access_token
|
72
|
+
ENV['GITHUB_ACCESS_TOKEN']
|
73
|
+
end
|
74
|
+
|
75
|
+
# @note You *MUST NOT* use `#access_token` in the URL because this string
|
76
|
+
# will be output STDOUT via `RubocopChallenger::CommandLine` module.
|
70
77
|
def github_token_url
|
71
|
-
"https
|
78
|
+
"https://${GITHUB_ACCESS_TOKEN}@github.com/#{github.repository}"
|
72
79
|
end
|
73
80
|
end
|
74
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop_challenger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.pre3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryosuke_sato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|