git_helper 3.6.1 → 3.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +44 -41
- data/Guardfile +2 -2
- data/README.md +21 -25
- data/lib/git_helper/git_config_reader.rb +1 -1
- data/lib/git_helper/local_code.rb +4 -4
- data/lib/git_helper/merge_request.rb +5 -10
- data/lib/git_helper/setup.rb +7 -8
- data/lib/git_helper/version.rb +1 -1
- data/lib/git_helper.rb +1 -1
- data/renovate.json +6 -0
- metadata +7 -36
- data/spec/git_helper/change_remote_spec.rb +0 -176
- data/spec/git_helper/checkout_default_spec.rb +0 -21
- data/spec/git_helper/clean_branches_spec.rb +0 -21
- data/spec/git_helper/code_request_spec.rb +0 -265
- data/spec/git_helper/empty_commit_spec.rb +0 -21
- data/spec/git_helper/forget_local_commits_spec.rb +0 -21
- data/spec/git_helper/git_config_reader_spec.rb +0 -90
- data/spec/git_helper/github_client_spec.rb +0 -131
- data/spec/git_helper/gitlab_client_spec.rb +0 -144
- data/spec/git_helper/local_code_spec.rb +0 -270
- data/spec/git_helper/merge_request_spec.rb +0 -278
- data/spec/git_helper/new_branch_spec.rb +0 -47
- data/spec/git_helper/pull_request_spec.rb +0 -255
- data/spec/git_helper/setup_spec.rb +0 -183
- data/spec/spec_helper.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e0efd69de26cab869fc579da3011c6958b2491913cca1e0ec061f33a6890e91
|
4
|
+
data.tar.gz: e942b0e9b503de7d33090ce6be10b197df033fffe80b401a837c4ce62195b186
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30472648379bc818e9b54f15b25948e7f5cc64e0a0cb349724a8ae9f1df8e0642d1daac1df3ff4669334d162370d3a7f78c57df16574fb89c9cc2b5d48963a1c
|
7
|
+
data.tar.gz: 69d48ba584a596249b41b91f0cb6828af7fca255a13c123d84bc24071ed2de5cfda8cac0777050002f68e63f8e4608322924f1baae288693bd5f12cb030f4930
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
git_helper (3.6.
|
4
|
+
git_helper (3.6.3)
|
5
5
|
gli (~> 2.13)
|
6
6
|
highline_wrapper (~> 1.1)
|
7
7
|
|
@@ -10,13 +10,13 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
ast (2.4.2)
|
12
12
|
coderay (1.1.3)
|
13
|
-
concurrent-ruby (1.
|
14
|
-
diff-lcs (1.
|
15
|
-
faker (
|
16
|
-
i18n (>= 1.
|
17
|
-
ffi (1.15.
|
18
|
-
formatador (
|
19
|
-
gli (2.
|
13
|
+
concurrent-ruby (1.2.0)
|
14
|
+
diff-lcs (1.5.0)
|
15
|
+
faker (3.1.1)
|
16
|
+
i18n (>= 1.8.11, < 2)
|
17
|
+
ffi (1.15.5)
|
18
|
+
formatador (1.1.0)
|
19
|
+
gli (2.21.0)
|
20
20
|
guard (2.18.0)
|
21
21
|
formatador (>= 0.2.4)
|
22
22
|
listen (>= 2.7, < 4.0)
|
@@ -31,12 +31,13 @@ GEM
|
|
31
31
|
guard (~> 2.1)
|
32
32
|
guard-compat (~> 1.1)
|
33
33
|
rspec (>= 2.99.0, < 4.0)
|
34
|
-
highline (2.0
|
35
|
-
highline_wrapper (1.3.
|
34
|
+
highline (2.1.0)
|
35
|
+
highline_wrapper (1.3.1)
|
36
36
|
highline (~> 2.0)
|
37
|
-
i18n (1.
|
37
|
+
i18n (1.12.0)
|
38
38
|
concurrent-ruby (~> 1.0)
|
39
|
-
|
39
|
+
json (2.6.3)
|
40
|
+
listen (3.8.0)
|
40
41
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
41
42
|
rb-inotify (~> 0.9, >= 0.9.10)
|
42
43
|
lumberjack (1.2.8)
|
@@ -45,53 +46,55 @@ GEM
|
|
45
46
|
notiffany (0.1.3)
|
46
47
|
nenv (~> 0.1)
|
47
48
|
shellany (~> 0.0)
|
48
|
-
parallel (1.
|
49
|
-
parser (3.
|
49
|
+
parallel (1.22.1)
|
50
|
+
parser (3.2.1.0)
|
50
51
|
ast (~> 2.4.1)
|
51
|
-
pry (0.14.
|
52
|
+
pry (0.14.2)
|
52
53
|
coderay (~> 1.1)
|
53
54
|
method_source (~> 1.0)
|
54
|
-
rainbow (3.
|
55
|
-
rb-fsevent (0.11.
|
55
|
+
rainbow (3.1.1)
|
56
|
+
rb-fsevent (0.11.2)
|
56
57
|
rb-inotify (0.10.1)
|
57
58
|
ffi (~> 1.0)
|
58
|
-
regexp_parser (2.
|
59
|
+
regexp_parser (2.7.0)
|
59
60
|
rexml (3.2.5)
|
60
|
-
rspec (3.
|
61
|
-
rspec-core (~> 3.
|
62
|
-
rspec-expectations (~> 3.
|
63
|
-
rspec-mocks (~> 3.
|
64
|
-
rspec-core (3.
|
65
|
-
rspec-support (~> 3.
|
66
|
-
rspec-expectations (3.
|
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.1)
|
66
|
+
rspec-support (~> 3.12.0)
|
67
|
+
rspec-expectations (3.12.2)
|
67
68
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
|
-
rspec-support (~> 3.
|
69
|
-
rspec-mocks (3.
|
69
|
+
rspec-support (~> 3.12.0)
|
70
|
+
rspec-mocks (3.12.3)
|
70
71
|
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
-
rspec-support (~> 3.
|
72
|
-
rspec-support (3.
|
73
|
-
rubocop (1.
|
72
|
+
rspec-support (~> 3.12.0)
|
73
|
+
rspec-support (3.12.0)
|
74
|
+
rubocop (1.45.1)
|
75
|
+
json (~> 2.3)
|
74
76
|
parallel (~> 1.10)
|
75
|
-
parser (>= 3.
|
77
|
+
parser (>= 3.2.0.0)
|
76
78
|
rainbow (>= 2.2.2, < 4.0)
|
77
79
|
regexp_parser (>= 1.8, < 3.0)
|
78
|
-
rexml
|
79
|
-
rubocop-ast (>= 1.
|
80
|
+
rexml (>= 3.2.5, < 4.0)
|
81
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
80
82
|
ruby-progressbar (~> 1.7)
|
81
|
-
unicode-display_width (>=
|
82
|
-
rubocop-ast (1.
|
83
|
-
parser (>= 3.
|
83
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
84
|
+
rubocop-ast (1.24.1)
|
85
|
+
parser (>= 3.1.1.0)
|
84
86
|
ruby-progressbar (1.11.0)
|
85
87
|
shellany (0.0.1)
|
86
|
-
thor (1.1
|
87
|
-
unicode-display_width (2.
|
88
|
+
thor (1.2.1)
|
89
|
+
unicode-display_width (2.4.2)
|
88
90
|
|
89
91
|
PLATFORMS
|
90
|
-
|
92
|
+
arm64-darwin-21
|
93
|
+
arm64-darwin-22
|
91
94
|
|
92
95
|
DEPENDENCIES
|
93
96
|
bundler (~> 2.2)
|
94
|
-
faker (~>
|
97
|
+
faker (~> 3.0)
|
95
98
|
git_helper!
|
96
99
|
guard-rspec (~> 4.3)
|
97
100
|
pry (~> 0.13)
|
@@ -99,4 +102,4 @@ DEPENDENCIES
|
|
99
102
|
rubocop (~> 1.10)
|
100
103
|
|
101
104
|
BUNDLED WITH
|
102
|
-
2.
|
105
|
+
2.4.6
|
data/Guardfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
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" }
|
4
6
|
watch(%r{^spec/.+_spec\.rb$})
|
5
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
6
|
-
watch('spec/spec_helper.rb') { 'spec' }
|
7
7
|
end
|
data/README.md
CHANGED
@@ -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
|
-
|
50
|
+
Running the `setup` command will give you the option to set this up:
|
46
51
|
|
47
52
|
```bash
|
48
|
-
|
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`:
|
53
|
-
|
54
|
-
```bash
|
55
|
-
export PATH=/path/to/computer/home/.git_helper/plugins:$PATH
|
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"
|
@@ -108,7 +108,7 @@ module GitHelper
|
|
108
108
|
# rubocop:enable Metrics/AbcSize
|
109
109
|
|
110
110
|
def read_template(file_name)
|
111
|
-
File.
|
111
|
+
File.read(file_name)
|
112
112
|
end
|
113
113
|
|
114
114
|
# rubocop:disable Metrics/AbcSize
|
@@ -122,14 +122,14 @@ module GitHelper
|
|
122
122
|
branch_arr.first.capitalize
|
123
123
|
elsif branch_arr[0].scan(/(\w+)/).any? && branch_arr[1].scan(/(\d+)/).any? # branch includes jira_123 at beginning
|
124
124
|
issue = "#{branch_arr[0].upcase}-#{branch_arr[1]}"
|
125
|
-
description = branch_arr[2
|
125
|
+
description = branch_arr[2..].join(' ')
|
126
126
|
"#{issue} #{description.capitalize}"
|
127
127
|
elsif branch_arr[0].scan(/(\w+-\d+)/).any? # branch includes string jira-123 at beginning
|
128
128
|
issue = branch_arr[0].upcase
|
129
|
-
description = branch_arr[1
|
129
|
+
description = branch_arr[1..].join(' ')
|
130
130
|
"#{issue} #{description.capitalize}"
|
131
131
|
else # plain words
|
132
|
-
branch_arr[0
|
132
|
+
branch_arr[0..].join(' ').capitalize
|
133
133
|
end
|
134
134
|
end
|
135
135
|
# rubocop:enable Metrics/MethodLength
|
@@ -29,21 +29,16 @@ module GitHelper
|
|
29
29
|
puts "Creating merge request: #{new_mr_title}"
|
30
30
|
mr = gitlab_client.create_merge_request(local_project, options)
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
if mr.diff_refs['base_sha'] == mr.diff_refs['head_sha']
|
32
|
+
if mr.web_url && mr.diff_refs && (mr.diff_refs['base_sha'] == mr.diff_refs['head_sha'])
|
35
33
|
puts "Merge request was created, but no commits have been pushed to GitLab: #{mr.web_url}"
|
36
|
-
|
34
|
+
elsif mr.web_url
|
37
35
|
puts "Merge request successfully created: #{mr.web_url}"
|
36
|
+
else
|
37
|
+
raise StandardError, (mr.message.instance_of?(Array) ? mr.message.first : mr.message)
|
38
38
|
end
|
39
39
|
rescue StandardError => e
|
40
40
|
puts 'Could not create merge request:'
|
41
|
-
|
42
|
-
if e.message.include?('Another open merge request already exists')
|
43
|
-
puts ' A merge request already exists for this branch'
|
44
|
-
else
|
45
|
-
puts " #{e.message}"
|
46
|
-
end
|
41
|
+
puts " #{e.message}"
|
47
42
|
end
|
48
43
|
# rubocop:enable Metrics/AbcSize
|
49
44
|
# rubocop:enable Metrics/MethodLength
|
data/lib/git_helper/setup.rb
CHANGED
@@ -32,14 +32,15 @@ module GitHelper
|
|
32
32
|
return unless answer
|
33
33
|
|
34
34
|
create_or_update_plugin_files
|
35
|
-
puts "\nNow add this line to your ~/.
|
36
|
-
'
|
35
|
+
puts "\nNow add this line to your ~/.zshrc:\n " \
|
36
|
+
'export PATH="$HOME/.git_helper/plugins:$PATH"'
|
37
37
|
puts "\nDone!"
|
38
38
|
end
|
39
39
|
|
40
40
|
private def create_or_update_config_file
|
41
41
|
contents = generate_file_contents
|
42
42
|
puts "Creating or updating your #{config_file} file..."
|
43
|
+
FileUtils.mkdir_p("#{Dir.home}/.git_helper")
|
43
44
|
File.open(config_file, 'w') { |file| file.puts contents }
|
44
45
|
puts "\nDone!\n\n"
|
45
46
|
end
|
@@ -66,8 +67,8 @@ module GitHelper
|
|
66
67
|
file_contents << ":gitlab_user: #{ask_question('GitLab username?')}\n"
|
67
68
|
file_contents << ':gitlab_token: ' \
|
68
69
|
"#{ask_question(
|
69
|
-
'GitLab personal access token? (Navigate to https://gitlab.com/-/profile/personal_access_tokens' \
|
70
|
-
'
|
70
|
+
'GitLab personal access token? (Navigate to https://gitlab.com/-/profile/personal_access_tokens ' \
|
71
|
+
'to create a new personal access token)',
|
71
72
|
secret: true
|
72
73
|
)}\n"
|
73
74
|
end
|
@@ -81,15 +82,14 @@ module GitHelper
|
|
81
82
|
end
|
82
83
|
|
83
84
|
# rubocop:disable Metrics/MethodLength
|
84
|
-
# rubocop:disable Metrics/AbcSize
|
85
85
|
private def create_or_update_plugin_files
|
86
|
-
plugins_dir = "#{Dir.
|
86
|
+
plugins_dir = "#{Dir.home}/.git_helper/plugins"
|
87
87
|
plugins_url = 'https://api.github.com/repos/emmahsax/git_helper/contents/plugins'
|
88
88
|
header = 'Accept: application/vnd.github.v3.raw'
|
89
89
|
token = git_config_reader.github_token
|
90
90
|
user = git_config_reader.github_user
|
91
91
|
|
92
|
-
|
92
|
+
FileUtils.mkdir_p(plugins_dir)
|
93
93
|
|
94
94
|
all_plugins = JSON.parse(`curl -s -u #{user}:#{token} -H "#{header}" -L "#{plugins_url}"`)
|
95
95
|
|
@@ -99,7 +99,6 @@ module GitHelper
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
# rubocop:enable Metrics/MethodLength
|
102
|
-
# rubocop:enable Metrics/AbcSize
|
103
102
|
|
104
103
|
private def config_file
|
105
104
|
git_config_reader.git_config_file_path
|
data/lib/git_helper/version.rb
CHANGED
data/lib/git_helper.rb
CHANGED
data/renovate.json
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emma Sax
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: guard-rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,21 +154,7 @@ files:
|
|
154
154
|
- lib/git_helper/setup.rb
|
155
155
|
- lib/git_helper/version.rb
|
156
156
|
- plugins.zip
|
157
|
-
-
|
158
|
-
- spec/git_helper/checkout_default_spec.rb
|
159
|
-
- spec/git_helper/clean_branches_spec.rb
|
160
|
-
- spec/git_helper/code_request_spec.rb
|
161
|
-
- spec/git_helper/empty_commit_spec.rb
|
162
|
-
- spec/git_helper/forget_local_commits_spec.rb
|
163
|
-
- spec/git_helper/git_config_reader_spec.rb
|
164
|
-
- spec/git_helper/github_client_spec.rb
|
165
|
-
- spec/git_helper/gitlab_client_spec.rb
|
166
|
-
- spec/git_helper/local_code_spec.rb
|
167
|
-
- spec/git_helper/merge_request_spec.rb
|
168
|
-
- spec/git_helper/new_branch_spec.rb
|
169
|
-
- spec/git_helper/pull_request_spec.rb
|
170
|
-
- spec/git_helper/setup_spec.rb
|
171
|
-
- spec/spec_helper.rb
|
157
|
+
- renovate.json
|
172
158
|
homepage: https://github.com/emmahsax/git_helper
|
173
159
|
licenses:
|
174
160
|
- BSD-3-Clause
|
@@ -189,23 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
175
|
- !ruby/object:Gem::Version
|
190
176
|
version: '0'
|
191
177
|
requirements: []
|
192
|
-
rubygems_version: 3.
|
178
|
+
rubygems_version: 3.4.6
|
193
179
|
signing_key:
|
194
180
|
specification_version: 4
|
195
181
|
summary: A set of GitHub and GitLab workflow scripts
|
196
|
-
test_files:
|
197
|
-
- spec/spec_helper.rb
|
198
|
-
- spec/git_helper/change_remote_spec.rb
|
199
|
-
- spec/git_helper/checkout_default_spec.rb
|
200
|
-
- spec/git_helper/clean_branches_spec.rb
|
201
|
-
- spec/git_helper/code_request_spec.rb
|
202
|
-
- spec/git_helper/empty_commit_spec.rb
|
203
|
-
- spec/git_helper/forget_local_commits_spec.rb
|
204
|
-
- spec/git_helper/git_config_reader_spec.rb
|
205
|
-
- spec/git_helper/github_client_spec.rb
|
206
|
-
- spec/git_helper/gitlab_client_spec.rb
|
207
|
-
- spec/git_helper/local_code_spec.rb
|
208
|
-
- spec/git_helper/merge_request_spec.rb
|
209
|
-
- spec/git_helper/new_branch_spec.rb
|
210
|
-
- spec/git_helper/pull_request_spec.rb
|
211
|
-
- spec/git_helper/setup_spec.rb
|
182
|
+
test_files: []
|
@@ -1,176 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'git_helper'
|
5
|
-
|
6
|
-
describe GitHelper::ChangeRemote do
|
7
|
-
let(:remote1) { "git@github.com:#{old_owner}/#{project}.git" }
|
8
|
-
let(:project) { Faker::Lorem.word }
|
9
|
-
let(:highline_wrapper) { double(:highline_wrapper, ask_yes_no: true) }
|
10
|
-
let(:old_owner) { Faker::Internet.username }
|
11
|
-
let(:new_owner) { Faker::Internet.username }
|
12
|
-
let(:directory_entries) { ['.', '..', project, Faker::Lorem.word, Faker::Lorem.word] }
|
13
|
-
|
14
|
-
let(:local_code) do
|
15
|
-
double(:local_code,
|
16
|
-
remotes: [remote1],
|
17
|
-
remote_name: Faker::Lorem.word,
|
18
|
-
ssh_remote?: true,
|
19
|
-
https_remote?: false,
|
20
|
-
remote_project: project,
|
21
|
-
remote_source: 'github.com',
|
22
|
-
change_remote: true)
|
23
|
-
end
|
24
|
-
|
25
|
-
subject { GitHelper::ChangeRemote.new(old_owner, new_owner) }
|
26
|
-
|
27
|
-
before do
|
28
|
-
allow(HighlineWrapper).to receive(:new).and_return(highline_wrapper)
|
29
|
-
allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
|
30
|
-
allow(subject).to receive(:puts)
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#execute' do
|
34
|
-
before do
|
35
|
-
allow(Dir).to receive(:pwd).and_return("/Users/#{Faker::Name.first_name}/#{project}")
|
36
|
-
allow(Dir).to receive(:entries).and_return(directory_entries)
|
37
|
-
allow(File).to receive(:join).and_return("/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
|
38
|
-
allow(File).to receive(:directory?).and_return(true)
|
39
|
-
allow(subject).to receive(:process_dir)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should call to process at least one directory' do
|
43
|
-
expect(subject).to receive(:process_dir).at_least(:once)
|
44
|
-
subject.execute
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should definitely look in the file structure' do
|
48
|
-
expect(Dir).to receive(:pwd)
|
49
|
-
expect(Dir).to receive(:entries)
|
50
|
-
expect(File).to receive(:join)
|
51
|
-
expect(File).to receive(:directory?)
|
52
|
-
subject.execute
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe '#process_dir' do
|
57
|
-
before do
|
58
|
-
allow(Dir).to receive(:chdir).and_return(nil)
|
59
|
-
allow(File).to receive(:exist?).and_return(true)
|
60
|
-
allow(subject).to receive(:process_git_repository)
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should definitely look in the file structure' do
|
64
|
-
expect(Dir).to receive(:chdir)
|
65
|
-
expect(File).to receive(:exist?)
|
66
|
-
subject.send(:process_dir, "/Users/#{Faker::Name.first_name}/#{project}", "/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'when the user says to process the directory' do
|
70
|
-
it 'should call to process the git repository at least once' do
|
71
|
-
expect(subject).to receive(:process_git_repository).at_least(:once)
|
72
|
-
subject.send(:process_dir, "/Users/#{Faker::Name.first_name}/#{project}", "/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'when the user says not to process the directory' do
|
77
|
-
let(:highline_wrapper) { double(:highline_wrapper, ask_yes_no: false) }
|
78
|
-
|
79
|
-
it 'should not call to process the directory' do
|
80
|
-
expect(subject).not_to receive(:process_git_repository)
|
81
|
-
subject.send(:process_dir, "/Users/#{Faker::Name.first_name}/#{project}", "/Users/#{Faker::Name.first_name}/#{project}/#{Faker::Lorem.word}")
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#process_git_repository' do
|
87
|
-
before do
|
88
|
-
allow(subject).to receive(:process_remote).and_return(nil)
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'should call local_code' do
|
92
|
-
expect(GitHelper::LocalCode).to receive(:new)
|
93
|
-
subject.send(:process_git_repository)
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'when the remote includes the old owner' do
|
97
|
-
it 'should call to process the remote' do
|
98
|
-
expect(subject).to receive(:process_remote)
|
99
|
-
subject.send(:process_git_repository)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
context 'when the remote does not include the old owner' do
|
104
|
-
let(:remote1) { "git@github.com:#{new_owner}/#{project}.git" }
|
105
|
-
|
106
|
-
it 'should not call to process the remote' do
|
107
|
-
expect(subject).not_to receive(:process_remote)
|
108
|
-
subject.send(:process_git_repository)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
describe '#process_remote' do
|
114
|
-
it 'should always get the remote name' do
|
115
|
-
expect(local_code).to receive(:remote_name)
|
116
|
-
subject.send(:process_remote, remote1)
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'should always attempt to change the remote' do
|
120
|
-
expect(local_code).to receive(:change_remote)
|
121
|
-
subject.send(:process_remote, remote1)
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'should attempt to get the remote repo exactly once' do
|
125
|
-
expect(local_code).to receive(:remote_project).exactly(:once)
|
126
|
-
subject.send(:process_remote, remote1)
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'should attempt to get the remote source exactly once' do
|
130
|
-
expect(local_code).to receive(:remote_source).exactly(:once)
|
131
|
-
subject.send(:process_remote, remote1)
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'should ask if the remote is SSH' do
|
135
|
-
expect(local_code).to receive(:ssh_remote?)
|
136
|
-
subject.send(:process_remote, remote1)
|
137
|
-
end
|
138
|
-
|
139
|
-
context 'https remote' do
|
140
|
-
let(:local_code) do
|
141
|
-
double(:local_code,
|
142
|
-
remotes: [remote1],
|
143
|
-
remote_name: Faker::Lorem.word,
|
144
|
-
ssh_remote?: false,
|
145
|
-
https_remote?: false,
|
146
|
-
remote_project: project,
|
147
|
-
remote_source: 'github.com',
|
148
|
-
change_remote: true)
|
149
|
-
end
|
150
|
-
|
151
|
-
it 'should ask if the remote is SSH' do
|
152
|
-
expect(local_code).to receive(:ssh_remote?)
|
153
|
-
subject.send(:process_remote, remote1)
|
154
|
-
end
|
155
|
-
|
156
|
-
it 'should ask if the remote is https' do
|
157
|
-
expect(local_code).to receive(:https_remote?)
|
158
|
-
subject.send(:process_remote, remote1)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe '#local_code' do
|
164
|
-
it 'should create a new local code instance' do
|
165
|
-
expect(GitHelper::LocalCode).to receive(:new)
|
166
|
-
subject.send(:local_code)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
describe '#highline' do
|
171
|
-
it 'should create a new highline_wrapper instance' do
|
172
|
-
expect(HighlineWrapper).to receive(:new)
|
173
|
-
subject.send(:highline)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'git_helper'
|
5
|
-
|
6
|
-
describe GitHelper::CheckoutDefault do
|
7
|
-
let(:local_code) { double(:local_code, checkout_default: :done) }
|
8
|
-
|
9
|
-
subject { GitHelper::CheckoutDefault.new }
|
10
|
-
|
11
|
-
it 'should call GitHelper::LocalCode' do
|
12
|
-
expect(GitHelper::LocalCode).to receive(:new).and_return(local_code)
|
13
|
-
subject.execute
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should call the checkout_default method from the local code class' do
|
17
|
-
allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
|
18
|
-
expect(local_code).to receive(:checkout_default)
|
19
|
-
subject.execute
|
20
|
-
end
|
21
|
-
end
|