git_reflow 0.8.10 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/multi-ruby-tests.yml +33 -0
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -1
- data/Appraisals +1 -6
- data/CHANGELOG.md +466 -348
- data/Gemfile.lock +100 -70
- data/LICENSE +20 -20
- data/README.md +36 -12
- data/Rakefile +15 -8
- data/Workflow +3 -0
- data/bin/console +7 -7
- data/bin/setup +6 -6
- data/exe/git-reflow +14 -30
- data/git_reflow.gemspec +25 -24
- data/lib/git_reflow.rb +3 -14
- data/lib/git_reflow/config.rb +52 -17
- data/lib/git_reflow/git_helpers.rb +69 -22
- data/lib/git_reflow/git_server/base.rb +68 -68
- data/lib/git_reflow/git_server/git_hub.rb +53 -40
- data/lib/git_reflow/git_server/git_hub/pull_request.rb +25 -17
- data/lib/git_reflow/git_server/pull_request.rb +19 -3
- data/lib/git_reflow/merge_error.rb +9 -9
- data/lib/git_reflow/rspec.rb +1 -0
- data/lib/git_reflow/rspec/command_line_helpers.rb +23 -6
- data/lib/git_reflow/rspec/stub_helpers.rb +13 -13
- data/lib/git_reflow/rspec/workflow_helpers.rb +18 -0
- data/lib/git_reflow/sandbox.rb +16 -6
- data/lib/git_reflow/version.rb +1 -1
- data/lib/git_reflow/workflow.rb +305 -10
- data/lib/git_reflow/workflows/FlatMergeWorkflow +38 -0
- data/lib/git_reflow/workflows/core.rb +208 -79
- data/spec/fixtures/authentication_failure.json +3 -0
- data/spec/fixtures/awesome_workflow.rb +2 -6
- data/spec/fixtures/git/git_config +7 -7
- data/spec/fixtures/issues/comment.json.erb +27 -27
- data/spec/fixtures/issues/comments.json +29 -29
- data/spec/fixtures/issues/comments.json.erb +15 -15
- data/spec/fixtures/pull_requests/comment.json.erb +45 -45
- data/spec/fixtures/pull_requests/comments.json +47 -47
- data/spec/fixtures/pull_requests/comments.json.erb +15 -15
- data/spec/fixtures/pull_requests/commits.json +29 -29
- data/spec/fixtures/pull_requests/external_pull_request.json +145 -145
- data/spec/fixtures/pull_requests/pull_request.json +142 -142
- data/spec/fixtures/pull_requests/pull_request.json.erb +142 -142
- data/spec/fixtures/pull_requests/pull_request_branch_nonexistent_error.json +32 -0
- data/spec/fixtures/pull_requests/pull_request_exists_error.json +32 -32
- data/spec/fixtures/pull_requests/pull_requests.json +136 -136
- data/spec/fixtures/repositories/commit.json +53 -53
- data/spec/fixtures/repositories/commit.json.erb +53 -53
- data/spec/fixtures/repositories/commits.json.erb +13 -13
- data/spec/fixtures/repositories/statuses.json +31 -31
- data/spec/fixtures/users/user.json +32 -0
- data/spec/lib/git_reflow/git_helpers_spec.rb +115 -12
- data/spec/lib/git_reflow/git_server/git_hub/pull_request_spec.rb +6 -6
- data/spec/lib/git_reflow/git_server/git_hub_spec.rb +77 -3
- data/spec/lib/git_reflow/git_server/pull_request_spec.rb +41 -7
- data/spec/lib/git_reflow/workflow_spec.rb +259 -14
- data/spec/lib/git_reflow/workflows/core_spec.rb +224 -65
- data/spec/lib/git_reflow/workflows/flat_merge_spec.rb +17 -6
- data/spec/lib/git_reflow_spec.rb +2 -25
- data/spec/spec_helper.rb +3 -0
- data/spec/support/github_helpers.rb +1 -1
- data/spec/support/mock_pull_request.rb +17 -17
- data/spec/support/web_mocks.rb +39 -39
- metadata +52 -53
- data/circle.yml +0 -26
- data/lib/git_reflow/commands/deliver.rb +0 -10
- data/lib/git_reflow/commands/refresh.rb +0 -20
- data/lib/git_reflow/commands/review.rb +0 -13
- data/lib/git_reflow/commands/setup.rb +0 -11
- data/lib/git_reflow/commands/stage.rb +0 -9
- data/lib/git_reflow/commands/start.rb +0 -18
- data/lib/git_reflow/commands/status.rb +0 -7
- data/lib/git_reflow/workflows/flat_merge.rb +0 -10
- 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) {
|
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) {
|
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 ".
|
161
|
-
let(:
|
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(:
|
165
|
-
let(:
|
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.
|
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(
|
172
|
-
allow(File).to receive(:exists?).with(
|
173
|
-
allow(File).to receive(:foreach).with(
|
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(
|
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 #{
|
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
|