git_helper 3.0.1 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +33 -23
- data/Guardfile +2 -2
- data/README.md +26 -13
- data/Rakefile +1 -1
- data/bin/git-helper +12 -16
- data/lib/git_helper.rb +6 -1
- data/lib/git_helper/change_remote.rb +1 -1
- data/lib/git_helper/code_request.rb +6 -5
- data/lib/git_helper/git_config_reader.rb +0 -2
- data/lib/git_helper/gitlab_client.rb +0 -2
- data/lib/git_helper/highline_cli.rb +12 -70
- data/lib/git_helper/local_code.rb +9 -9
- data/lib/git_helper/merge_request.rb +5 -5
- data/lib/git_helper/new_branch.rb +1 -1
- data/lib/git_helper/octokit_client.rb +0 -2
- data/lib/git_helper/pull_request.rb +4 -4
- data/lib/git_helper/version.rb +1 -1
- data/plugins.zip +0 -0
- data/spec/git_helper/change_remote_spec.rb +19 -16
- data/spec/git_helper/code_request_spec.rb +37 -34
- data/spec/git_helper/git_config_reader_spec.rb +9 -7
- data/spec/git_helper/highline_cli_spec.rb +18 -182
- data/spec/git_helper/local_code_spec.rb +62 -26
- data/spec/git_helper/merge_request_spec.rb +58 -41
- data/spec/git_helper/new_branch_spec.rb +3 -2
- data/spec/git_helper/pull_request_spec.rb +46 -38
- data/spec/spec_helper.rb +2 -0
- metadata +27 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3f63c9e4283a7e005a3f6ca7f29e7721e474ec06ebebecd1dcda8f63f841450
|
4
|
+
data.tar.gz: 2ec89ecd8513c12f9434aa9c03f7568522b84d3c282e62e09670aa15a63fef95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bce1b9c25dc1ad30c8434a0e252bdc95f8864fcd29e2c02e712dffb4fe63aaa063fa6a72d9cc27a91c06784758fd6499f9aaa21f62ea57d7b7b81522558112a4
|
7
|
+
data.tar.gz: 572c484112dbdcfbb2da9ad8c25add8fd56baa3c652931715a46d9355780e3535e226afc3a83d2f57a6815f78df6fba7c8f47e97990801608bb9653ef3c961c2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
git_helper (3.
|
4
|
+
git_helper (3.2.0)
|
5
5
|
gitlab (~> 4.16)
|
6
6
|
gli (~> 2.13)
|
7
7
|
highline (~> 2.0)
|
@@ -13,13 +13,19 @@ GEM
|
|
13
13
|
addressable (2.7.0)
|
14
14
|
public_suffix (>= 2.0.2, < 5.0)
|
15
15
|
coderay (1.1.3)
|
16
|
+
concurrent-ruby (1.1.7)
|
16
17
|
diff-lcs (1.4.4)
|
17
|
-
|
18
|
+
faker (2.15.1)
|
19
|
+
i18n (>= 1.6, < 2)
|
20
|
+
faraday (1.3.0)
|
21
|
+
faraday-net_http (~> 1.0)
|
18
22
|
multipart-post (>= 1.2, < 3)
|
19
|
-
|
23
|
+
ruby2_keywords
|
24
|
+
faraday-net_http (1.0.0)
|
25
|
+
ffi (1.14.2)
|
20
26
|
formatador (0.2.5)
|
21
|
-
gitlab (4.
|
22
|
-
httparty (~> 0.
|
27
|
+
gitlab (4.17.0)
|
28
|
+
httparty (~> 0.18)
|
23
29
|
terminal-table (~> 1.5, >= 1.5.1)
|
24
30
|
gli (2.19.2)
|
25
31
|
guard (2.16.2)
|
@@ -40,44 +46,47 @@ GEM
|
|
40
46
|
httparty (0.18.1)
|
41
47
|
mime-types (~> 3.0)
|
42
48
|
multi_xml (>= 0.5.2)
|
43
|
-
|
49
|
+
i18n (1.8.7)
|
50
|
+
concurrent-ruby (~> 1.0)
|
51
|
+
listen (3.4.1)
|
44
52
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
45
53
|
rb-inotify (~> 0.9, >= 0.9.10)
|
46
54
|
lumberjack (1.2.8)
|
47
55
|
method_source (1.0.0)
|
48
56
|
mime-types (3.3.1)
|
49
57
|
mime-types-data (~> 3.2015)
|
50
|
-
mime-types-data (3.2020.
|
58
|
+
mime-types-data (3.2020.1104)
|
51
59
|
multi_xml (0.6.0)
|
52
60
|
multipart-post (2.1.1)
|
53
61
|
nenv (0.3.0)
|
54
62
|
notiffany (0.1.3)
|
55
63
|
nenv (~> 0.1)
|
56
64
|
shellany (~> 0.0)
|
57
|
-
octokit (4.
|
65
|
+
octokit (4.20.0)
|
58
66
|
faraday (>= 0.9)
|
59
67
|
sawyer (~> 0.8.0, >= 0.5.3)
|
60
68
|
pry (0.13.1)
|
61
69
|
coderay (~> 1.1)
|
62
70
|
method_source (~> 1.0)
|
63
71
|
public_suffix (4.0.6)
|
64
|
-
rake (13.0.
|
72
|
+
rake (13.0.3)
|
65
73
|
rb-fsevent (0.10.4)
|
66
74
|
rb-inotify (0.10.1)
|
67
75
|
ffi (~> 1.0)
|
68
|
-
rspec (3.
|
69
|
-
rspec-core (~> 3.
|
70
|
-
rspec-expectations (~> 3.
|
71
|
-
rspec-mocks (~> 3.
|
72
|
-
rspec-core (3.
|
73
|
-
rspec-support (~> 3.
|
74
|
-
rspec-expectations (3.
|
76
|
+
rspec (3.10.0)
|
77
|
+
rspec-core (~> 3.10.0)
|
78
|
+
rspec-expectations (~> 3.10.0)
|
79
|
+
rspec-mocks (~> 3.10.0)
|
80
|
+
rspec-core (3.10.1)
|
81
|
+
rspec-support (~> 3.10.0)
|
82
|
+
rspec-expectations (3.10.1)
|
75
83
|
diff-lcs (>= 1.2.0, < 2.0)
|
76
|
-
rspec-support (~> 3.
|
77
|
-
rspec-mocks (3.
|
84
|
+
rspec-support (~> 3.10.0)
|
85
|
+
rspec-mocks (3.10.1)
|
78
86
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
-
rspec-support (~> 3.
|
80
|
-
rspec-support (3.
|
87
|
+
rspec-support (~> 3.10.0)
|
88
|
+
rspec-support (3.10.1)
|
89
|
+
ruby2_keywords (0.0.2)
|
81
90
|
sawyer (0.8.2)
|
82
91
|
addressable (>= 2.3.5)
|
83
92
|
faraday (> 0.8, < 2.0)
|
@@ -88,14 +97,15 @@ GEM
|
|
88
97
|
unicode-display_width (1.7.0)
|
89
98
|
|
90
99
|
PLATFORMS
|
91
|
-
|
100
|
+
x86_64-darwin-19
|
92
101
|
|
93
102
|
DEPENDENCIES
|
94
|
-
bundler (~> 2.
|
103
|
+
bundler (~> 2.2)
|
104
|
+
faker (~> 2.15)
|
95
105
|
git_helper!
|
96
106
|
guard-rspec (~> 4.3)
|
97
107
|
rake (~> 13.0)
|
98
108
|
rspec (~> 3.9)
|
99
109
|
|
100
110
|
BUNDLED WITH
|
101
|
-
2.
|
111
|
+
2.2.4
|
data/Guardfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
guard :rspec, cmd: 'bundle exec rspec', all_on_start: true
|
1
|
+
guard :rspec, cmd: 'bundle exec rspec', all_on_start: true do
|
2
2
|
watch(%r{^spec/.+_spec\.rb$})
|
3
3
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
4
|
-
watch('spec/spec_helper.rb') {
|
4
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
5
5
|
end
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# git_helper [](https://codeclimate.com/github/emmasax4/git_helper/maintainability) ](https://codeclimate.com/github/emmasax4/git_helper/maintainability) 
|
2
2
|
|
3
3
|
## Gem Usage
|
4
4
|
|
@@ -34,7 +34,7 @@ As an additional option, you can set each of the following commands to be a git
|
|
34
34
|
```bash
|
35
35
|
# As a Gem # As a Plugin
|
36
36
|
git-helper clean-branches git clean-branches
|
37
|
-
git-helper code-request
|
37
|
+
git-helper code-request git code-request
|
38
38
|
```
|
39
39
|
|
40
40
|
To do this, download the `plugins.zip` file in the root of this directory. Unzip and place the contents in the appropriate location:
|
@@ -110,25 +110,21 @@ git-helper clean-branches
|
|
110
110
|
|
111
111
|
### `code-request`
|
112
112
|
|
113
|
-
This command can be used to handily make new GitHub/GitLab pull/merge requests
|
113
|
+
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).
|
114
114
|
|
115
|
-
After setup is complete, you can call the
|
115
|
+
After setup is complete, you can call the command like this:
|
116
116
|
|
117
117
|
```bash
|
118
|
-
git-helper code-request
|
119
|
-
# OR
|
120
|
-
git-helper code-request -m
|
118
|
+
git-helper code-request
|
121
119
|
```
|
122
120
|
|
123
|
-
|
121
|
+
The command will provide an autogenerated code request title based on your branch name. It will separate the branch name by `'_'` if underscores are in the branch, or `'-'` if dashes are present. Then it will join the list of words together by spaces. If there's a pattern in the form of `jira-123` or `jira_123` in the first part of the branch name, then it'll add `JIRA-123` to the first part of the code request. You can respond 'yes' or 'no'. If you respond 'no', you can provide your own code request title.
|
124
122
|
|
125
123
|
The command will also ask you if the default branch of the repository is the proper base branch to use. You can say 'yes' or 'no'. If you respond 'no', then you can give the command your chosen base base.
|
126
124
|
|
127
|
-
|
128
|
-
|
129
|
-
If you're requesting to merge a code request, the command will ask you the number ID of the code request you wish to merge. For GitHub, the command will also ask you what type of merge to do: regular merging, squashing, or rebasing. The commit message to use during the merge/squash/rebase will be the title of the pull request. For GitLab, the command will also ask you what type of merge to do: regular merging or squashing. The commit message to use during the merge/squash will be the title of the merge request.
|
125
|
+
If your project uses GitLab, the command will potentially ask you if you'd like to delete the source branch upon merge. If the project defaults to deleting the source branch, then the script will use that selection, and the value can be changed for a specific MR either over the API or in the browser. If the project just provides source branch deletion as on option, then it'll ask the user. It also will probably ask you if you'd like to squash the MR upon merge. If the project requires or prevents squashing, then whatever answer you give will be _*ignored*_. This is unfortunate, but is here due to limited API functionality.
|
130
126
|
|
131
|
-
|
127
|
+
Lastly, it'll ask about code request templates. For GitHub, it'll ask the user to apply any pull request templates found at `.github/pull_request_template.md`, `./pull_request_template.md`, or `.github/PULL_REQUEST_TEMPLATE/*.md`. Applying any template is optional, and a user can make an empty pull request if they desire. For GitLab, it'll ask the user to apply any merge request templates found at any `.gitlab/merge_request_template.md`, `./merge_request_template.md`, or `.gitlab/merge_request_templates/*.md`. Applying any template is optional, and from the command's standpoint, a user can make an empty merge request if they desire (although GitLab may still add a merge request template if the project itself requires one). When searching for templates, the code ignores cases, so the file could be named with all capital letters or all lowercase letters.
|
132
128
|
|
133
129
|
### `empty-commit`
|
134
130
|
|
@@ -146,6 +142,23 @@ This command is handy if you locally have a bunch of commits you wish to complet
|
|
146
142
|
git-helper forget-local-commits
|
147
143
|
```
|
148
144
|
|
145
|
+
### `merge-code-request`
|
146
|
+
|
147
|
+
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).
|
148
|
+
|
149
|
+
After setup is complete, you can call the proper command like this:
|
150
|
+
|
151
|
+
```bash
|
152
|
+
git-helper merge-code-request
|
153
|
+
```
|
154
|
+
|
155
|
+
The command will ask you the number ID of the code request you wish to merge.
|
156
|
+
|
157
|
+
If using GitHub _and_ the repository allows multiple types of merges (merge/squash/rebase), then the command will ask the user what type of merge to do. It'll only let users select a type of merge the repository allows. If a repository only allows one type of merging, then the command will automatically use that. The commit message to use during the merge/squash/rebase will be the title of the pull request.
|
158
|
+
|
159
|
+
For GitLab, the command will use whatever squash/source branch deletion/etc settings are already set on the merge request, so make sure you click the proper checkboxes in the MR manually or over the API before running this command. The commit message to use during the merge/squash will be the title of the merge request.
|
160
|
+
|
161
|
+
|
149
162
|
### `new-branch`
|
150
163
|
|
151
164
|
This command is useful for making new branches in a repository on the command line. To run the command, run:
|
@@ -164,7 +177,7 @@ To submit a feature request, bug ticket, etc, please submit an official [GitHub
|
|
164
177
|
|
165
178
|
To report any security vulnerabilities, please view this project's [Security Policy](https://github.com/emmasax4/git_helper/security/policy).
|
166
179
|
|
167
|
-
|
180
|
+
When interacting with this repository, please follow [Contributor Covenant's Code of Conduct](https://contributor-covenant.org).
|
168
181
|
|
169
182
|
## Releasing
|
170
183
|
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/git-helper
CHANGED
@@ -27,7 +27,7 @@ command 'change-remote' do |c|
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
desc
|
30
|
+
desc 'Checks out the default branch of a repo based on the local remote branches.'
|
31
31
|
command 'checkout-default' do |c|
|
32
32
|
c.action do |global_options, options, args|
|
33
33
|
GitHelper::CheckoutDefault.new.execute
|
@@ -41,14 +41,14 @@ command 'clean-branches' do |c|
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
desc
|
44
|
+
desc 'Creates an empty commit with a basic commit message.'
|
45
45
|
command 'empty-commit' do |c|
|
46
46
|
c.action do |global_options, options, args|
|
47
47
|
GitHelper::EmptyCommit.new.execute
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
desc
|
51
|
+
desc 'Reset your local git commits to origin/HEAD.'
|
52
52
|
command 'forget-local-commits' do |c|
|
53
53
|
c.action do |global_options, options, args|
|
54
54
|
GitHelper::ForgetLocalCommits.new.execute
|
@@ -63,21 +63,17 @@ command 'new-branch' do |c|
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
desc '
|
67
|
-
command 'code-request' do |c|
|
68
|
-
c.switch [:c, :create], desc: 'Create a new pull/merge request'
|
69
|
-
c.switch [:m, :merge], desc: 'Merge an existing pull/merge request'
|
70
|
-
|
66
|
+
desc 'Merge a GitHub/GitLab pull/merge request. The command will figure out whether your code project belongs to GitHub or GitLab.'
|
67
|
+
command 'merge-code-request' do |c|
|
71
68
|
c.action do |global_options, options, args|
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
GitHelper::CodeRequest.new.merge
|
70
|
+
end
|
71
|
+
end
|
75
72
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
73
|
+
desc 'Create a GitHub/GitLab pull/merge request from the current branch. The command will figure out whether your code project belongs to GitHub or GitLab.'
|
74
|
+
command 'code-request' do |c|
|
75
|
+
c.action do |global_options, options, args|
|
76
|
+
GitHelper::CodeRequest.new.create
|
81
77
|
end
|
82
78
|
end
|
83
79
|
|
data/lib/git_helper.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
require 'yaml'
|
2
|
+
require 'gitlab'
|
3
|
+
require 'highline'
|
4
|
+
require 'octokit'
|
5
|
+
|
6
|
+
Dir[File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), 'git_helper')) + '/**/*.rb'].each do |file|
|
2
7
|
require_relative file
|
3
8
|
end
|
4
9
|
|
@@ -23,7 +23,7 @@ module GitHelper
|
|
23
23
|
Dir.chdir(current_dir)
|
24
24
|
|
25
25
|
if File.exist?('.git')
|
26
|
-
process_git_repository if cli.
|
26
|
+
process_git_repository if cli.ask_yes_no("Found git directory: #{current_dir}. Do you wish to proceed in updating #{current_dir}'s remote URLs? (y/n)")
|
27
27
|
end
|
28
28
|
|
29
29
|
Dir.chdir(original_dir)
|
@@ -24,7 +24,7 @@ module GitHelper
|
|
24
24
|
end
|
25
25
|
|
26
26
|
private def ask_for_clarification
|
27
|
-
resp = cli.
|
27
|
+
resp = cli.ask('Found git remotes for both GitHub and GitLab. Would you like to proceed with GitLab or GitHub? (github/gitlab)').downcase
|
28
28
|
if resp.include?('hub')
|
29
29
|
github_pull_request
|
30
30
|
elsif resp.include?('lab')
|
@@ -61,10 +61,10 @@ module GitHelper
|
|
61
61
|
end
|
62
62
|
|
63
63
|
private def base_branch
|
64
|
-
@base_branch ||= if cli.
|
64
|
+
@base_branch ||= if cli.ask_yes_no("Is '#{default_branch}' the correct base branch for your new code request? (y/n)")
|
65
65
|
default_branch
|
66
66
|
else
|
67
|
-
cli.
|
67
|
+
cli.ask('Base branch?')
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -77,10 +77,11 @@ module GitHelper
|
|
77
77
|
end
|
78
78
|
|
79
79
|
private def new_code_request_title
|
80
|
-
@new_code_request_title ||= if
|
80
|
+
@new_code_request_title ||= if autogenerated_title &&
|
81
|
+
cli.ask_yes_no("Accept the autogenerated code request title '#{autogenerated_title}'? (y/n)")
|
81
82
|
autogenerated_title
|
82
83
|
else
|
83
|
-
cli.
|
84
|
+
cli.ask('Title?')
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
@@ -1,87 +1,29 @@
|
|
1
|
-
require 'highline'
|
2
|
-
|
3
1
|
module GitHelper
|
4
2
|
class HighlineCli
|
5
|
-
def
|
6
|
-
ask(
|
7
|
-
|
8
|
-
|
9
|
-
def process_directory_remotes?(directory)
|
10
|
-
answer = ask("Found git directory: #{directory}. Do you wish to proceed in updating #{directory}'s remote URLs? (y/n)")
|
11
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
12
|
-
end
|
13
|
-
|
14
|
-
def conflicting_remote_clarification
|
15
|
-
ask('Found git remotes for both GitHub and GitLab. Would you like to proceed with GitLab or GitHub? (github/gitlab)').downcase
|
16
|
-
end
|
17
|
-
|
18
|
-
def title
|
19
|
-
ask('Title?')
|
20
|
-
end
|
21
|
-
|
22
|
-
def base_branch
|
23
|
-
ask('Base branch?')
|
24
|
-
end
|
25
|
-
|
26
|
-
def code_request_id(request_type)
|
27
|
-
ask("#{request_type} Request ID?")
|
28
|
-
end
|
29
|
-
|
30
|
-
def accept_autogenerated_title?(autogenerated_title)
|
31
|
-
return false unless autogenerated_title
|
32
|
-
answer = ask("Accept the autogenerated code request title '#{autogenerated_title}'? (y/n)")
|
33
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
34
|
-
end
|
35
|
-
|
36
|
-
def base_branch_default?(default_branch)
|
37
|
-
answer = ask("Is '#{default_branch}' the correct base branch for your new code request? (y/n)")
|
38
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
39
|
-
end
|
40
|
-
|
41
|
-
def squash_merge_request?
|
42
|
-
answer = ask('Squash merge request? (y/n)')
|
43
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
44
|
-
end
|
45
|
-
|
46
|
-
def remove_source_branch?
|
47
|
-
answer = ask('Remove source branch after merging? (y/n)')
|
48
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
49
|
-
end
|
50
|
-
|
51
|
-
def merge_method(merge_options)
|
52
|
-
index = ask_options("Merge method?", merge_options)
|
53
|
-
merge_options[index]
|
54
|
-
end
|
55
|
-
|
56
|
-
def apply_template?(template_file_name, request_type)
|
57
|
-
answer = ask("Apply the #{request_type} request template from #{template_file_name}? (y/n)")
|
58
|
-
answer.empty? ? true : !!(answer =~ /^y/i)
|
59
|
-
end
|
60
|
-
|
61
|
-
def template_to_apply(template_options, request_type)
|
62
|
-
complete_options = template_options << 'None'
|
63
|
-
index = ask_options("Which #{request_type} request template should be applied?", complete_options)
|
64
|
-
complete_options[index]
|
3
|
+
def ask(prompt)
|
4
|
+
highline_client.ask(prompt) do |conf|
|
5
|
+
conf.readline = true
|
6
|
+
end.to_s
|
65
7
|
end
|
66
8
|
|
67
|
-
|
68
|
-
|
69
|
-
#######################
|
70
|
-
|
71
|
-
private def ask(prompt)
|
72
|
-
highline_client.ask(prompt) do |conf|
|
9
|
+
def ask_yes_no(prompt)
|
10
|
+
answer = highline_client.ask(prompt) do |conf|
|
73
11
|
conf.readline = true
|
74
12
|
end.to_s
|
13
|
+
|
14
|
+
answer.empty? ? true : !!(answer =~ /^y/i)
|
75
15
|
end
|
76
16
|
|
77
|
-
|
17
|
+
def ask_options(prompt, choices)
|
78
18
|
choices_as_string_options = ''
|
79
19
|
choices.each { |choice| choices_as_string_options << "#{choices.index(choice) + 1}. #{choice}\n" }
|
80
20
|
compiled_prompt = "#{prompt}\n#{choices_as_string_options.strip}"
|
81
21
|
|
82
|
-
highline_client.ask(compiled_prompt) do |conf|
|
22
|
+
index = highline_client.ask(compiled_prompt) do |conf|
|
83
23
|
conf.readline = true
|
84
24
|
end.to_i - 1
|
25
|
+
|
26
|
+
choices[index]
|
85
27
|
end
|
86
28
|
|
87
29
|
private def highline_client
|
@@ -1,27 +1,27 @@
|
|
1
1
|
module GitHelper
|
2
2
|
class LocalCode
|
3
3
|
def checkout_default
|
4
|
-
system(
|
4
|
+
system('git checkout $(git symbolic-ref refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@")')
|
5
5
|
end
|
6
6
|
|
7
7
|
def forget_local_commits
|
8
|
-
system(
|
9
|
-
system(
|
8
|
+
system('git pull')
|
9
|
+
system('git reset --hard origin/HEAD')
|
10
10
|
end
|
11
11
|
|
12
12
|
def empty_commit
|
13
|
-
system(
|
13
|
+
system('git commit --allow-empty -m "Empty commit"')
|
14
14
|
end
|
15
15
|
|
16
16
|
def clean_branches
|
17
|
-
system(
|
18
|
-
system(
|
19
|
-
system(
|
20
|
-
system(
|
17
|
+
system('git checkout $(git symbolic-ref refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@")')
|
18
|
+
system('git pull')
|
19
|
+
system('git fetch -p')
|
20
|
+
system('git branch -vv | grep "origin/.*: gone]" | awk "{print \$1}" | grep -v "*" | xargs git branch -D')
|
21
21
|
end
|
22
22
|
|
23
23
|
def new_branch(branch_name)
|
24
|
-
system(
|
24
|
+
system('git pull')
|
25
25
|
system("git branch --no-track #{branch_name}")
|
26
26
|
system("git checkout #{branch_name}")
|
27
27
|
system("git push --set-upstream origin #{branch_name}")
|