git_helper 3.3.2 → 3.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +29 -20
- data/README.md +4 -4
- data/lib/git_helper.rb +1 -1
- data/lib/git_helper/change_remote.rb +6 -5
- data/lib/git_helper/code_request.rb +10 -9
- data/lib/git_helper/merge_request.rb +7 -7
- data/lib/git_helper/new_branch.rb +1 -1
- data/lib/git_helper/pull_request.rb +6 -6
- data/lib/git_helper/setup.rb +19 -19
- data/lib/git_helper/version.rb +1 -1
- data/spec/git_helper/change_remote_spec.rb +7 -7
- data/spec/git_helper/code_request_spec.rb +28 -28
- data/spec/git_helper/merge_request_spec.rb +16 -16
- data/spec/git_helper/new_branch_spec.rb +8 -8
- data/spec/git_helper/pull_request_spec.rb +15 -15
- data/spec/git_helper/setup_spec.rb +22 -19
- data/spec/spec_helper.rb +1 -0
- metadata +38 -13
- data/lib/git_helper/highline_cli.rb +0 -35
- data/spec/git_helper/highline_cli_spec.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa8dfc9e8dff01f688d1f18ac2db60d0f0d9c193ad9ad1a5d91ab54fa7e2cb47
|
4
|
+
data.tar.gz: ed55743cbc0291c9058e8639c8b426d7201e5152d8f7f54c146df614a5cc154b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d412a23d9fb0daf6798fd0a364c536451361e3d195925e411b0ff2022ae0d2390f422f1fbcc2f83ce8830e38aa3371a76c10bea381cc565d9418c6b0a8ebdfda
|
7
|
+
data.tar.gz: b7eab53f9e11d32d058f9d9b52a05ef7e87e08288ddd115c2011f937c4ccd6a6e1a5e83c2eab9cc85b6488a1f5d727d2945822c254212ac02284d0c8b1748bd6
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
git_helper (3.3.
|
4
|
+
git_helper (3.3.7)
|
5
5
|
gitlab (~> 4.16)
|
6
6
|
gli (~> 2.13)
|
7
|
-
|
7
|
+
highline_wrapper (~> 1.1)
|
8
8
|
octokit (~> 4.18)
|
9
|
+
psych (< 4)
|
9
10
|
|
10
11
|
GEM
|
11
12
|
remote: https://rubygems.org/
|
@@ -16,19 +17,23 @@ GEM
|
|
16
17
|
coderay (1.1.3)
|
17
18
|
concurrent-ruby (1.1.8)
|
18
19
|
diff-lcs (1.4.4)
|
19
|
-
faker (2.
|
20
|
+
faker (2.17.0)
|
20
21
|
i18n (>= 1.6, < 2)
|
21
|
-
faraday (1.
|
22
|
+
faraday (1.4.1)
|
23
|
+
faraday-excon (~> 1.1)
|
22
24
|
faraday-net_http (~> 1.0)
|
25
|
+
faraday-net_http_persistent (~> 1.1)
|
23
26
|
multipart-post (>= 1.2, < 3)
|
24
|
-
ruby2_keywords
|
27
|
+
ruby2_keywords (>= 0.0.4)
|
28
|
+
faraday-excon (1.1.0)
|
25
29
|
faraday-net_http (1.0.1)
|
26
|
-
|
30
|
+
faraday-net_http_persistent (1.1.0)
|
31
|
+
ffi (1.15.0)
|
27
32
|
formatador (0.2.5)
|
28
33
|
gitlab (4.17.0)
|
29
34
|
httparty (~> 0.18)
|
30
35
|
terminal-table (~> 1.5, >= 1.5.1)
|
31
|
-
gli (2.
|
36
|
+
gli (2.20.0)
|
32
37
|
guard (2.16.2)
|
33
38
|
formatador (>= 0.2.4)
|
34
39
|
listen (>= 2.7, < 4.0)
|
@@ -44,34 +49,37 @@ GEM
|
|
44
49
|
guard-compat (~> 1.1)
|
45
50
|
rspec (>= 2.99.0, < 4.0)
|
46
51
|
highline (2.0.3)
|
52
|
+
highline_wrapper (1.1.0)
|
53
|
+
highline (~> 2.0)
|
47
54
|
httparty (0.18.1)
|
48
55
|
mime-types (~> 3.0)
|
49
56
|
multi_xml (>= 0.5.2)
|
50
|
-
i18n (1.8.
|
57
|
+
i18n (1.8.10)
|
51
58
|
concurrent-ruby (~> 1.0)
|
52
|
-
listen (3.
|
59
|
+
listen (3.5.1)
|
53
60
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
54
61
|
rb-inotify (~> 0.9, >= 0.9.10)
|
55
62
|
lumberjack (1.2.8)
|
56
63
|
method_source (1.0.0)
|
57
64
|
mime-types (3.3.1)
|
58
65
|
mime-types-data (~> 3.2015)
|
59
|
-
mime-types-data (3.
|
66
|
+
mime-types-data (3.2021.0225)
|
60
67
|
multi_xml (0.6.0)
|
61
68
|
multipart-post (2.1.1)
|
62
69
|
nenv (0.3.0)
|
63
70
|
notiffany (0.1.3)
|
64
71
|
nenv (~> 0.1)
|
65
72
|
shellany (~> 0.0)
|
66
|
-
octokit (4.
|
73
|
+
octokit (4.21.0)
|
67
74
|
faraday (>= 0.9)
|
68
75
|
sawyer (~> 0.8.0, >= 0.5.3)
|
69
76
|
parallel (1.20.1)
|
70
|
-
parser (3.0.
|
77
|
+
parser (3.0.1.1)
|
71
78
|
ast (~> 2.4.1)
|
72
|
-
pry (0.14.
|
79
|
+
pry (0.14.1)
|
73
80
|
coderay (~> 1.1)
|
74
81
|
method_source (~> 1.0)
|
82
|
+
psych (3.3.2)
|
75
83
|
public_suffix (4.0.6)
|
76
84
|
rainbow (3.0.0)
|
77
85
|
rake (13.0.3)
|
@@ -79,7 +87,7 @@ GEM
|
|
79
87
|
rb-inotify (0.10.1)
|
80
88
|
ffi (~> 1.0)
|
81
89
|
regexp_parser (2.1.1)
|
82
|
-
rexml (3.2.
|
90
|
+
rexml (3.2.5)
|
83
91
|
rspec (3.10.0)
|
84
92
|
rspec-core (~> 3.10.0)
|
85
93
|
rspec-expectations (~> 3.10.0)
|
@@ -93,17 +101,17 @@ GEM
|
|
93
101
|
diff-lcs (>= 1.2.0, < 2.0)
|
94
102
|
rspec-support (~> 3.10.0)
|
95
103
|
rspec-support (3.10.2)
|
96
|
-
rubocop (1.
|
104
|
+
rubocop (1.14.0)
|
97
105
|
parallel (~> 1.10)
|
98
106
|
parser (>= 3.0.0.0)
|
99
107
|
rainbow (>= 2.2.2, < 4.0)
|
100
108
|
regexp_parser (>= 1.8, < 3.0)
|
101
109
|
rexml
|
102
|
-
rubocop-ast (>= 1.
|
110
|
+
rubocop-ast (>= 1.5.0, < 2.0)
|
103
111
|
ruby-progressbar (~> 1.7)
|
104
112
|
unicode-display_width (>= 1.4.0, < 3.0)
|
105
|
-
rubocop-ast (1.
|
106
|
-
parser (>=
|
113
|
+
rubocop-ast (1.5.0)
|
114
|
+
parser (>= 3.0.1.1)
|
107
115
|
ruby-progressbar (1.11.0)
|
108
116
|
ruby2_keywords (0.0.4)
|
109
117
|
sawyer (0.8.2)
|
@@ -123,9 +131,10 @@ DEPENDENCIES
|
|
123
131
|
faker (~> 2.15)
|
124
132
|
git_helper!
|
125
133
|
guard-rspec (~> 4.3)
|
134
|
+
pry (~> 0.13)
|
126
135
|
rake (~> 13.0)
|
127
136
|
rspec (~> 3.9)
|
128
|
-
rubocop
|
137
|
+
rubocop (~> 1.10)
|
129
138
|
|
130
139
|
BUNDLED WITH
|
131
|
-
2.2.
|
140
|
+
2.2.17
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Git Helper [![Main](https://github.com/emmahsax/git_helper/actions/workflows/main.yml/badge.svg)](https://github.com/emmahsax/git_helper/actions/workflows/main.yml)
|
2
2
|
|
3
3
|
## Gem Usage
|
4
4
|
|
@@ -115,7 +115,7 @@ git-helper clean-branches
|
|
115
115
|
|
116
116
|
### `code-request`
|
117
117
|
|
118
|
-
This command can be used to handily make new GitHub/GitLab pull/merge requests from the command
|
118
|
+
This command can be used to handily make new GitHub/GitLab pull/merge requests from the command-line. The command uses either the [`Octokit::Client`](https://octokit.github.io/octokit.rb/Octokit/Client.html) or [`Gitlab` client](https://github.com/NARKOZ/gitlab) to do this, so make sure you have a `~/.git_helper/config.yml` file set up in the home directory of your computer. For instructions on how to do that, see [Gem Usage](#gem-usage).
|
119
119
|
|
120
120
|
After setup is complete, you can call the command like this:
|
121
121
|
|
@@ -149,7 +149,7 @@ git-helper forget-local-commits
|
|
149
149
|
|
150
150
|
### `merge-code-request`
|
151
151
|
|
152
|
-
This command can be used to merge pull/merge requests from the command
|
152
|
+
This command can be used to merge pull/merge requests from the command-line. The command uses either the [`Octokit::Client`](https://octokit.github.io/octokit.rb/Octokit/Client.html) or [`Gitlab` client](https://github.com/NARKOZ/gitlab) to do this, so make sure you have a `~/.git_helper/config.yml` file set up in the home directory of your computer. For instructions on how to do that, see [Gem Usage](#gem-usage).
|
153
153
|
|
154
154
|
After setup is complete, you can call the proper command like this:
|
155
155
|
|
@@ -166,7 +166,7 @@ For GitLab, the command will use whatever squash/source branch deletion/etc sett
|
|
166
166
|
|
167
167
|
### `new-branch`
|
168
168
|
|
169
|
-
This command is useful for making new branches in a repository on the command
|
169
|
+
This command is useful for making new branches in a repository on the command-line. To run the command, run:
|
170
170
|
|
171
171
|
```bash
|
172
172
|
git-helper new-branch
|
data/lib/git_helper.rb
CHANGED
@@ -24,8 +24,9 @@ module GitHelper
|
|
24
24
|
private def process_dir(current_dir, original_dir)
|
25
25
|
Dir.chdir(current_dir)
|
26
26
|
|
27
|
-
if File.exist?('.git') &&
|
28
|
-
"Found git directory: #{current_dir}. Do you wish to proceed in updating #{current_dir}'s remote URLs? (y/n)"
|
27
|
+
if File.exist?('.git') && highline.ask_yes_no(
|
28
|
+
"Found git directory: #{current_dir}. Do you wish to proceed in updating #{current_dir}'s remote URLs? (y/n)",
|
29
|
+
{ required: true }
|
29
30
|
)
|
30
31
|
process_git_repository
|
31
32
|
end
|
@@ -41,7 +42,7 @@ module GitHelper
|
|
41
42
|
puts " Found remote is not pointing to #{old_owner}."
|
42
43
|
end
|
43
44
|
end
|
44
|
-
puts
|
45
|
+
puts
|
45
46
|
end
|
46
47
|
|
47
48
|
# rubocop:disable Metrics/AbcSize
|
@@ -69,8 +70,8 @@ module GitHelper
|
|
69
70
|
@local_code ||= GitHelper::LocalCode.new
|
70
71
|
end
|
71
72
|
|
72
|
-
private def
|
73
|
-
@
|
73
|
+
private def highline
|
74
|
+
@highline ||= HighlineWrapper.new
|
74
75
|
end
|
75
76
|
end
|
76
77
|
end
|
@@ -29,9 +29,10 @@ module GitHelper
|
|
29
29
|
|
30
30
|
# rubocop:disable Metrics/MethodLength
|
31
31
|
private def ask_for_clarification
|
32
|
-
resp =
|
32
|
+
resp = highline.ask(
|
33
33
|
'Found git remotes for both GitHub and GitLab. Would you like to proceed ' \
|
34
|
-
'with GitLab or GitHub? (github/gitlab)'
|
34
|
+
'with GitLab or GitHub? (github/gitlab)',
|
35
|
+
{ required: true }
|
35
36
|
).downcase
|
36
37
|
|
37
38
|
if resp.include?('hub')
|
@@ -58,7 +59,7 @@ module GitHelper
|
|
58
59
|
local_project: local_project,
|
59
60
|
local_branch: local_branch,
|
60
61
|
local_code: local_code,
|
61
|
-
|
62
|
+
highline: highline
|
62
63
|
}
|
63
64
|
end
|
64
65
|
|
@@ -72,10 +73,10 @@ module GitHelper
|
|
72
73
|
|
73
74
|
private def base_branch
|
74
75
|
@base_branch ||=
|
75
|
-
if
|
76
|
+
if highline.ask_yes_no("Is '#{default_branch}' the correct base branch for your new code request? (y/n)")
|
76
77
|
default_branch
|
77
78
|
else
|
78
|
-
|
79
|
+
highline.ask('Base branch?', { required: true })
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
@@ -89,17 +90,17 @@ module GitHelper
|
|
89
90
|
|
90
91
|
private def new_code_request_title
|
91
92
|
@new_code_request_title ||=
|
92
|
-
if autogenerated_title &&
|
93
|
+
if autogenerated_title && highline.ask_yes_no(
|
93
94
|
"Accept the autogenerated code request title '#{autogenerated_title}'? (y/n)"
|
94
95
|
)
|
95
96
|
autogenerated_title
|
96
97
|
else
|
97
|
-
|
98
|
+
highline.ask('Title?', { required: true })
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
101
|
-
private def
|
102
|
-
@
|
102
|
+
private def highline
|
103
|
+
@highline ||= HighlineWrapper.new
|
103
104
|
end
|
104
105
|
|
105
106
|
private def local_code
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
module GitHelper
|
4
4
|
class GitLabMergeRequest
|
5
|
-
attr_accessor :local_project, :local_branch, :local_code, :
|
5
|
+
attr_accessor :local_project, :local_branch, :local_code, :highline, :base_branch, :new_mr_title
|
6
6
|
|
7
7
|
def initialize(options)
|
8
8
|
@local_project = options[:local_project]
|
9
9
|
@local_branch = options[:local_branch]
|
10
10
|
@local_code = options[:local_code]
|
11
|
-
@
|
11
|
+
@highline = options[:highline]
|
12
12
|
end
|
13
13
|
|
14
14
|
# rubocop:disable Metrics/MethodLength
|
@@ -97,12 +97,12 @@ module GitHelper
|
|
97
97
|
# rubocop:disable Metrics/MethodLength
|
98
98
|
private def determine_template
|
99
99
|
if mr_template_options.count == 1
|
100
|
-
apply_single_template =
|
100
|
+
apply_single_template = highline.ask_yes_no(
|
101
101
|
"Apply the merge request template from #{mr_template_options.first}? (y/n)"
|
102
102
|
)
|
103
103
|
@template_name_to_apply = mr_template_options.first if apply_single_template
|
104
104
|
else
|
105
|
-
response =
|
105
|
+
response = highline.ask_options(
|
106
106
|
'Which merge request template should be applied?', mr_template_options << 'None'
|
107
107
|
)
|
108
108
|
@template_name_to_apply = response unless response == 'None'
|
@@ -121,16 +121,16 @@ module GitHelper
|
|
121
121
|
end
|
122
122
|
|
123
123
|
private def mr_id
|
124
|
-
@mr_id ||=
|
124
|
+
@mr_id ||= highline.ask('Merge Request ID?')
|
125
125
|
end
|
126
126
|
|
127
127
|
private def squash_merge_request
|
128
|
-
@squash_merge_request ||=
|
128
|
+
@squash_merge_request ||= highline.ask_yes_no('Squash merge request? (y/n)')
|
129
129
|
end
|
130
130
|
|
131
131
|
private def remove_source_branch
|
132
132
|
@remove_source_branch ||=
|
133
|
-
existing_project.remove_source_branch_after_merge ||
|
133
|
+
existing_project.remove_source_branch_after_merge || highline.ask_yes_no(
|
134
134
|
'Remove source branch after merging? (y/n)'
|
135
135
|
)
|
136
136
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module GitHelper
|
4
4
|
class NewBranch
|
5
5
|
def execute(new_branch_name = nil)
|
6
|
-
branch_name = new_branch_name ||
|
6
|
+
branch_name = new_branch_name || HighlineWrapper.new.ask('New branch name?', { required: true })
|
7
7
|
puts "Attempting to create a new branch: #{branch_name}"
|
8
8
|
GitHelper::LocalCode.new.new_branch(branch_name)
|
9
9
|
end
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
module GitHelper
|
4
4
|
class GitHubPullRequest
|
5
|
-
attr_accessor :local_repo, :local_branch, :local_code, :
|
5
|
+
attr_accessor :local_repo, :local_branch, :local_code, :highline, :base_branch, :new_pr_title
|
6
6
|
|
7
7
|
def initialize(options)
|
8
8
|
@local_repo = options[:local_project]
|
9
9
|
@local_branch = options[:local_branch]
|
10
10
|
@local_code = options[:local_code]
|
11
|
-
@
|
11
|
+
@highline = options[:highline]
|
12
12
|
end
|
13
13
|
|
14
14
|
# rubocop:disable Metrics/MethodLength
|
@@ -102,12 +102,12 @@ module GitHelper
|
|
102
102
|
# rubocop:disable Metrics/MethodLength
|
103
103
|
private def determine_template
|
104
104
|
if pr_template_options.count == 1
|
105
|
-
apply_single_template =
|
105
|
+
apply_single_template = highline.ask_yes_no(
|
106
106
|
"Apply the pull request template from #{pr_template_options.first}? (y/n)"
|
107
107
|
)
|
108
108
|
@template_name_to_apply = pr_template_options.first if apply_single_template
|
109
109
|
else
|
110
|
-
response =
|
110
|
+
response = highline.ask_options(
|
111
111
|
'Which pull request template should be applied?', pr_template_options << 'None'
|
112
112
|
)
|
113
113
|
@template_name_to_apply = response unless response == 'None'
|
@@ -126,7 +126,7 @@ module GitHelper
|
|
126
126
|
end
|
127
127
|
|
128
128
|
private def pr_id
|
129
|
-
@pr_id ||=
|
129
|
+
@pr_id ||= highline.ask('Pull Request ID?')
|
130
130
|
end
|
131
131
|
|
132
132
|
private def merge_method
|
@@ -134,7 +134,7 @@ module GitHelper
|
|
134
134
|
if merge_options.length == 1
|
135
135
|
merge_options.first
|
136
136
|
else
|
137
|
-
|
137
|
+
highline.ask_options('Merge method?', merge_options)
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
data/lib/git_helper/setup.rb
CHANGED
@@ -7,23 +7,26 @@ module GitHelper
|
|
7
7
|
execute_plugins
|
8
8
|
end
|
9
9
|
|
10
|
+
# rubocop:disable Style/ConditionalAssignment
|
10
11
|
private def execute_config_file
|
11
12
|
if config_file_exists?
|
12
13
|
answer = highline.ask_yes_no(
|
13
|
-
"It looks like the #{config_file} file already exists. Do you wish to replace it? (y/n)"
|
14
|
+
"It looks like the #{config_file} file already exists. Do you wish to replace it? (y/n)",
|
15
|
+
{ required: true }
|
14
16
|
)
|
15
|
-
puts
|
16
17
|
else
|
17
18
|
answer = true
|
18
19
|
end
|
19
20
|
|
20
21
|
create_or_update_config_file if answer
|
21
22
|
end
|
23
|
+
# rubocop:enable Style/ConditionalAssignment
|
22
24
|
|
23
25
|
private def execute_plugins
|
24
26
|
answer = highline.ask_yes_no(
|
25
27
|
'Do you wish to set up the Git Helper plugins? (y/n) (This process will ' \
|
26
|
-
'attempt to use your GitHub personal access token to authenticate)'
|
28
|
+
'attempt to use your GitHub personal access token to authenticate)',
|
29
|
+
{ required: true }
|
27
30
|
)
|
28
31
|
|
29
32
|
return unless answer
|
@@ -36,7 +39,7 @@ module GitHelper
|
|
36
39
|
|
37
40
|
private def create_or_update_config_file
|
38
41
|
contents = generate_file_contents
|
39
|
-
puts "
|
42
|
+
puts "Creating or updating your #{config_file} file..."
|
40
43
|
File.open(config_file, 'w') { |file| file.puts contents }
|
41
44
|
puts "\nDone!\n\n"
|
42
45
|
end
|
@@ -49,19 +52,23 @@ module GitHelper
|
|
49
52
|
private def generate_file_contents
|
50
53
|
file_contents = ''.dup
|
51
54
|
|
52
|
-
if highline.ask_yes_no('Do you wish to set up GitHub credentials? (y/n)')
|
55
|
+
if highline.ask_yes_no('Do you wish to set up GitHub credentials? (y/n)', { required: true })
|
53
56
|
file_contents << ":github_user: #{ask_question('GitHub username?')}\n"
|
54
57
|
file_contents << ':github_token: ' \
|
55
|
-
"#{ask_question(
|
56
|
-
|
58
|
+
"#{ask_question(
|
59
|
+
'GitHub personal access token? (Navigate to https://github.com/settings/tokens ' \
|
60
|
+
'to create a new personal access token)',
|
61
|
+
secret: true
|
62
|
+
)}\n"
|
57
63
|
end
|
58
64
|
|
59
|
-
if highline.ask_yes_no(
|
65
|
+
if highline.ask_yes_no('Do you wish to set up GitLab credentials? (y/n)', { required: true })
|
60
66
|
file_contents << ":gitlab_user: #{ask_question('GitLab username?')}\n"
|
61
67
|
file_contents << ':gitlab_token: ' \
|
62
68
|
"#{ask_question(
|
63
69
|
'GitLab personal access token? (Navigate to https://gitlab.com/-/profile/personal_access_tokens' \
|
64
|
-
' to create a new personal access token)'
|
70
|
+
' to create a new personal access token)',
|
71
|
+
secret: true
|
65
72
|
)}\n"
|
66
73
|
end
|
67
74
|
|
@@ -69,15 +76,8 @@ module GitHelper
|
|
69
76
|
end
|
70
77
|
# rubocop:enable Metrics/MethodLength
|
71
78
|
|
72
|
-
private def ask_question(prompt)
|
73
|
-
|
74
|
-
|
75
|
-
if answer.empty?
|
76
|
-
puts "\nThis question is required."
|
77
|
-
ask_question(prompt)
|
78
|
-
else
|
79
|
-
answer
|
80
|
-
end
|
79
|
+
private def ask_question(prompt, secret: false)
|
80
|
+
highline.ask(prompt, { required: true, secret: secret })
|
81
81
|
end
|
82
82
|
|
83
83
|
# rubocop:disable Metrics/MethodLength
|
@@ -110,7 +110,7 @@ module GitHelper
|
|
110
110
|
end
|
111
111
|
|
112
112
|
private def highline
|
113
|
-
@highline ||=
|
113
|
+
@highline ||= HighlineWrapper.new
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|