git_helper 3.3.0 → 3.6.6

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +58 -64
  4. data/Guardfile +5 -3
  5. data/LICENSE.md +29 -0
  6. data/README.md +42 -34
  7. data/Rakefile +2 -0
  8. data/bin/git-helper +18 -13
  9. data/lib/git_helper/change_remote.rb +15 -6
  10. data/lib/git_helper/checkout_default.rb +2 -0
  11. data/lib/git_helper/clean_branches.rb +2 -0
  12. data/lib/git_helper/code_request.rb +33 -19
  13. data/lib/git_helper/empty_commit.rb +2 -0
  14. data/lib/git_helper/forget_local_commits.rb +2 -0
  15. data/lib/git_helper/git_config_reader.rb +11 -5
  16. data/lib/git_helper/github_client.rb +70 -0
  17. data/lib/git_helper/gitlab_client.rb +48 -2
  18. data/lib/git_helper/local_code.rb +24 -14
  19. data/lib/git_helper/merge_request.rb +98 -70
  20. data/lib/git_helper/new_branch.rb +3 -1
  21. data/lib/git_helper/pull_request.rb +91 -73
  22. data/lib/git_helper/setup.rb +62 -39
  23. data/lib/git_helper/version.rb +3 -1
  24. data/lib/git_helper.rb +7 -4
  25. data/renovate.json +6 -0
  26. metadata +34 -80
  27. data/LICENSE +0 -22
  28. data/lib/git_helper/highline_cli.rb +0 -33
  29. data/lib/git_helper/octokit_client.rb +0 -11
  30. data/plugins.zip +0 -0
  31. data/spec/git_helper/change_remote_spec.rb +0 -176
  32. data/spec/git_helper/checkout_default_spec.rb +0 -19
  33. data/spec/git_helper/clean_branches_spec.rb +0 -19
  34. data/spec/git_helper/code_request_spec.rb +0 -263
  35. data/spec/git_helper/empty_commit_spec.rb +0 -19
  36. data/spec/git_helper/forget_local_commits_spec.rb +0 -19
  37. data/spec/git_helper/git_config_reader_spec.rb +0 -62
  38. data/spec/git_helper/gitlab_client_spec.rb +0 -26
  39. data/spec/git_helper/highline_cli_spec.rb +0 -51
  40. data/spec/git_helper/local_code_spec.rb +0 -268
  41. data/spec/git_helper/merge_request_spec.rb +0 -251
  42. data/spec/git_helper/new_branch_spec.rb +0 -45
  43. data/spec/git_helper/octokit_client_spec.rb +0 -26
  44. data/spec/git_helper/pull_request_spec.rb +0 -254
  45. data/spec/git_helper/setup_spec.rb +0 -170
  46. data/spec/spec_helper.rb +0 -47
@@ -1,75 +1,76 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GitHelper
2
4
  class GitHubPullRequest
3
- attr_accessor :local_repo, :local_branch, :local_code, :cli, :base_branch, :new_pr_title
5
+ attr_accessor :local_repo, :local_branch, :local_code, :highline, :base_branch, :new_pr_title
4
6
 
5
7
  def initialize(options)
6
8
  @local_repo = options[:local_project]
7
9
  @local_branch = options[:local_branch]
8
10
  @local_code = options[:local_code]
9
- @cli = options[:cli]
11
+ @highline = options[:highline]
10
12
  end
11
13
 
14
+ # rubocop:disable Metrics/MethodLength
15
+ # rubocop:disable Metrics/AbcSize
12
16
  def create(options)
13
17
  @base_branch = options[:base_branch]
14
18
  @new_pr_title = options[:new_title]
15
19
 
16
- begin
17
- new_pr_body
18
-
19
- puts "Creating pull request: #{new_pr_title}"
20
- pr = octokit_client.create_pull_request(local_repo, base_branch, local_branch, new_pr_title, new_pr_body)
21
- puts "Pull request successfully created: #{pr.html_url}"
22
- rescue Octokit::UnprocessableEntity => e
23
- puts 'Could not create pull request:'
24
- if e.message.include?('pull request already exists')
25
- puts ' A pull request already exists for this branch'
26
- elsif e.message.include?('No commits between')
27
- puts ' No commits have been pushed to GitHub'
28
- else
29
- puts e.message
30
- end
31
- rescue Exception => e
32
- puts 'Could not create pull request:'
33
- puts e.message
20
+ options = {
21
+ head: local_branch,
22
+ base: base_branch,
23
+ body: new_pr_body,
24
+ title: new_pr_title
25
+ }
26
+
27
+ puts "Creating pull request: #{new_pr_title}"
28
+ pr = github_client.create_pull_request(local_repo, options)
29
+
30
+ raise StandardError, pr.errors.first['message'] if pr.html_url.nil?
31
+
32
+ puts "Pull request successfully created: #{pr.html_url}"
33
+ rescue StandardError => e
34
+ puts 'Could not create pull request:'
35
+
36
+ if e.message.include?('A pull request already exists')
37
+ puts ' A pull request already exists for this branch'
38
+ elsif e.message.include?('No commits between')
39
+ puts ' No commits have been pushed to GitHub'
40
+ else
41
+ puts " #{e.message}"
34
42
  end
35
43
  end
44
+ # rubocop:enable Metrics/AbcSize
45
+ # rubocop:enable Metrics/MethodLength
36
46
 
47
+ # rubocop:disable Metrics/MethodLength
48
+ # rubocop:disable Metrics/AbcSize
37
49
  def merge
38
- begin
39
- pr_id
40
- merge_method
41
-
42
- puts "Merging pull request: #{pr_id}"
43
- merge = octokit_client.merge_pull_request(local_repo, pr_id, existing_pr.title, { merge_method: merge_method })
44
- puts "Pull request successfully merged: #{merge.sha}"
45
- rescue Octokit::UnprocessableEntity => e
46
- puts 'Could not merge pull request:'
47
- puts e.message
48
- rescue Octokit::NotFound => e
49
- puts 'Could not merge pull request:'
50
- puts " Could not a locate a pull request to merge with ID #{pr_id}"
51
- rescue Octokit::MethodNotAllowed => e
52
- puts 'Could not merge pull request:'
53
- if e.message.include?('405 - Required status check')
54
- puts ' A required status check has not passed'
55
- elsif e.message.include?('405 - Base branch was modified')
56
- puts ' The base branch has been modified'
57
- elsif e.message.include?('405 - Pull Request is not mergeable')
58
- puts ' The pull request is not mergeable'
59
- elsif e.message.include?('405 - Rebase merges are not allowed on this repository')
60
- puts ' Rebase merges are not allowed on this repository'
61
- elsif e.message.include?('405 - Merge commits are not allowed on this repository')
62
- puts ' Merge commits are not allowed on this repository'
63
- elsif e.message.include?('405 - Squash commits are not allowed on this repository')
64
- puts ' Squash merges are not allowed on this repository'
65
- else
66
- puts e.message
67
- end
68
- rescue Exception => e
69
- puts 'Could not merge pull request:'
70
- puts e.message
50
+ pr_id
51
+
52
+ options = {
53
+ merge_method: merge_method,
54
+ commit_title: existing_pr.title
55
+ }
56
+
57
+ puts "Merging pull request: #{pr_id}"
58
+ merge = github_client.merge_pull_request(local_repo, pr_id, options)
59
+
60
+ raise StandardError, merge.message if merge.sha.nil?
61
+
62
+ puts "Pull request successfully merged: #{merge.sha}"
63
+ rescue StandardError => e
64
+ puts 'Could not merge pull request:'
65
+
66
+ if e.message.include?('Not found')
67
+ puts ' Could not a locate a pull request to merge with given ID'
68
+ else
69
+ puts " #{e.message}"
71
70
  end
72
71
  end
72
+ # rubocop:enable Metrics/AbcSize
73
+ # rubocop:enable Metrics/MethodLength
73
74
 
74
75
  private def new_pr_body
75
76
  @new_pr_body ||= template_name_to_apply ? local_code.read_template(template_name_to_apply) : ''
@@ -77,39 +78,56 @@ module GitHelper
77
78
 
78
79
  private def template_name_to_apply
79
80
  return @template_name_to_apply if @template_name_to_apply
81
+
80
82
  @template_name_to_apply = nil
81
83
 
82
- unless pr_template_options.empty?
83
- if pr_template_options.count == 1
84
- apply_single_template = cli.ask_yes_no("Apply the pull request template from #{pr_template_options.first}? (y/n)")
85
- @template_name_to_apply = pr_template_options.first if apply_single_template
86
- else
87
- response = cli.ask_options("Which pull request template should be applied?", pr_template_options << 'None')
88
- @template_name_to_apply = response unless response == 'None'
89
- end
90
- end
84
+ determine_template unless pr_template_options.empty?
91
85
 
92
86
  @template_name_to_apply
93
87
  end
94
88
 
89
+ # rubocop:disable Metrics/MethodLength
90
+ private def determine_template
91
+ if pr_template_options.count == 1
92
+ apply_single_template = highline.ask_yes_no(
93
+ "Apply the pull request template from #{pr_template_options.first}? (Y/n)"
94
+ )
95
+ @template_name_to_apply = pr_template_options.first if apply_single_template
96
+ else
97
+ response = highline.ask_options(
98
+ 'Which pull request template should be applied?', pr_template_options << 'None'
99
+ )
100
+ @template_name_to_apply = response unless response == 'None'
101
+ end
102
+ end
103
+ # rubocop:enable Metrics/MethodLength
104
+
95
105
  private def pr_template_options
96
- @pr_template_options ||= local_code.template_options({
97
- template_directory: '.github',
98
- nested_directory_name: 'PULL_REQUEST_TEMPLATE',
99
- non_nested_file_name: 'pull_request_template'
100
- })
106
+ @pr_template_options ||= local_code.template_options(
107
+ {
108
+ template_directory: '.github',
109
+ nested_directory_name: 'PULL_REQUEST_TEMPLATE',
110
+ non_nested_file_name: 'pull_request_template'
111
+ }
112
+ )
101
113
  end
102
114
 
103
115
  private def pr_id
104
- @pr_id ||= cli.ask('Pull Request ID?')
116
+ @pr_id ||= highline.ask('Pull Request ID?', { required: true })
105
117
  end
106
118
 
107
119
  private def merge_method
108
- @merge_method ||= merge_options.length == 1 ? merge_options.first : cli.ask_options('Merge method?', merge_options)
120
+ @merge_method ||=
121
+ if merge_options.length == 1
122
+ merge_options.first
123
+ else
124
+ highline.ask_options('Merge method?', merge_options)
125
+ end
109
126
  end
110
127
 
111
128
  private def merge_options
112
129
  return @merge_options if @merge_options
130
+
113
131
  merge_options = []
114
132
  merge_options << 'merge' if existing_project.allow_merge_commit
115
133
  merge_options << 'squash' if existing_project.allow_squash_merge
@@ -118,15 +136,15 @@ module GitHelper
118
136
  end
119
137
 
120
138
  private def existing_project
121
- @existing_project ||= octokit_client.repository(local_repo)
139
+ @existing_project ||= github_client.repository(local_repo)
122
140
  end
123
141
 
124
142
  private def existing_pr
125
- @existing_pr ||= octokit_client.pull_request(local_repo, pr_id)
143
+ @existing_pr ||= github_client.pull_request(local_repo, pr_id)
126
144
  end
127
145
 
128
- private def octokit_client
129
- @octokit_client ||= GitHelper::OctokitClient.new.client
146
+ private def github_client
147
+ @github_client ||= GitHelper::GitHubClient.new
130
148
  end
131
149
  end
132
150
  end
@@ -1,87 +1,110 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GitHelper
2
4
  class Setup
3
5
  def execute
6
+ execute_config_file
7
+ execute_plugins
8
+ end
9
+
10
+ # rubocop:disable Style/ConditionalAssignment
11
+ private def execute_config_file
4
12
  if config_file_exists?
5
- answer = highline.ask_yes_no("It looks like the #{config_file} file already exists. Do you wish to replace it? (y/n)")
6
- puts
13
+ answer = highline.ask_yes_no(
14
+ "It looks like the #{config_file} file already exists. Do you wish to replace it? (y/n)",
15
+ { required: true }
16
+ )
7
17
  else
8
18
  answer = true
9
19
  end
10
20
 
11
21
  create_or_update_config_file if answer
22
+ end
23
+ # rubocop:enable Style/ConditionalAssignment
12
24
 
13
- answer = highline.ask_yes_no("Do you wish to set up the Git Helper plugins? (y/n)")
25
+ private def execute_plugins
26
+ answer = highline.ask_yes_no(
27
+ 'Do you wish to set up the Git Helper plugins? (y/n)',
28
+ { required: true }
29
+ )
14
30
 
15
- if answer
16
- create_or_update_plugin_files
17
- puts "\nNow add this line to your ~/.bash_profile:\n export PATH=/path/to/computer/home/.git_helper/plugins:$PATH"
18
- puts "\nDone!"
19
- end
31
+ return unless answer
32
+
33
+ create_or_update_plugin_files
34
+ puts "\nNow add this line to your ~/.zshrc:\n " \
35
+ 'export PATH="$HOME/.git_helper/plugins:$PATH"'
36
+ puts "\nDone!"
20
37
  end
21
38
 
22
39
  private def create_or_update_config_file
23
40
  contents = generate_file_contents
24
- puts "\nCreating or updating your #{config_file} file..."
41
+ puts "Creating or updating your #{config_file} file..."
42
+ FileUtils.mkdir_p("#{Dir.home}/.git_helper")
25
43
  File.open(config_file, 'w') { |file| file.puts contents }
26
44
  puts "\nDone!\n\n"
27
45
  end
28
46
 
29
47
  private def config_file_exists?
30
- File.exists?(config_file)
48
+ File.exist?(config_file)
31
49
  end
32
50
 
51
+ # rubocop:disable Metrics/MethodLength
33
52
  private def generate_file_contents
34
- file_contents = ''
53
+ file_contents = ''.dup
35
54
 
36
- 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 })
37
56
  file_contents << ":github_user: #{ask_question('GitHub username?')}\n"
38
- file_contents << ":github_token: " \
39
- "#{ask_question('GitHub personal access token? (Navigate to https://github.com/settings/tokens ' \
40
- 'to create a new personal access token)')}\n"
57
+ file_contents << ':github_token: ' \
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"
41
63
  end
42
64
 
43
- if highline.ask_yes_no("\nDo you wish to set up GitLab credentials? (y/n)")
65
+ if highline.ask_yes_no('Do you wish to set up GitLab credentials? (y/n)', { required: true })
44
66
  file_contents << ":gitlab_user: #{ask_question('GitLab username?')}\n"
45
- file_contents << ":gitlab_token: " \
46
- "#{ask_question('GitLab personal access token? (Navigate to https://gitlab.com/-/profile/personal_access_tokens ' \
47
- 'to create a new personal access token)')}\n"
67
+ file_contents << ':gitlab_token: ' \
68
+ "#{ask_question(
69
+ 'GitLab personal access token? (Navigate to https://gitlab.com/-/profile/personal_access_tokens ' \
70
+ 'to create a new personal access token)',
71
+ secret: true
72
+ )}\n"
48
73
  end
49
74
 
50
75
  file_contents.strip
51
76
  end
77
+ # rubocop:enable Metrics/MethodLength
52
78
 
53
- private def ask_question(prompt)
54
- answer = highline.ask("\n#{prompt}")
55
-
56
- if answer.empty?
57
- puts "\nThis question is required."
58
- ask_question(prompt)
59
- else
60
- answer
61
- end
62
- end
63
-
64
- private def highline
65
- @highline ||= GitHelper::HighlineCli.new
66
- end
67
-
68
- private def config_file
69
- GitHelper::GitConfigReader.new.git_config_file_path
79
+ private def ask_question(prompt, secret: false)
80
+ highline.ask(prompt, { required: true, secret: secret })
70
81
  end
71
82
 
72
83
  private def create_or_update_plugin_files
73
- plugins_dir = "#{Dir.pwd.scan(/\A\/[\w]*\/[\w]*\//).first}/.git_helper/plugins"
84
+ plugins_dir = "#{Dir.home}/.git_helper/plugins"
74
85
  plugins_url = 'https://api.github.com/repos/emmahsax/git_helper/contents/plugins'
75
86
  header = 'Accept: application/vnd.github.v3.raw'
76
87
 
77
- Dir.mkdir(plugins_dir) unless File.exists?(plugins_dir)
88
+ FileUtils.mkdir_p(plugins_dir)
78
89
 
79
90
  all_plugins = JSON.parse(`curl -s -H "#{header}" -L "#{plugins_url}"`)
80
91
 
81
92
  all_plugins.each do |plugin|
82
93
  plugin_content = `curl -s -H "#{header}" -L "#{plugins_url}/#{plugin['name']}"`
83
- File.open("#{plugins_dir}/#{plugin['name']}", 'w') { |file| file.puts plugin_content }
94
+ File.open("#{plugins_dir}/#{plugin['name']}", 'w', 0o755) { |file| file.puts plugin_content }
84
95
  end
85
96
  end
97
+
98
+ private def config_file
99
+ git_config_reader.git_config_file_path
100
+ end
101
+
102
+ private def git_config_reader
103
+ @git_config_reader ||= GitHelper::GitConfigReader.new
104
+ end
105
+
106
+ private def highline
107
+ @highline ||= HighlineWrapper.new
108
+ end
86
109
  end
87
110
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GitHelper
2
- VERSION = '3.3.0'
4
+ VERSION = '3.6.6'
3
5
  end
data/lib/git_helper.rb CHANGED
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
- require 'gitlab'
3
- require 'highline'
4
- require 'octokit'
4
+ require 'json'
5
+ require 'highline_wrapper'
6
+
7
+ files = "#{File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), 'git_helper'))}/**/*.rb"
5
8
 
6
- Dir[File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), 'git_helper')) + '/**/*.rb'].each do |file|
9
+ Dir[files].sort.each do |file|
7
10
  require_relative file
8
11
  end
9
12
 
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:base"
5
+ ]
6
+ }
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emma Sax
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-25 00:00:00.000000000 Z
11
+ date: 2023-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: gitlab
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '4.16'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '4.16'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: gli
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -39,33 +25,19 @@ dependencies:
39
25
  - !ruby/object:Gem::Version
40
26
  version: '2.13'
41
27
  - !ruby/object:Gem::Dependency
42
- name: highline
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: octokit
28
+ name: highline_wrapper
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - "~>"
60
32
  - !ruby/object:Gem::Version
61
- version: '4.18'
33
+ version: '1.1'
62
34
  type: :runtime
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
38
  - - "~>"
67
39
  - !ruby/object:Gem::Version
68
- version: '4.18'
40
+ version: '1.1'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: bundler
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +58,14 @@ dependencies:
86
58
  requirements:
87
59
  - - "~>"
88
60
  - !ruby/object:Gem::Version
89
- version: '2.15'
61
+ version: '3.0'
90
62
  type: :development
91
63
  prerelease: false
92
64
  version_requirements: !ruby/object:Gem::Requirement
93
65
  requirements:
94
66
  - - "~>"
95
67
  - !ruby/object:Gem::Version
96
- version: '2.15'
68
+ version: '3.0'
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: guard-rspec
99
71
  requirement: !ruby/object:Gem::Requirement
@@ -109,19 +81,19 @@ dependencies:
109
81
  - !ruby/object:Gem::Version
110
82
  version: '4.3'
111
83
  - !ruby/object:Gem::Dependency
112
- name: rake
84
+ name: pry
113
85
  requirement: !ruby/object:Gem::Requirement
114
86
  requirements:
115
87
  - - "~>"
116
88
  - !ruby/object:Gem::Version
117
- version: '13.0'
89
+ version: '0.13'
118
90
  type: :development
119
91
  prerelease: false
120
92
  version_requirements: !ruby/object:Gem::Requirement
121
93
  requirements:
122
94
  - - "~>"
123
95
  - !ruby/object:Gem::Version
124
- version: '13.0'
96
+ version: '0.13'
125
97
  - !ruby/object:Gem::Dependency
126
98
  name: rspec
127
99
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +108,20 @@ dependencies:
136
108
  - - "~>"
137
109
  - !ruby/object:Gem::Version
138
110
  version: '3.9'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.10'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.10'
139
125
  description: A set of GitHub and GitLab workflow scripts to provide a smoother development
140
126
  process for your git projects.
141
127
  email:
@@ -147,7 +133,7 @@ files:
147
133
  - Gemfile
148
134
  - Gemfile.lock
149
135
  - Guardfile
150
- - LICENSE
136
+ - LICENSE.md
151
137
  - README.md
152
138
  - Rakefile
153
139
  - bin/git-helper
@@ -159,36 +145,20 @@ files:
159
145
  - lib/git_helper/empty_commit.rb
160
146
  - lib/git_helper/forget_local_commits.rb
161
147
  - lib/git_helper/git_config_reader.rb
148
+ - lib/git_helper/github_client.rb
162
149
  - lib/git_helper/gitlab_client.rb
163
- - lib/git_helper/highline_cli.rb
164
150
  - lib/git_helper/local_code.rb
165
151
  - lib/git_helper/merge_request.rb
166
152
  - lib/git_helper/new_branch.rb
167
- - lib/git_helper/octokit_client.rb
168
153
  - lib/git_helper/pull_request.rb
169
154
  - lib/git_helper/setup.rb
170
155
  - lib/git_helper/version.rb
171
- - plugins.zip
172
- - spec/git_helper/change_remote_spec.rb
173
- - spec/git_helper/checkout_default_spec.rb
174
- - spec/git_helper/clean_branches_spec.rb
175
- - spec/git_helper/code_request_spec.rb
176
- - spec/git_helper/empty_commit_spec.rb
177
- - spec/git_helper/forget_local_commits_spec.rb
178
- - spec/git_helper/git_config_reader_spec.rb
179
- - spec/git_helper/gitlab_client_spec.rb
180
- - spec/git_helper/highline_cli_spec.rb
181
- - spec/git_helper/local_code_spec.rb
182
- - spec/git_helper/merge_request_spec.rb
183
- - spec/git_helper/new_branch_spec.rb
184
- - spec/git_helper/octokit_client_spec.rb
185
- - spec/git_helper/pull_request_spec.rb
186
- - spec/git_helper/setup_spec.rb
187
- - spec/spec_helper.rb
156
+ - renovate.json
188
157
  homepage: https://github.com/emmahsax/git_helper
189
158
  licenses:
190
- - MIT
191
- metadata: {}
159
+ - BSD-3-Clause
160
+ metadata:
161
+ rubygems_mfa_required: 'true'
192
162
  post_install_message:
193
163
  rdoc_options: []
194
164
  require_paths:
@@ -197,31 +167,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
197
167
  requirements:
198
168
  - - ">="
199
169
  - !ruby/object:Gem::Version
200
- version: '0'
170
+ version: '2.5'
201
171
  required_rubygems_version: !ruby/object:Gem::Requirement
202
172
  requirements:
203
173
  - - ">="
204
174
  - !ruby/object:Gem::Version
205
175
  version: '0'
206
176
  requirements: []
207
- rubygems_version: 3.2.3
177
+ rubygems_version: 3.4.12
208
178
  signing_key:
209
179
  specification_version: 4
210
- summary: A set of GitHub and GitLab workflow scripts.
211
- test_files:
212
- - spec/spec_helper.rb
213
- - spec/git_helper/change_remote_spec.rb
214
- - spec/git_helper/checkout_default_spec.rb
215
- - spec/git_helper/clean_branches_spec.rb
216
- - spec/git_helper/code_request_spec.rb
217
- - spec/git_helper/empty_commit_spec.rb
218
- - spec/git_helper/forget_local_commits_spec.rb
219
- - spec/git_helper/git_config_reader_spec.rb
220
- - spec/git_helper/gitlab_client_spec.rb
221
- - spec/git_helper/highline_cli_spec.rb
222
- - spec/git_helper/local_code_spec.rb
223
- - spec/git_helper/merge_request_spec.rb
224
- - spec/git_helper/new_branch_spec.rb
225
- - spec/git_helper/octokit_client_spec.rb
226
- - spec/git_helper/pull_request_spec.rb
227
- - spec/git_helper/setup_spec.rb
180
+ summary: A set of GitHub and GitLab workflow scripts
181
+ test_files: []
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright 2020 Emma Sax
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,33 +0,0 @@
1
- module GitHelper
2
- class HighlineCli
3
- def ask(prompt)
4
- highline_client.ask(prompt) do |conf|
5
- conf.readline = true
6
- end.to_s
7
- end
8
-
9
- def ask_yes_no(prompt)
10
- answer = highline_client.ask(prompt) do |conf|
11
- conf.readline = true
12
- end.to_s
13
-
14
- answer.empty? ? true : !!(answer =~ /^y/i)
15
- end
16
-
17
- def ask_options(prompt, choices)
18
- choices_as_string_options = ''
19
- choices.each { |choice| choices_as_string_options << "#{choices.index(choice) + 1}. #{choice}\n" }
20
- compiled_prompt = "#{prompt}\n#{choices_as_string_options.strip}"
21
-
22
- index = highline_client.ask(compiled_prompt) do |conf|
23
- conf.readline = true
24
- end.to_i - 1
25
-
26
- choices[index]
27
- end
28
-
29
- private def highline_client
30
- @highline_client ||= HighLine.new
31
- end
32
- end
33
- end