git_reflow 0.9.3 → 0.9.7

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.
@@ -1,15 +1,15 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
+
3
+ module Gitacular
4
+ include GitReflow::GitHelpers
5
+ extend self
6
+ end
2
7
 
3
8
  describe GitReflow::GitHelpers do
4
- let(:origin_url) { 'git@github.com:reenhanced.spectacular/this-is-the.shit.git' }
9
+ let(:origin_url) { "git@github.com:reenhanced.spectacular/this-is-the.shit.git" }
5
10
 
6
11
  before do
7
- stub_with_fallback(GitReflow::Config, :get).with('remote.origin.url').and_return(origin_url)
8
-
9
- module Gitacular
10
- include GitReflow::GitHelpers
11
- extend self
12
- end
12
+ stub_with_fallback(GitReflow::Config, :get).with("remote.origin.url").and_return(origin_url)
13
13
 
14
14
  stub_run_for Gitacular
15
15
  end
@@ -18,83 +18,86 @@ describe GitReflow::GitHelpers do
18
18
  subject { Gitacular.default_editor }
19
19
 
20
20
  context "when the environment has EDITOR set" do
21
- before { allow(ENV).to receive(:[]).with('EDITOR').and_return('emacs') }
22
- specify { expect( subject ).to eql('emacs') }
21
+ before { allow(ENV).to receive(:[]).with("EDITOR").and_return("emacs") }
22
+ specify { expect(subject).to eql("emacs") }
23
23
  end
24
24
 
25
25
  context "when the environment has no EDITOR set" do
26
- before { allow(ENV).to receive(:[]).with('EDITOR').and_return(nil) }
27
- specify { expect( subject ).to eql('vi') }
26
+ before { allow(ENV).to receive(:[]).with("EDITOR").and_return(nil) }
27
+ specify { expect(subject).to eql("vi") }
28
28
  end
29
29
  end
30
30
 
31
31
  describe ".git_root_dir" do
32
32
  subject { Gitacular.git_root_dir }
33
- it { expect{ subject }.to have_run_command_silently "git rev-parse --show-toplevel" }
33
+ it { expect { subject }.to have_run_command_silently "git rev-parse --show-toplevel" }
34
34
  end
35
35
 
36
- describe '.git_editor_command' do
36
+ describe ".git_editor_command" do
37
37
  subject { Gitacular.git_editor_command }
38
- before { ENV['EDITOR'] = 'vim' }
38
+ before { ENV["EDITOR"] = "vim" }
39
39
 
40
- it 'defaults to GitReflow config' do
41
- allow(GitReflow::Config).to receive(:get).with('core.editor').and_return 'nano'
40
+ it "defaults to GitReflow config" do
41
+ allow(GitReflow::Config).to receive(:get).with("core.editor").and_return "nano"
42
42
 
43
- expect(subject).to eq 'nano'
43
+ expect(subject).to eq "nano"
44
44
  end
45
45
 
46
- it 'falls back to the environment variable $EDITOR' do
47
- allow(GitReflow::Config).to receive(:get).with('core.editor').and_return ''
46
+ it "falls back to the environment variable $EDITOR" do
47
+ allow(GitReflow::Config).to receive(:get).with("core.editor").and_return ""
48
48
 
49
- expect(subject).to eq 'vim'
49
+ expect(subject).to eq "vim"
50
50
  end
51
51
  end
52
52
 
53
53
  describe ".remote_user" do
54
54
  subject { Gitacular.remote_user }
55
55
 
56
- it { is_expected.to eq('reenhanced.spectacular') }
56
+ it { is_expected.to eq("reenhanced.spectacular") }
57
57
 
58
58
  context "remote origin url isn't set" do
59
- let(:origin_url) { '' }
60
- it { is_expected.to eq('') }
59
+ let(:origin_url) { "" }
60
+ it { is_expected.to eq("") }
61
61
  end
62
62
 
63
63
  context "remote origin uses HTTP" do
64
- let(:origin_url) { 'https://github.com/reenhanced.spectacular/this-is-the.shit.git' }
65
- it { is_expected.to eq('reenhanced.spectacular') }
64
+ let(:origin_url) { "https://github.com/reenhanced.spectacular/this-is-the.shit.git" }
65
+ it { is_expected.to eq("reenhanced.spectacular") }
66
66
  end
67
67
  end
68
68
 
69
69
  describe ".remote_repo_name" do
70
70
  subject { Gitacular.remote_repo_name }
71
71
 
72
- it { is_expected.to eq('this-is-the.shit') }
72
+ it { is_expected.to eq("this-is-the.shit") }
73
73
 
74
74
  context "remote origin url isn't set" do
75
- let(:origin_url) { '' }
76
- it { is_expected.to eq('') }
75
+ let(:origin_url) { "" }
76
+ it { is_expected.to eq("") }
77
77
  end
78
78
 
79
79
  context "remote origin uses HTTP" do
80
- let(:origin_url) { 'https://github.com/reenhanced.spectacular/this-is-the.shit.git' }
81
- it { is_expected.to eq('this-is-the.shit') }
80
+ let(:origin_url) { "https://github.com/reenhanced.spectacular/this-is-the.shit.git" }
81
+ it { is_expected.to eq("this-is-the.shit") }
82
82
  end
83
83
  end
84
84
 
85
- describe '.default_base_branch' do
85
+ describe ".default_base_branch" do
86
86
  subject { Gitacular.default_base_branch }
87
- it { is_expected.to eq('master') }
87
+ it { is_expected.to eq("master") }
88
88
 
89
- context 'when configured' do
90
- before { allow(GitReflow::Config).to receive(:get).with('reflow.base-branch').and_return('tuba') }
91
- it { is_expected.to eq('tuba') }
89
+ context "when configured" do
90
+ before { allow(GitReflow::Config).to receive(:get).with("reflow.base-branch").and_return("tuba") }
91
+ it { is_expected.to eq("tuba") }
92
92
  end
93
93
  end
94
94
 
95
95
  describe ".current_branch" do
96
96
  subject { Gitacular.current_branch }
97
- it { expect{ subject }.to have_run_command_silently "git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g'" }
97
+ it {
98
+ expect { subject }
99
+ .to have_run_command_silently "git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g'"
100
+ }
98
101
  end
99
102
 
100
103
  describe ".pull_request_template" do
@@ -119,36 +122,29 @@ describe GitReflow::GitHelpers do
119
122
 
120
123
  it { is_expected.to be_nil }
121
124
  end
122
- end
123
-
124
- describe ".pull_request_template" do
125
- subject { Gitacular.pull_request_template }
126
-
127
- context "template file exists" do
128
- let(:root_dir) { "/some_repo" }
129
- let(:template_content) { "Template content" }
130
125
 
126
+ context "custom template file configured" do
131
127
  before do
132
- allow(Gitacular).to receive(:git_root_dir).and_return(root_dir)
133
- allow(File).to receive(:exist?).with("#{root_dir}/.github/PULL_REQUEST_TEMPLATE.md").and_return(true)
134
- allow(File).to receive(:read).with("#{root_dir}/.github/PULL_REQUEST_TEMPLATE.md").and_return(template_content)
128
+ allow(GitReflow::Config).to receive(:get).with("templates.pull-request").and_return "pr_template_file.md"
135
129
  end
136
130
 
137
- it { is_expected.to eq template_content }
131
+ context "template file exists" do
132
+ let(:template_content) { "Template content" }
138
133
 
139
- context "when template has mustache tags" do
140
- let(:template_content) { "This is the coolest {{current_branch}}" }
141
- before { allow(GitReflow).to receive(:current_branch).and_return("tomato") }
142
- it { is_expected.to eq "This is the coolest tomato" }
134
+ before do
135
+ allow(File).to receive(:exist?).with("pr_template_file.md").and_return(true)
136
+ allow(File).to receive(:read).with("pr_template_file.md").and_return(template_content)
137
+ end
138
+ it { is_expected.to eq template_content }
143
139
  end
144
- end
145
140
 
146
- context "template file does not exist" do
147
- before do
148
- allow(File).to receive(:exist?).and_return(false)
149
- end
141
+ context "template file does not exist" do
142
+ before do
143
+ allow(File).to receive(:exist?).and_return(false)
144
+ end
150
145
 
151
- it { is_expected.to be_nil }
146
+ it { is_expected.to be_nil }
147
+ end
152
148
  end
153
149
  end
154
150
 
@@ -181,27 +177,51 @@ describe GitReflow::GitHelpers do
181
177
 
182
178
  it { is_expected.to be_nil }
183
179
  end
180
+
181
+ context "custom template file configured" do
182
+ before do
183
+ allow(GitReflow::Config).to receive(:get).with("templates.merge-commit").and_return "merge_template_file.md"
184
+ end
185
+
186
+ context "template file exists" do
187
+ let(:template_content) { "Template content" }
188
+
189
+ before do
190
+ allow(File).to receive(:exist?).with("merge_template_file.md").and_return(true)
191
+ allow(File).to receive(:read).with("merge_template_file.md").and_return(template_content)
192
+ end
193
+ it { is_expected.to eq template_content }
194
+ end
195
+
196
+ context "template file does not exist" do
197
+ before do
198
+ allow(File).to receive(:exist?).and_return(false)
199
+ end
200
+
201
+ it { is_expected.to be_nil }
202
+ end
203
+ end
184
204
  end
185
205
 
186
206
  describe ".get_first_commit_message" do
187
207
  subject { Gitacular.get_first_commit_message }
188
- it { expect{ subject }.to have_run_command_silently 'git log --pretty=format:"%s" --no-merges -n 1' }
208
+ it { expect { subject }.to have_run_command_silently 'git log --pretty=format:"%s" --no-merges -n 1' }
189
209
  end
190
210
 
191
211
  describe ".push_current_branch" do
192
212
  subject { Gitacular.push_current_branch }
193
- before { allow(Gitacular).to receive(:current_branch).and_return('bingo') }
194
- it { expect{ subject }.to have_run_command "git push origin bingo" }
213
+ before { allow(Gitacular).to receive(:current_branch).and_return("bingo") }
214
+ it { expect { subject }.to have_run_command "git push origin bingo" }
195
215
  end
196
216
 
197
217
  describe ".fetch_destination(destination_branch)" do
198
- subject { Gitacular.fetch_destination('new-feature') }
199
- it { expect{ subject }.to have_run_command "git fetch origin new-feature" }
218
+ subject { Gitacular.fetch_destination("new-feature") }
219
+ it { expect { subject }.to have_run_command "git fetch origin new-feature" }
200
220
  end
201
221
 
202
222
  describe ".update_destination(destination_branch)" do
203
- let(:current_branch) { 'bananas' }
204
- let(:destination_branch) { 'monkey-business' }
223
+ let(:current_branch) { "bananas" }
224
+ let(:destination_branch) { "monkey-business" }
205
225
 
206
226
  before { allow(Gitacular).to receive(:current_branch).and_return(current_branch) }
207
227
  subject { Gitacular.update_destination(destination_branch) }
@@ -217,7 +237,7 @@ describe GitReflow::GitHelpers do
217
237
 
218
238
  describe ".update_current_branch" do
219
239
  subject { Gitacular.update_current_branch }
220
- before { allow(Gitacular).to receive(:current_branch).and_return('new-feature') }
240
+ before { allow(Gitacular).to receive(:current_branch).and_return("new-feature") }
221
241
 
222
242
  it "updates the remote changes and pushes any local changes" do
223
243
  expect { subject }.to have_run_commands_in_order [
@@ -228,9 +248,9 @@ describe GitReflow::GitHelpers do
228
248
  end
229
249
 
230
250
  describe ".update_feature_branch" do
231
- options = {base: "base", remote: "remote"}
251
+ options = { base: "base", remote: "remote" }
232
252
  subject { Gitacular.update_feature_branch(options) }
233
- before { allow(Gitacular).to receive(:current_branch).and_return('feature') }
253
+ before { allow(Gitacular).to receive(:current_branch).and_return("feature") }
234
254
 
235
255
  it "calls the correct methods" do
236
256
  expect { subject }.to have_run_commands_in_order [
@@ -246,14 +266,14 @@ describe GitReflow::GitHelpers do
246
266
  describe ".append_to_merge_commit_message(message)" do
247
267
  let(:original_commit_message) { "Oooooo, SQUASH IT" }
248
268
  let(:message) { "do do the voodoo that you do" }
249
- let(:root_dir) { '/home/gitreflow' }
269
+ let(:root_dir) { "/home/gitreflow" }
250
270
  let(:merge_message_path) { "#{root_dir}/.git/SQUASH_MSG" }
251
271
  let(:tmp_merge_message_path) { "#{root_dir}/.git/tmp_merge_msg" }
252
272
  before { allow(Gitacular).to receive(:git_root_dir).and_return(root_dir) }
253
273
  subject { Gitacular.append_to_merge_commit_message(message) }
254
274
 
255
275
  it "appends the message to git's SQUASH_MSG temp file" do
256
- tmp_file = double('file')
276
+ tmp_file = double("file")
257
277
  allow(File).to receive(:open).with(tmp_merge_message_path, "w").and_yield(tmp_file)
258
278
  allow(File).to receive(:exists?).with(merge_message_path).and_return(true)
259
279
  allow(File).to receive(:foreach).with(merge_message_path).and_yield(original_commit_message)
@@ -269,7 +289,7 @@ describe GitReflow::GitHelpers do
269
289
  let(:merge_message_path) { "#{root_dir}/.git/MERGE_MSG" }
270
290
  subject { Gitacular.append_to_merge_commit_message(message, merge_method: "merge") }
271
291
  it "appends the message to git's MERGE_MSG temp file if using a direct merge" do
272
- tmp_file = double('file')
292
+ tmp_file = double("file")
273
293
  allow(File).to receive(:open).with(tmp_merge_message_path, "w").and_yield(tmp_file)
274
294
  allow(File).to receive(:exists?).with(merge_message_path).and_return(true)
275
295
  allow(File).to receive(:foreach).with(merge_message_path).and_yield(original_commit_message)
@@ -100,7 +100,7 @@ describe GitReflow::GitServer::GitHub::PullRequest do
100
100
  context "Testing Nil Comments" do
101
101
  before do
102
102
  stub_request(:get, "https://api.github.com/repos/reenhanced/repo/pulls/2/comments?access_token=a1b2c3d4e5f6g7h8i9j0").
103
- with(:headers => {'Accept'=>'application/vnd.github.v3+json,application/vnd.github.beta+json;q=0.5,application/json;q=0.1', 'Accept-Charset'=>'utf-8', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'token a1b2c3d4e5f6g7h8i9j0', 'User-Agent'=>'Github API Ruby Gem 0.18.2'}).
103
+ with(:headers => {'Accept'=>'application/vnd.github.v3+json,application/vnd.github.beta+json;q=0.5,application/json;q=0.1', 'Accept-Charset'=>'utf-8', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'token a1b2c3d4e5f6g7h8i9j0', 'User-Agent'=>'Github API Ruby Gem 0.19.0'}).
104
104
  to_return(:status => 200, :body => "", :headers => {})
105
105
 
106
106
  FakeGitHub.new(
@@ -491,14 +491,42 @@ describe GitReflow::GitServer::PullRequest do
491
491
  allow(GitReflow::Config).to receive(:get).with('reflow.always-cleanup').and_return('false')
492
492
  end
493
493
 
494
- context "and user chooses to cleanup" do
495
- before { expect(pr).to receive(:ask).with('Would you like to push this branch to your remote repo and cleanup your feature branch? ').and_return('yes') }
494
+ context "and always cleanup local config is set" do
495
+ end
496
+
497
+ context "and always cleanup remote config is set" do
498
+ end
499
+
500
+ context "and user chooses to cleanup local only" do
501
+ before do
502
+ expect(pr).to receive(:ask).with('Would you like to cleanup your local feature branch? ').and_return('yes')
503
+ allow(pr).to receive(:ask).with('Would you like to cleanup your remote feature branch? ').and_return('no')
504
+ end
505
+ it { should be_truthy }
506
+ end
507
+
508
+ context "and user chooses to cleanup remote only" do
509
+ before do
510
+ expect(pr).to receive(:ask).with('Would you like to cleanup your local feature branch? ').and_return('no')
511
+ expect(pr).to receive(:ask).with('Would you like to cleanup your remote feature branch? ').and_return('yes')
512
+ end
496
513
  it { should be_truthy }
497
514
  end
498
515
 
499
- context "and user chooses not to cleanup" do
500
- before { expect(pr).to receive(:ask).with('Would you like to push this branch to your remote repo and cleanup your feature branch? ').and_return('no') }
501
- it { should be_falsy }
516
+ context "and user chooses to cleanup local and remote" do
517
+ before do
518
+ allow(pr).to receive(:ask).with('Would you like to cleanup your local feature branch? ').and_return('yes')
519
+ allow(pr).to receive(:ask).with('Would you like to cleanup your remote feature branch? ').and_return('yes')
520
+ end
521
+ it { should be_truthy }
522
+ end
523
+
524
+ context "and user chooses to cleanup neither local nor remote" do
525
+ before do
526
+ expect(pr).to receive(:ask).with('Would you like to cleanup your local feature branch? ').and_return('no')
527
+ allow(pr).to receive(:ask).with('Would you like to cleanup your remote feature branch? ').and_return('no')
528
+ end
529
+ it { should be_falsey }
502
530
  end
503
531
  end
504
532
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe GitReflow do
4
-
5
4
  describe ".logger" do
6
5
  # Ignore memoization for tests
7
6
  before { GitReflow.instance_variable_set("@logger", nil) }
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'rspec'
3
+ require 'ruby_jard'
3
4
  require 'multi_json'
4
5
  require 'webmock/rspec'
5
- require 'pry'
6
6
 
7
7
  $LOAD_PATH << 'lib'
8
8
  require 'git_reflow'
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_reflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentino Stoll
8
8
  - Robert Stern
9
9
  - Nicholas Hance
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2020-06-02 00:00:00.000000000 Z
13
+ date: 2022-02-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: appraisal
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.2.0
21
+ version: 2.4.0
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 2.2.0
28
+ version: 2.4.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: chronic
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -55,7 +55,7 @@ dependencies:
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
- name: pry-byebug
58
+ name: ruby_jard
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
@@ -74,14 +74,14 @@ dependencies:
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: 13.0.1
77
+ version: 13.0.3
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: 13.0.1
84
+ version: 13.0.3
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rdoc
87
87
  requirement: !ruby/object:Gem::Requirement
@@ -102,14 +102,14 @@ dependencies:
102
102
  requirements:
103
103
  - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: '3.9'
105
+ version: '3.10'
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: '3.9'
112
+ version: '3.10'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: webmock
115
115
  requirement: !ruby/object:Gem::Requirement
@@ -172,28 +172,28 @@ dependencies:
172
172
  requirements:
173
173
  - - ">="
174
174
  - !ruby/object:Gem::Version
175
- version: 0.7.0
175
+ version: 0.8.1
176
176
  type: :runtime
177
177
  prerelease: false
178
178
  version_requirements: !ruby/object:Gem::Requirement
179
179
  requirements:
180
180
  - - ">="
181
181
  - !ruby/object:Gem::Version
182
- version: 0.7.0
182
+ version: 0.8.1
183
183
  - !ruby/object:Gem::Dependency
184
184
  name: github_api
185
185
  requirement: !ruby/object:Gem::Requirement
186
186
  requirements:
187
187
  - - '='
188
188
  - !ruby/object:Gem::Version
189
- version: 0.18.2
189
+ version: '0.19'
190
190
  type: :runtime
191
191
  prerelease: false
192
192
  version_requirements: !ruby/object:Gem::Requirement
193
193
  requirements:
194
194
  - - '='
195
195
  - !ruby/object:Gem::Version
196
- version: 0.18.2
196
+ version: '0.19'
197
197
  - !ruby/object:Gem::Dependency
198
198
  name: highline
199
199
  requirement: !ruby/object:Gem::Requirement
@@ -335,8 +335,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
335
335
  - !ruby/object:Gem::Version
336
336
  version: '0'
337
337
  requirements: []
338
- rubygems_version: 3.1.2
339
- signing_key:
338
+ rubygems_version: 3.2.3
339
+ signing_key:
340
340
  specification_version: 4
341
341
  summary: A better git process
342
342
  test_files: