git_reflow 0.8.9 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/multi-ruby-tests.yml +33 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +2 -0
  5. data/.ruby-version +1 -0
  6. data/Appraisals +1 -6
  7. data/CHANGELOG.md +466 -348
  8. data/Gemfile.lock +99 -72
  9. data/LICENSE +20 -20
  10. data/README.md +481 -0
  11. data/Rakefile +15 -8
  12. data/Workflow +3 -0
  13. data/_config.yml +1 -0
  14. data/bin/console +7 -7
  15. data/bin/setup +6 -6
  16. data/exe/git-reflow +20 -36
  17. data/git_reflow.gemspec +26 -30
  18. data/lib/git_reflow.rb +3 -15
  19. data/lib/git_reflow/config.rb +48 -13
  20. data/lib/git_reflow/git_helpers.rb +69 -22
  21. data/lib/git_reflow/git_server.rb +63 -63
  22. data/lib/git_reflow/git_server/base.rb +68 -68
  23. data/lib/git_reflow/git_server/bit_bucket.rb +101 -101
  24. data/lib/git_reflow/git_server/bit_bucket/pull_request.rb +84 -84
  25. data/lib/git_reflow/git_server/git_hub.rb +53 -41
  26. data/lib/git_reflow/git_server/git_hub/pull_request.rb +16 -14
  27. data/lib/git_reflow/git_server/pull_request.rb +4 -2
  28. data/lib/git_reflow/merge_error.rb +9 -9
  29. data/lib/git_reflow/rspec.rb +3 -2
  30. data/lib/git_reflow/rspec/command_line_helpers.rb +23 -6
  31. data/lib/git_reflow/rspec/stub_helpers.rb +13 -13
  32. data/lib/git_reflow/rspec/workflow_helpers.rb +18 -0
  33. data/lib/git_reflow/sandbox.rb +16 -6
  34. data/lib/git_reflow/version.rb +1 -1
  35. data/lib/git_reflow/workflow.rb +304 -9
  36. data/lib/git_reflow/workflows/FlatMergeWorkflow +38 -0
  37. data/lib/git_reflow/workflows/core.rb +364 -238
  38. data/spec/fixtures/authentication_failure.json +3 -0
  39. data/spec/fixtures/awesome_workflow.rb +3 -7
  40. data/spec/fixtures/git/git_config +7 -7
  41. data/spec/fixtures/issues/comment.json.erb +27 -27
  42. data/spec/fixtures/issues/comments.json +29 -29
  43. data/spec/fixtures/issues/comments.json.erb +15 -15
  44. data/spec/fixtures/pull_requests/comment.json.erb +45 -45
  45. data/spec/fixtures/pull_requests/comments.json +47 -47
  46. data/spec/fixtures/pull_requests/comments.json.erb +15 -15
  47. data/spec/fixtures/pull_requests/commits.json +29 -29
  48. data/spec/fixtures/pull_requests/external_pull_request.json +145 -145
  49. data/spec/fixtures/pull_requests/pull_request.json +142 -142
  50. data/spec/fixtures/pull_requests/pull_request.json.erb +142 -142
  51. data/spec/fixtures/pull_requests/pull_request_branch_nonexistent_error.json +32 -0
  52. data/spec/fixtures/pull_requests/pull_request_exists_error.json +32 -32
  53. data/spec/fixtures/pull_requests/pull_requests.json +136 -136
  54. data/spec/fixtures/repositories/commit.json +53 -53
  55. data/spec/fixtures/repositories/commit.json.erb +53 -53
  56. data/spec/fixtures/repositories/commits.json.erb +13 -13
  57. data/spec/fixtures/repositories/statuses.json +31 -31
  58. data/spec/fixtures/users/user.json +32 -0
  59. data/spec/lib/git_reflow/git_helpers_spec.rb +115 -12
  60. data/spec/lib/git_reflow/git_server/bit_bucket_spec.rb +81 -81
  61. data/spec/lib/git_reflow/git_server/git_hub/pull_request_spec.rb +10 -10
  62. data/spec/lib/git_reflow/git_server/git_hub_spec.rb +77 -3
  63. data/spec/lib/git_reflow/git_server/pull_request_spec.rb +9 -3
  64. data/spec/lib/git_reflow/git_server_spec.rb +101 -101
  65. data/spec/lib/git_reflow/sandbox_spec.rb +1 -1
  66. data/spec/lib/git_reflow/workflow_spec.rb +304 -59
  67. data/spec/lib/git_reflow/workflows/core_spec.rb +225 -67
  68. data/spec/lib/git_reflow/workflows/flat_merge_spec.rb +71 -59
  69. data/spec/lib/git_reflow_spec.rb +2 -25
  70. data/spec/spec_helper.rb +3 -0
  71. data/spec/support/fixtures.rb +54 -54
  72. data/spec/support/github_helpers.rb +99 -109
  73. data/spec/support/mock_pull_request.rb +17 -17
  74. data/spec/support/web_mocks.rb +39 -39
  75. metadata +51 -74
  76. data/README.rdoc +0 -461
  77. data/circle.yml +0 -26
  78. data/lib/git_reflow/commands/deliver.rb +0 -10
  79. data/lib/git_reflow/commands/refresh.rb +0 -20
  80. data/lib/git_reflow/commands/review.rb +0 -13
  81. data/lib/git_reflow/commands/setup.rb +0 -11
  82. data/lib/git_reflow/commands/stage.rb +0 -9
  83. data/lib/git_reflow/commands/start.rb +0 -18
  84. data/lib/git_reflow/commands/status.rb +0 -7
  85. data/lib/git_reflow/os_detector.rb +0 -23
  86. data/lib/git_reflow/workflows/flat_merge.rb +0 -10
  87. data/spec/fixtures/workflow_with_super.rb +0 -8
@@ -1,53 +1,53 @@
1
- {
2
- "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
3
- "commit": {
4
- "url": "https://api.github.com/repos/reenhanced/repo/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
5
- "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
6
- "author": {
7
- "name": "Monalisa Octocat",
8
- "email": "support@github.com",
9
- "date": "2011-04-14T16:00:49Z"
10
- },
11
- "committer": {
12
- "name": "Monalisa Octocat",
13
- "email": "support@github.com",
14
- "date": "2011-04-14T16:00:49Z"
15
- },
16
- "message": "Fix all the bugs",
17
- "tree": {
18
- "url": "https://api.github.com/repos/reenhanced/repo/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e",
19
- "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
20
- }
21
- },
22
- "author": {
23
- "login": "reenhanced",
24
- "id": 1,
25
- "avatar_url": "https://github.com/images/error/octocat_happy.gif",
26
- "url": "https://api.github.com/users/reenhanced"
27
- },
28
- "committer": {
29
- "login": "reenhanced",
30
- "id": 1,
31
- "avatar_url": "https://github.com/images/error/octocat_happy.gif",
32
- "url": "https://api.github.com/users/reenhanced"
33
- },
34
- "parents": [
35
- {
36
- "url": "https://api.github.com/repos/reenhanced/repo/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
37
- "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
38
- }
39
- ],
40
- "stats": {
41
- "additions": 104,
42
- "deletions": 4,
43
- "total": 108
44
- },
45
- "files": [
46
- {
47
- "filename": "file1.txt",
48
- "additions": 10,
49
- "deletions": 2,
50
- "total": 12
51
- }
52
- ]
53
- }
1
+ {
2
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
3
+ "commit": {
4
+ "url": "https://api.github.com/repos/reenhanced/repo/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
5
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
6
+ "author": {
7
+ "name": "Monalisa Octocat",
8
+ "email": "support@github.com",
9
+ "date": "2011-04-14T16:00:49Z"
10
+ },
11
+ "committer": {
12
+ "name": "Monalisa Octocat",
13
+ "email": "support@github.com",
14
+ "date": "2011-04-14T16:00:49Z"
15
+ },
16
+ "message": "Fix all the bugs",
17
+ "tree": {
18
+ "url": "https://api.github.com/repos/reenhanced/repo/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e",
19
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
20
+ }
21
+ },
22
+ "author": {
23
+ "login": "reenhanced",
24
+ "id": 1,
25
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
26
+ "url": "https://api.github.com/users/reenhanced"
27
+ },
28
+ "committer": {
29
+ "login": "reenhanced",
30
+ "id": 1,
31
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
32
+ "url": "https://api.github.com/users/reenhanced"
33
+ },
34
+ "parents": [
35
+ {
36
+ "url": "https://api.github.com/repos/reenhanced/repo/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
37
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
38
+ }
39
+ ],
40
+ "stats": {
41
+ "additions": 104,
42
+ "deletions": 4,
43
+ "total": 108
44
+ },
45
+ "files": [
46
+ {
47
+ "filename": "file1.txt",
48
+ "additions": 10,
49
+ "deletions": 2,
50
+ "total": 12
51
+ }
52
+ ]
53
+ }
@@ -1,53 +1,53 @@
1
- {
2
- "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
3
- "commit": {
4
- "url": "https://api.github.com/repos/<%= repo_owner %>/<%= repo_name %>/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
5
- "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
6
- "author": {
7
- "name": "Monalisa Octocat",
8
- "email": "support@github.com",
9
- "date": "<%= created_at || "2011-04-14T16:00:49Z" %>"
10
- },
11
- "committer": {
12
- "name": "Monalisa Octocat",
13
- "email": "support@github.com",
14
- "date": "<%= created_at || "2011-04-14T16:00:49Z" %>"
15
- },
16
- "message": "Fix all the bugs",
17
- "tree": {
18
- "url": "https://api.github.com/repos/<%= repo_owner %>/<%= repo_name %>/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e",
19
- "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
20
- }
21
- },
22
- "author": {
23
- "login": "<%= author %>",
24
- "id": 1,
25
- "avatar_url": "https://github.com/images/error/octocat_happy.gif",
26
- "url": "https://api.github.com/users/<%= author %>"
27
- },
28
- "committer": {
29
- "login": "<%= author %>",
30
- "id": 1,
31
- "avatar_url": "https://github.com/images/error/octocat_happy.gif",
32
- "url": "https://api.github.com/users/<%= author %>"
33
- },
34
- "parents": [
35
- {
36
- "url": "https://api.github.com/repos/<%= repo_owner %>/<%= repo_name %>/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
37
- "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
38
- }
39
- ],
40
- "stats": {
41
- "additions": 104,
42
- "deletions": 4,
43
- "total": 108
44
- },
45
- "files": [
46
- {
47
- "filename": "file1.txt",
48
- "additions": 10,
49
- "deletions": 2,
50
- "total": 12
51
- }
52
- ]
53
- }
1
+ {
2
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
3
+ "commit": {
4
+ "url": "https://api.github.com/repos/<%= repo_owner %>/<%= repo_name %>/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
5
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
6
+ "author": {
7
+ "name": "Monalisa Octocat",
8
+ "email": "support@github.com",
9
+ "date": "<%= created_at || "2011-04-14T16:00:49Z" %>"
10
+ },
11
+ "committer": {
12
+ "name": "Monalisa Octocat",
13
+ "email": "support@github.com",
14
+ "date": "<%= created_at || "2011-04-14T16:00:49Z" %>"
15
+ },
16
+ "message": "Fix all the bugs",
17
+ "tree": {
18
+ "url": "https://api.github.com/repos/<%= repo_owner %>/<%= repo_name %>/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e",
19
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
20
+ }
21
+ },
22
+ "author": {
23
+ "login": "<%= author %>",
24
+ "id": 1,
25
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
26
+ "url": "https://api.github.com/users/<%= author %>"
27
+ },
28
+ "committer": {
29
+ "login": "<%= author %>",
30
+ "id": 1,
31
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
32
+ "url": "https://api.github.com/users/<%= author %>"
33
+ },
34
+ "parents": [
35
+ {
36
+ "url": "https://api.github.com/repos/<%= repo_owner %>/<%= repo_name %>/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
37
+ "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
38
+ }
39
+ ],
40
+ "stats": {
41
+ "additions": 104,
42
+ "deletions": 4,
43
+ "total": 108
44
+ },
45
+ "files": [
46
+ {
47
+ "filename": "file1.txt",
48
+ "additions": 10,
49
+ "deletions": 2,
50
+ "total": 12
51
+ }
52
+ ]
53
+ }
@@ -1,13 +1,13 @@
1
- [
2
- <% commits_json = [] %>
3
- <% commits.each_with_index do |commit, index| %>
4
- <% commits_json << Fixture.new('repositories/commit.json.erb',
5
- id: index,
6
- author: commit[:author],
7
- repo_owner: repo_owner,
8
- repo_name: repo_name,
9
- created_at: commit[:created_at] || Chronic.parse("October 21, 2015 07:28:00")
10
- ).to_s %>
11
- <% end %>
12
- <%= commits_json.join(", ") %>
13
- ]
1
+ [
2
+ <% commits_json = [] %>
3
+ <% commits.each_with_index do |commit, index| %>
4
+ <% commits_json << Fixture.new('repositories/commit.json.erb',
5
+ id: index,
6
+ author: commit[:author],
7
+ repo_owner: repo_owner,
8
+ repo_name: repo_name,
9
+ created_at: commit[:created_at] || Chronic.parse("October 21, 2015 07:28:00")
10
+ ).to_s %>
11
+ <% end %>
12
+ <%= commits_json.join(", ") %>
13
+ ]
@@ -1,31 +1,31 @@
1
- [
2
- {
3
- "created_at": "2012-07-20T01:19:13Z",
4
- "updated_at": "2012-07-20T01:19:13Z",
5
- "state": "success",
6
- "target_url": "https://ci.example.com/1000/output",
7
- "description": "Build has completed successfully",
8
- "id": 1,
9
- "url": "https://api.github.com/repos/reenhanced/example/statuses/1",
10
- "context": "continuous-integration/jenkins",
11
- "creator": {
12
- "login": "reenhanced",
13
- "id": 1,
14
- "avatar_url": "https://github.com/images/error/octocat_happy.gif",
15
- "gravatar_id": "somehexcode",
16
- "url": "https://api.github.com/users/reenhanced",
17
- "html_url": "https://github.com/reenhanced",
18
- "followers_url": "https://api.github.com/users/reenhanced/followers",
19
- "following_url": "https://api.github.com/users/reenhanced/following{/other_user}",
20
- "gists_url": "https://api.github.com/users/reenhanced/gists{/gist_id}",
21
- "starred_url": "https://api.github.com/users/reenhanced/starred{/owner}{/repo}",
22
- "subscriptions_url": "https://api.github.com/users/reenhanced/subscriptions",
23
- "organizations_url": "https://api.github.com/users/reenhanced/orgs",
24
- "repos_url": "https://api.github.com/users/reenhanced/repos",
25
- "events_url": "https://api.github.com/users/reenhanced/events{/privacy}",
26
- "received_events_url": "https://api.github.com/users/reenhanced/received_events",
27
- "type": "User",
28
- "site_admin": false
29
- }
30
- }
31
- ]
1
+ [
2
+ {
3
+ "created_at": "2012-07-20T01:19:13Z",
4
+ "updated_at": "2012-07-20T01:19:13Z",
5
+ "state": "success",
6
+ "target_url": "https://ci.example.com/1000/output",
7
+ "description": "Build has completed successfully",
8
+ "id": 1,
9
+ "url": "https://api.github.com/repos/reenhanced/example/statuses/1",
10
+ "context": "continuous-integration/jenkins",
11
+ "creator": {
12
+ "login": "reenhanced",
13
+ "id": 1,
14
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
15
+ "gravatar_id": "somehexcode",
16
+ "url": "https://api.github.com/users/reenhanced",
17
+ "html_url": "https://github.com/reenhanced",
18
+ "followers_url": "https://api.github.com/users/reenhanced/followers",
19
+ "following_url": "https://api.github.com/users/reenhanced/following{/other_user}",
20
+ "gists_url": "https://api.github.com/users/reenhanced/gists{/gist_id}",
21
+ "starred_url": "https://api.github.com/users/reenhanced/starred{/owner}{/repo}",
22
+ "subscriptions_url": "https://api.github.com/users/reenhanced/subscriptions",
23
+ "organizations_url": "https://api.github.com/users/reenhanced/orgs",
24
+ "repos_url": "https://api.github.com/users/reenhanced/repos",
25
+ "events_url": "https://api.github.com/users/reenhanced/events{/privacy}",
26
+ "received_events_url": "https://api.github.com/users/reenhanced/received_events",
27
+ "type": "User",
28
+ "site_admin": false
29
+ }
30
+ }
31
+ ]
@@ -0,0 +1,32 @@
1
+ {
2
+ "login": "reenhanced",
3
+ "id": 1,
4
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
5
+ "gravatar_id": "somehexcode",
6
+ "url": "https://api.github.com/users/reenhanced",
7
+ "name": "monalisa octocat",
8
+ "company": "GitHub",
9
+ "blog": "https://github.com/blog",
10
+ "location": "San Francisco",
11
+ "email": "octocat@github.com",
12
+ "hireable": false,
13
+ "bio": "There once was...",
14
+ "public_repos": 2,
15
+ "public_gists": 1,
16
+ "followers": 20,
17
+ "following": 0,
18
+ "html_url": "https://github.com/reenhanced",
19
+ "created_at": "2008-01-14T04:33:35Z",
20
+ "type": "User",
21
+ "total_private_repos": 100,
22
+ "owned_private_repos": 100,
23
+ "private_gists": 81,
24
+ "disk_usage": 10000,
25
+ "collaborators": 8,
26
+ "plan": {
27
+ "name": "Medium",
28
+ "space": 400,
29
+ "collaborators": 10,
30
+ "private_repos": 20
31
+ }
32
+ }
@@ -14,6 +14,20 @@ describe GitReflow::GitHelpers do
14
14
  stub_run_for Gitacular
15
15
  end
16
16
 
17
+ describe ".default_editor" do
18
+ subject { Gitacular.default_editor }
19
+
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') }
23
+ end
24
+
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') }
28
+ end
29
+ end
30
+
17
31
  describe ".git_root_dir" do
18
32
  subject { Gitacular.git_root_dir }
19
33
  it { expect{ subject }.to have_run_command_silently "git rev-parse --show-toplevel" }
@@ -42,7 +56,7 @@ describe GitReflow::GitHelpers do
42
56
  it { is_expected.to eq('reenhanced.spectacular') }
43
57
 
44
58
  context "remote origin url isn't set" do
45
- let(:origin_url) { nil }
59
+ let(:origin_url) { '' }
46
60
  it { is_expected.to eq('') }
47
61
  end
48
62
 
@@ -58,7 +72,7 @@ describe GitReflow::GitHelpers do
58
72
  it { is_expected.to eq('this-is-the.shit') }
59
73
 
60
74
  context "remote origin url isn't set" do
61
- let(:origin_url) { nil }
75
+ let(:origin_url) { '' }
62
76
  it { is_expected.to eq('') }
63
77
  end
64
78
 
@@ -68,6 +82,16 @@ describe GitReflow::GitHelpers do
68
82
  end
69
83
  end
70
84
 
85
+ describe '.default_base_branch' do
86
+ subject { Gitacular.default_base_branch }
87
+ it { is_expected.to eq('master') }
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') }
92
+ end
93
+ end
94
+
71
95
  describe ".current_branch" do
72
96
  subject { Gitacular.current_branch }
73
97
  it { expect{ subject }.to have_run_command_silently "git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g'" }
@@ -97,6 +121,68 @@ describe GitReflow::GitHelpers do
97
121
  end
98
122
  end
99
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
+
131
+ 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)
135
+ end
136
+
137
+ it { is_expected.to eq template_content }
138
+
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" }
143
+ end
144
+ end
145
+
146
+ context "template file does not exist" do
147
+ before do
148
+ allow(File).to receive(:exist?).and_return(false)
149
+ end
150
+
151
+ it { is_expected.to be_nil }
152
+ end
153
+ end
154
+
155
+ describe ".merge_commit_template" do
156
+ subject { Gitacular.merge_commit_template }
157
+
158
+ context "template file exists" do
159
+ let(:root_dir) { "/some_repo" }
160
+ let(:template_content) { "Template content" }
161
+
162
+ before do
163
+ allow(Gitacular).to receive(:git_root_dir).and_return(root_dir)
164
+ allow(File).to receive(:exist?).with("#{root_dir}/.github/MERGE_COMMIT_TEMPLATE.md").and_return(true)
165
+ allow(File).to receive(:read).with("#{root_dir}/.github/MERGE_COMMIT_TEMPLATE.md").and_return(template_content)
166
+ end
167
+
168
+ it { is_expected.to eq template_content }
169
+
170
+ context "when template has mustache tags" do
171
+ let(:template_content) { "This is the coolest {{current_branch}}" }
172
+ before { allow(GitReflow).to receive(:current_branch).and_return("tomato") }
173
+ it { is_expected.to eq "This is the coolest tomato" }
174
+ end
175
+ end
176
+
177
+ context "template file does not exist" do
178
+ before do
179
+ allow(File).to receive(:exist?).and_return(false)
180
+ end
181
+
182
+ it { is_expected.to be_nil }
183
+ end
184
+ end
185
+
100
186
  describe ".get_first_commit_message" do
101
187
  subject { Gitacular.get_first_commit_message }
102
188
  it { expect{ subject }.to have_run_command_silently 'git log --pretty=format:"%s" --no-merges -n 1' }
@@ -157,26 +243,43 @@ describe GitReflow::GitHelpers do
157
243
  end
158
244
  end
159
245
 
160
- describe ".append_to_squashed_commit_message(message)" do
161
- let(:original_squash_message) { "Oooooo, SQUASH IT" }
246
+ describe ".append_to_merge_commit_message(message)" do
247
+ let(:original_commit_message) { "Oooooo, SQUASH IT" }
162
248
  let(:message) { "do do the voodoo that you do" }
163
249
  let(:root_dir) { '/home/gitreflow' }
164
- let(:squash_path) { "#{root_dir}/.git/SQUASH_MSG" }
165
- let(:tmp_squash_path) { "#{root_dir}/.git/tmp_squash_msg" }
250
+ let(:merge_message_path) { "#{root_dir}/.git/SQUASH_MSG" }
251
+ let(:tmp_merge_message_path) { "#{root_dir}/.git/tmp_merge_msg" }
166
252
  before { allow(Gitacular).to receive(:git_root_dir).and_return(root_dir) }
167
- subject { Gitacular.append_to_squashed_commit_message(message) }
253
+ subject { Gitacular.append_to_merge_commit_message(message) }
168
254
 
169
255
  it "appends the message to git's SQUASH_MSG temp file" do
170
256
  tmp_file = double('file')
171
- allow(File).to receive(:open).with(tmp_squash_path, "w").and_yield(tmp_file)
172
- allow(File).to receive(:exists?).with(squash_path).and_return(true)
173
- allow(File).to receive(:foreach).with(squash_path).and_yield(original_squash_message)
257
+ allow(File).to receive(:open).with(tmp_merge_message_path, "w").and_yield(tmp_file)
258
+ allow(File).to receive(:exists?).with(merge_message_path).and_return(true)
259
+ allow(File).to receive(:foreach).with(merge_message_path).and_yield(original_commit_message)
174
260
  expect(tmp_file).to receive(:puts).with(message)
175
- expect(tmp_file).to receive(:puts).with(original_squash_message)
261
+ expect(tmp_file).to receive(:puts).with(original_commit_message)
176
262
 
177
263
  expect { subject }.to have_run_commands_in_order [
178
- "mv #{tmp_squash_path} #{squash_path}"
264
+ "mv #{tmp_merge_message_path} #{merge_message_path}"
179
265
  ]
180
266
  end
267
+
268
+ context "when doing a direct merge" do
269
+ let(:merge_message_path) { "#{root_dir}/.git/MERGE_MSG" }
270
+ subject { Gitacular.append_to_merge_commit_message(message, merge_method: "merge") }
271
+ it "appends the message to git's MERGE_MSG temp file if using a direct merge" do
272
+ tmp_file = double('file')
273
+ allow(File).to receive(:open).with(tmp_merge_message_path, "w").and_yield(tmp_file)
274
+ allow(File).to receive(:exists?).with(merge_message_path).and_return(true)
275
+ allow(File).to receive(:foreach).with(merge_message_path).and_yield(original_commit_message)
276
+ expect(tmp_file).to receive(:puts).with(message)
277
+ expect(tmp_file).to receive(:puts).with(original_commit_message)
278
+
279
+ expect { subject }.to have_run_commands_in_order [
280
+ "mv #{tmp_merge_message_path} #{merge_message_path}"
281
+ ]
282
+ end
283
+ end
181
284
  end
182
285
  end