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.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +58 -64
- data/Guardfile +5 -3
- data/LICENSE.md +29 -0
- data/README.md +42 -34
- data/Rakefile +2 -0
- data/bin/git-helper +18 -13
- data/lib/git_helper/change_remote.rb +15 -6
- data/lib/git_helper/checkout_default.rb +2 -0
- data/lib/git_helper/clean_branches.rb +2 -0
- data/lib/git_helper/code_request.rb +33 -19
- data/lib/git_helper/empty_commit.rb +2 -0
- data/lib/git_helper/forget_local_commits.rb +2 -0
- data/lib/git_helper/git_config_reader.rb +11 -5
- data/lib/git_helper/github_client.rb +70 -0
- data/lib/git_helper/gitlab_client.rb +48 -2
- data/lib/git_helper/local_code.rb +24 -14
- data/lib/git_helper/merge_request.rb +98 -70
- data/lib/git_helper/new_branch.rb +3 -1
- data/lib/git_helper/pull_request.rb +91 -73
- data/lib/git_helper/setup.rb +62 -39
- data/lib/git_helper/version.rb +3 -1
- data/lib/git_helper.rb +7 -4
- data/renovate.json +6 -0
- metadata +34 -80
- data/LICENSE +0 -22
- data/lib/git_helper/highline_cli.rb +0 -33
- data/lib/git_helper/octokit_client.rb +0 -11
- data/plugins.zip +0 -0
- data/spec/git_helper/change_remote_spec.rb +0 -176
- data/spec/git_helper/checkout_default_spec.rb +0 -19
- data/spec/git_helper/clean_branches_spec.rb +0 -19
- data/spec/git_helper/code_request_spec.rb +0 -263
- data/spec/git_helper/empty_commit_spec.rb +0 -19
- data/spec/git_helper/forget_local_commits_spec.rb +0 -19
- data/spec/git_helper/git_config_reader_spec.rb +0 -62
- data/spec/git_helper/gitlab_client_spec.rb +0 -26
- data/spec/git_helper/highline_cli_spec.rb +0 -51
- data/spec/git_helper/local_code_spec.rb +0 -268
- data/spec/git_helper/merge_request_spec.rb +0 -251
- data/spec/git_helper/new_branch_spec.rb +0 -45
- data/spec/git_helper/octokit_client_spec.rb +0 -26
- data/spec/git_helper/pull_request_spec.rb +0 -254
- data/spec/git_helper/setup_spec.rb +0 -170
- data/spec/spec_helper.rb +0 -47
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 787737eda759eb8586dfc74869c4d3aa37d983c886d39ea5bdc6cbd84aec1c3c
|
|
4
|
+
data.tar.gz: 1620a4c05ab9e1d22faddbf35f3399873ee2fa331a9e432e15c60c055f8a5d0d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fed4f42c02f1868d01f814b2a688063a0c0d5ea133db7a89ae480fb0f4534f6101e788e54fef1ea2284726b846cfb52ab18d2d6fa58dd5dd5b993a646b415099
|
|
7
|
+
data.tar.gz: f578749f192739180569eba8725dab7f853eef9e150f903e87716ab94443333a493272c286b24fdd87ee82b4946a9184b79397548c9b0fca0af027080775f739
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,40 +1,29 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
git_helper (3.
|
|
5
|
-
gitlab (~> 4.16)
|
|
4
|
+
git_helper (3.6.5)
|
|
6
5
|
gli (~> 2.13)
|
|
7
|
-
|
|
8
|
-
octokit (~> 4.18)
|
|
6
|
+
highline_wrapper (~> 1.1)
|
|
9
7
|
|
|
10
8
|
GEM
|
|
11
9
|
remote: https://rubygems.org/
|
|
12
10
|
specs:
|
|
13
|
-
|
|
14
|
-
public_suffix (>= 2.0.2, < 5.0)
|
|
11
|
+
ast (2.4.2)
|
|
15
12
|
coderay (1.1.3)
|
|
16
|
-
concurrent-ruby (1.
|
|
17
|
-
diff-lcs (1.
|
|
18
|
-
faker (2.
|
|
19
|
-
i18n (>= 1.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
faraday-net_http (1.0.1)
|
|
25
|
-
ffi (1.14.2)
|
|
26
|
-
formatador (0.2.5)
|
|
27
|
-
gitlab (4.17.0)
|
|
28
|
-
httparty (~> 0.18)
|
|
29
|
-
terminal-table (~> 1.5, >= 1.5.1)
|
|
30
|
-
gli (2.19.2)
|
|
31
|
-
guard (2.16.2)
|
|
13
|
+
concurrent-ruby (1.2.2)
|
|
14
|
+
diff-lcs (1.5.0)
|
|
15
|
+
faker (3.2.0)
|
|
16
|
+
i18n (>= 1.8.11, < 2)
|
|
17
|
+
ffi (1.15.5)
|
|
18
|
+
formatador (1.1.0)
|
|
19
|
+
gli (2.21.0)
|
|
20
|
+
guard (2.18.0)
|
|
32
21
|
formatador (>= 0.2.4)
|
|
33
22
|
listen (>= 2.7, < 4.0)
|
|
34
23
|
lumberjack (>= 1.0.12, < 2.0)
|
|
35
24
|
nenv (~> 0.1)
|
|
36
25
|
notiffany (~> 0.0)
|
|
37
|
-
pry (>= 0.
|
|
26
|
+
pry (>= 0.13.0)
|
|
38
27
|
shellany (~> 0.0)
|
|
39
28
|
thor (>= 0.18.1)
|
|
40
29
|
guard-compat (1.2.1)
|
|
@@ -42,70 +31,75 @@ GEM
|
|
|
42
31
|
guard (~> 2.1)
|
|
43
32
|
guard-compat (~> 1.1)
|
|
44
33
|
rspec (>= 2.99.0, < 4.0)
|
|
45
|
-
highline (2.0
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
i18n (1.8.8)
|
|
34
|
+
highline (2.1.0)
|
|
35
|
+
highline_wrapper (1.3.1)
|
|
36
|
+
highline (~> 2.0)
|
|
37
|
+
i18n (1.13.0)
|
|
50
38
|
concurrent-ruby (~> 1.0)
|
|
51
|
-
|
|
39
|
+
json (2.6.3)
|
|
40
|
+
listen (3.8.0)
|
|
52
41
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
53
42
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
54
43
|
lumberjack (1.2.8)
|
|
55
44
|
method_source (1.0.0)
|
|
56
|
-
mime-types (3.3.1)
|
|
57
|
-
mime-types-data (~> 3.2015)
|
|
58
|
-
mime-types-data (3.2020.1104)
|
|
59
|
-
multi_xml (0.6.0)
|
|
60
|
-
multipart-post (2.1.1)
|
|
61
45
|
nenv (0.3.0)
|
|
62
46
|
notiffany (0.1.3)
|
|
63
47
|
nenv (~> 0.1)
|
|
64
48
|
shellany (~> 0.0)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
pry (0.14.
|
|
49
|
+
parallel (1.23.0)
|
|
50
|
+
parser (3.2.2.1)
|
|
51
|
+
ast (~> 2.4.1)
|
|
52
|
+
pry (0.14.2)
|
|
69
53
|
coderay (~> 1.1)
|
|
70
54
|
method_source (~> 1.0)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
rb-fsevent (0.10.4)
|
|
55
|
+
rainbow (3.1.1)
|
|
56
|
+
rb-fsevent (0.11.2)
|
|
74
57
|
rb-inotify (0.10.1)
|
|
75
58
|
ffi (~> 1.0)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
rspec-
|
|
80
|
-
|
|
81
|
-
rspec-
|
|
82
|
-
rspec-
|
|
59
|
+
regexp_parser (2.8.0)
|
|
60
|
+
rexml (3.2.5)
|
|
61
|
+
rspec (3.12.0)
|
|
62
|
+
rspec-core (~> 3.12.0)
|
|
63
|
+
rspec-expectations (~> 3.12.0)
|
|
64
|
+
rspec-mocks (~> 3.12.0)
|
|
65
|
+
rspec-core (3.12.2)
|
|
66
|
+
rspec-support (~> 3.12.0)
|
|
67
|
+
rspec-expectations (3.12.3)
|
|
83
68
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
84
|
-
rspec-support (~> 3.
|
|
85
|
-
rspec-mocks (3.
|
|
69
|
+
rspec-support (~> 3.12.0)
|
|
70
|
+
rspec-mocks (3.12.5)
|
|
86
71
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
87
|
-
rspec-support (~> 3.
|
|
88
|
-
rspec-support (3.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
72
|
+
rspec-support (~> 3.12.0)
|
|
73
|
+
rspec-support (3.12.0)
|
|
74
|
+
rubocop (1.50.2)
|
|
75
|
+
json (~> 2.3)
|
|
76
|
+
parallel (~> 1.10)
|
|
77
|
+
parser (>= 3.2.0.0)
|
|
78
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
79
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
80
|
+
rexml (>= 3.2.5, < 4.0)
|
|
81
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
|
82
|
+
ruby-progressbar (~> 1.7)
|
|
83
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
|
84
|
+
rubocop-ast (1.28.1)
|
|
85
|
+
parser (>= 3.2.1.0)
|
|
86
|
+
ruby-progressbar (1.13.0)
|
|
93
87
|
shellany (0.0.1)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
thor (1.1.0)
|
|
97
|
-
unicode-display_width (1.7.0)
|
|
88
|
+
thor (1.2.1)
|
|
89
|
+
unicode-display_width (2.4.2)
|
|
98
90
|
|
|
99
91
|
PLATFORMS
|
|
100
|
-
|
|
92
|
+
arm64-darwin-21
|
|
93
|
+
arm64-darwin-22
|
|
101
94
|
|
|
102
95
|
DEPENDENCIES
|
|
103
96
|
bundler (~> 2.2)
|
|
104
|
-
faker (~>
|
|
97
|
+
faker (~> 3.0)
|
|
105
98
|
git_helper!
|
|
106
99
|
guard-rspec (~> 4.3)
|
|
107
|
-
|
|
100
|
+
pry (~> 0.13)
|
|
108
101
|
rspec (~> 3.9)
|
|
102
|
+
rubocop (~> 1.10)
|
|
109
103
|
|
|
110
104
|
BUNDLED WITH
|
|
111
|
-
2.
|
|
105
|
+
2.4.8
|
data/Guardfile
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
guard :rspec, cmd: 'bundle exec rspec', all_on_start: true do
|
|
4
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
|
5
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
|
2
6
|
watch(%r{^spec/.+_spec\.rb$})
|
|
3
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
4
|
-
watch('spec/spec_helper.rb') { 'spec' }
|
|
5
7
|
end
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause "New" or "Revised" License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Emma Sax.
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions, and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions, and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Git Helper
|
|
2
2
|
|
|
3
3
|
## Gem Usage
|
|
4
4
|
|
|
@@ -6,32 +6,37 @@
|
|
|
6
6
|
gem install git_helper
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Some of the commands in this gem can be used without any additional configuration. However, others utilize special GitHub or GitLab configuration. To provide access tokens for this, create a `~/.git_helper/config.yml` file. The contents should look like this:
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
:github_user: GITHUB-USERNAME
|
|
13
|
-
:github_token: GITHUB-TOKEN
|
|
14
|
-
:gitlab_user: GITLAB-USERNAME
|
|
15
|
-
:gitlab_token: GITLAB-TOKEN
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
To create or see what access tokens you have, look [here for GitHub personal access tokens](https://github.com/settings/tokens) and [here for GitLab access tokens](https://gitlab.com/profile/personal_access_tokens). You could either have one set of tokens for each computer you use, or just have one set of tokens for all computers that you rotate periodically.
|
|
19
|
-
|
|
20
9
|
Once the gem is installed, run this to view the help screen:
|
|
10
|
+
|
|
21
11
|
```bash
|
|
22
12
|
git-helper --help
|
|
23
13
|
```
|
|
24
14
|
|
|
25
|
-
To see what version of
|
|
15
|
+
To see what version of Git Helper you're running, run:
|
|
16
|
+
|
|
26
17
|
```bash
|
|
27
18
|
git-helper --version
|
|
28
19
|
```
|
|
29
20
|
|
|
30
|
-
|
|
21
|
+
Some of the commands in this gem can be used without any additional configuration. However, others utilize special GitHub or GitLab configuration. To set up access with GitHub/GitLab, run:
|
|
22
|
+
|
|
31
23
|
```bash
|
|
32
24
|
git-helper setup
|
|
33
25
|
```
|
|
34
26
|
|
|
27
|
+
This will give you the option to set up credentials at GitHub and/or GitLab, as well as give you the choice to set up Git Helper as a plugin or not (see below).
|
|
28
|
+
|
|
29
|
+
The final result will be a `~/.git_helper/config.yml` file with the contents in this form:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
:github_user: GITHUB-USERNAME
|
|
33
|
+
:github_token: GITHUB-TOKEN
|
|
34
|
+
:gitlab_user: GITLAB-USERNAME
|
|
35
|
+
:gitlab_token: GITLAB-TOKEN
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
To create or see what access tokens you have, look [here for GitHub personal access tokens](https://github.com/settings/tokens) and [here for GitLab access tokens](https://gitlab.com/profile/personal_access_tokens). You could either have one set of tokens for each computer you use, or just have one set of tokens for all computers that you rotate periodically.
|
|
39
|
+
|
|
35
40
|
## Plugin Usage
|
|
36
41
|
|
|
37
42
|
As an additional option, you can set each of the following commands to be a git plugin, meaning you can call them in a way that feels even more git-native:
|
|
@@ -42,21 +47,12 @@ git-helper clean-branches git clean-branches
|
|
|
42
47
|
git-helper code-request git code-request
|
|
43
48
|
```
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
mkdir ~/.git_helper
|
|
49
|
-
unzip path/to/downloaded/plugins.zip -d ~/.git_helper
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Now, the plugins will live in `~/.git_helper/plugins/*`. Add the following line to your `~/.bash_profile`:
|
|
50
|
+
Running the `setup` command will give you the option to set this up:
|
|
53
51
|
|
|
54
52
|
```bash
|
|
55
|
-
|
|
53
|
+
git-helper setup
|
|
56
54
|
```
|
|
57
55
|
|
|
58
|
-
And then run `source ~/.bash_profile`.
|
|
59
|
-
|
|
60
56
|
## Alias Usage
|
|
61
57
|
|
|
62
58
|
To make the commands even shorter, I recommend setting aliases. You can either set aliases through git itself, like this (only possible if you also use the plugin option):
|
|
@@ -67,7 +63,7 @@ git config --global alias.nb new-branch
|
|
|
67
63
|
|
|
68
64
|
And then running `git nb` maps to `git new-branch`, which through the plugin, maps to `git-helper new-branch`.
|
|
69
65
|
|
|
70
|
-
Or you can set the alias through your `~/.
|
|
66
|
+
Or you can set the alias through your `~/.zshrc` (which is my preferred method because it can make the command even shorter, and doesn't require the plugin usage). To do this, add lines like this to the `~/.zshrc` file and run `source ~/.zshrc`:
|
|
71
67
|
|
|
72
68
|
```bash
|
|
73
69
|
alias gnb="git new-branch"
|
|
@@ -115,7 +111,7 @@ git-helper clean-branches
|
|
|
115
111
|
|
|
116
112
|
### `code-request`
|
|
117
113
|
|
|
118
|
-
This command can be used to handily make new GitHub/GitLab pull/merge requests from the command
|
|
114
|
+
This command can be used to handily make new GitHub/GitLab pull/merge requests from the command-line. The command uses either the [GitHub REST API](https://docs.github.com/en/rest) or [GitLab API](https://docs.gitlab.com/ee/api/) 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). Furthermore, this project will use [JSON](https://www.npmjs.com/package/json), [YAML](https://www.cloudbees.com/blog/yaml-tutorial-everything-you-need-get-started), and [cURL](https://developer.zendesk.com/documentation/developer-tools/getting-started/installing-and-using-curl/).
|
|
119
115
|
|
|
120
116
|
After setup is complete, you can call the command like this:
|
|
121
117
|
|
|
@@ -127,7 +123,7 @@ The command will provide an autogenerated code request title based on your branc
|
|
|
127
123
|
|
|
128
124
|
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.
|
|
129
125
|
|
|
130
|
-
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.
|
|
126
|
+
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. If the project has allowed squashing, but doesn't default it, then the code will ask the user whether to squash the merge request. If the project has set merge requests to require squashing, prevent squashing, or sets the project to default to squashing, then the code will skip a squash question. If default squashing is set, then the code will set the merge request to squash, and the user can change that over the API or in the browser.
|
|
131
127
|
|
|
132
128
|
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.
|
|
133
129
|
|
|
@@ -149,7 +145,7 @@ git-helper forget-local-commits
|
|
|
149
145
|
|
|
150
146
|
### `merge-code-request`
|
|
151
147
|
|
|
152
|
-
This command can be used to merge pull/merge requests from the command
|
|
148
|
+
This command can be used to merge pull/merge requests from the command-line. The command uses either the [GitHub REST API](https://docs.github.com/en/rest) or [GitLab API](https://docs.gitlab.com/ee/api/) 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). Furthermore, this project will use [JSON](https://www.npmjs.com/package/json), [YAML](https://www.cloudbees.com/blog/yaml-tutorial-everything-you-need-get-started), and [cURL](https://developer.zendesk.com/documentation/developer-tools/getting-started/installing-and-using-curl/).
|
|
153
149
|
|
|
154
150
|
After setup is complete, you can call the proper command like this:
|
|
155
151
|
|
|
@@ -166,7 +162,7 @@ For GitLab, the command will use whatever squash/source branch deletion/etc sett
|
|
|
166
162
|
|
|
167
163
|
### `new-branch`
|
|
168
164
|
|
|
169
|
-
This command is useful for making new branches in a repository on the command
|
|
165
|
+
This command is useful for making new branches in a repository on the command-line. To run the command, run:
|
|
170
166
|
|
|
171
167
|
```bash
|
|
172
168
|
git-helper new-branch
|
|
@@ -176,15 +172,27 @@ git-helper new-branch NEW_BRANCH_NAME
|
|
|
176
172
|
|
|
177
173
|
The command either accepts a branch name right away or it will ask you for the name of your new branch. Make sure your input does not contain any spaces or special characters.
|
|
178
174
|
|
|
179
|
-
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
### Contributing
|
|
178
|
+
|
|
179
|
+
To submit a feature request, bug ticket, etc, please submit an official [GitHub issue](https://github.com/emmahsax/git_helper/issues/new). To copy or make changes, please [fork this repository](https://github.com/emmahsax/git_helper/fork). When/if you'd like to contribute back to this upstream, please create a pull request on this repository.
|
|
180
|
+
|
|
181
|
+
Please follow included Issue Template(s) and Pull Request Template(s) when creating issues or pull requests.
|
|
182
|
+
|
|
183
|
+
### Security Policy
|
|
184
|
+
|
|
185
|
+
To report any security vulnerabilities, please view this repository's [Security Policy](https://github.com/emmahsax/git_helper/security/policy).
|
|
186
|
+
|
|
187
|
+
### Licensing
|
|
180
188
|
|
|
181
|
-
|
|
189
|
+
For information on licensing, please see [LICENSE.md](https://github.com/emmahsax/git_helper/blob/main/LICENSE.md).
|
|
182
190
|
|
|
183
|
-
|
|
191
|
+
### Code of Conduct
|
|
184
192
|
|
|
185
193
|
When interacting with this repository, please follow [Contributor Covenant's Code of Conduct](https://contributor-covenant.org).
|
|
186
194
|
|
|
187
|
-
|
|
195
|
+
### Releasing
|
|
188
196
|
|
|
189
197
|
To make a new release of this gem:
|
|
190
198
|
|
data/Rakefile
CHANGED
data/bin/git-helper
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
require 'rubygems'
|
|
3
5
|
require 'gli'
|
|
4
6
|
require_relative '../lib/git_helper'
|
|
@@ -11,15 +13,15 @@ version GitHelper::VERSION
|
|
|
11
13
|
autocomplete_commands false
|
|
12
14
|
wrap_help_text :verbatim
|
|
13
15
|
|
|
14
|
-
program_long_desc "
|
|
16
|
+
program_long_desc "
|
|
15
17
|
DOCUMENTATION
|
|
16
18
|
For documentation and help in setting up your Git configuration files,
|
|
17
19
|
see Git Helper's GitHub repo: https://github.com/emmahsax/git_helper
|
|
18
|
-
"
|
|
20
|
+
"
|
|
19
21
|
|
|
20
22
|
desc 'Sets up Git Helper configs at ~/.git_helper/*'
|
|
21
23
|
command 'setup' do |c|
|
|
22
|
-
c.action do
|
|
24
|
+
c.action do
|
|
23
25
|
GitHelper::Setup.new.execute
|
|
24
26
|
end
|
|
25
27
|
end
|
|
@@ -28,36 +30,37 @@ arg :old_owner
|
|
|
28
30
|
arg :new_owner
|
|
29
31
|
desc "Update a repository's remote URLs from an old GitHub owner to a new owner."
|
|
30
32
|
command 'change-remote' do |c|
|
|
31
|
-
c.action do |
|
|
33
|
+
c.action do |_global_options, _options, args|
|
|
32
34
|
raise ArgumentError, 'You must specify an old owner and a new owner' unless args.count == 2
|
|
35
|
+
|
|
33
36
|
GitHelper::ChangeRemote.new(args[0], args[1]).execute
|
|
34
37
|
end
|
|
35
38
|
end
|
|
36
39
|
|
|
37
40
|
desc 'Checks out the default branch of a repo based on the local remote branches.'
|
|
38
41
|
command 'checkout-default' do |c|
|
|
39
|
-
c.action do |
|
|
42
|
+
c.action do |_global_options, _options, _args|
|
|
40
43
|
GitHelper::CheckoutDefault.new.execute
|
|
41
44
|
end
|
|
42
45
|
end
|
|
43
46
|
|
|
44
47
|
desc "Clean a repository's git branches."
|
|
45
48
|
command 'clean-branches' do |c|
|
|
46
|
-
c.action do |
|
|
49
|
+
c.action do |_global_options, _options, _args|
|
|
47
50
|
GitHelper::CleanBranches.new.execute
|
|
48
51
|
end
|
|
49
52
|
end
|
|
50
53
|
|
|
51
54
|
desc 'Creates an empty commit with a basic commit message.'
|
|
52
55
|
command 'empty-commit' do |c|
|
|
53
|
-
c.action do |
|
|
56
|
+
c.action do |_global_options, _options, _args|
|
|
54
57
|
GitHelper::EmptyCommit.new.execute
|
|
55
58
|
end
|
|
56
59
|
end
|
|
57
60
|
|
|
58
61
|
desc 'Reset your local git commits to origin/HEAD.'
|
|
59
62
|
command 'forget-local-commits' do |c|
|
|
60
|
-
c.action do |
|
|
63
|
+
c.action do |_global_options, _options, _args|
|
|
61
64
|
GitHelper::ForgetLocalCommits.new.execute
|
|
62
65
|
end
|
|
63
66
|
end
|
|
@@ -65,21 +68,23 @@ end
|
|
|
65
68
|
arg :new_branch_name, optional: true
|
|
66
69
|
desc 'Create a new branch for features, bug fixes, or experimentation.'
|
|
67
70
|
command 'new-branch' do |c|
|
|
68
|
-
c.action do |
|
|
71
|
+
c.action do |_global_options, _options, args|
|
|
69
72
|
GitHelper::NewBranch.new.execute(args[0])
|
|
70
73
|
end
|
|
71
74
|
end
|
|
72
75
|
|
|
73
|
-
desc 'Merge a GitHub/GitLab pull/merge request. The command will figure out whether your
|
|
76
|
+
desc 'Merge a GitHub/GitLab pull/merge request. The command will figure out whether your ' \
|
|
77
|
+
'code project belongs to GitHub or GitLab.'
|
|
74
78
|
command 'merge-code-request' do |c|
|
|
75
|
-
c.action do |
|
|
79
|
+
c.action do |_global_options, _options, _args|
|
|
76
80
|
GitHelper::CodeRequest.new.merge
|
|
77
81
|
end
|
|
78
82
|
end
|
|
79
83
|
|
|
80
|
-
desc 'Create a GitHub/GitLab pull/merge request from the current branch. The command will figure
|
|
84
|
+
desc 'Create a GitHub/GitLab pull/merge request from the current branch. The command will figure ' \
|
|
85
|
+
'out whether your code project belongs to GitHub or GitLab.'
|
|
81
86
|
command 'code-request' do |c|
|
|
82
|
-
c.action do |
|
|
87
|
+
c.action do |_global_options, _options, _args|
|
|
83
88
|
GitHelper::CodeRequest.new.create
|
|
84
89
|
end
|
|
85
90
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module GitHelper
|
|
2
4
|
class ChangeRemote
|
|
3
5
|
attr_accessor :old_owner, :new_owner
|
|
@@ -11,7 +13,7 @@ module GitHelper
|
|
|
11
13
|
original_dir = Dir.pwd
|
|
12
14
|
nested_dirs = Dir.entries(original_dir).select do |entry|
|
|
13
15
|
entry_dir = File.join(original_dir, entry)
|
|
14
|
-
File.directory?(entry_dir) && !
|
|
16
|
+
File.directory?(entry_dir) && !['.', '..'].include?(entry)
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
nested_dirs.each do |nested_dir|
|
|
@@ -22,8 +24,11 @@ module GitHelper
|
|
|
22
24
|
private def process_dir(current_dir, original_dir)
|
|
23
25
|
Dir.chdir(current_dir)
|
|
24
26
|
|
|
25
|
-
if File.exist?('.git')
|
|
26
|
-
|
|
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 }
|
|
30
|
+
)
|
|
31
|
+
process_git_repository
|
|
27
32
|
end
|
|
28
33
|
|
|
29
34
|
Dir.chdir(original_dir)
|
|
@@ -37,9 +42,11 @@ module GitHelper
|
|
|
37
42
|
puts " Found remote is not pointing to #{old_owner}."
|
|
38
43
|
end
|
|
39
44
|
end
|
|
40
|
-
puts
|
|
45
|
+
puts
|
|
41
46
|
end
|
|
42
47
|
|
|
48
|
+
# rubocop:disable Metrics/AbcSize
|
|
49
|
+
# rubocop:disable Metrics/MethodLength
|
|
43
50
|
private def process_remote(remote)
|
|
44
51
|
remote_name = local_code.remote_name(remote)
|
|
45
52
|
|
|
@@ -56,13 +63,15 @@ module GitHelper
|
|
|
56
63
|
puts " Changing the remote URL #{remote_name} to be '#{remote_url}'."
|
|
57
64
|
local_code.change_remote(remote_name, remote_url)
|
|
58
65
|
end
|
|
66
|
+
# rubocop:enable Metrics/MethodLength
|
|
67
|
+
# rubocop:enable Metrics/AbcSize
|
|
59
68
|
|
|
60
69
|
private def local_code
|
|
61
70
|
@local_code ||= GitHelper::LocalCode.new
|
|
62
71
|
end
|
|
63
72
|
|
|
64
|
-
private def
|
|
65
|
-
@
|
|
73
|
+
private def highline
|
|
74
|
+
@highline ||= HighlineWrapper.new
|
|
66
75
|
end
|
|
67
76
|
end
|
|
68
77
|
end
|