toolshed 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +11 -0
- data/.toolshedrc.sample +32 -0
- data/README.md +159 -2
- data/Rakefile +3 -3
- data/bin/toolshed +6 -1
- data/lib/toolshed.rb +38 -28
- data/lib/toolshed/base.rb +33 -11
- data/lib/toolshed/cli.rb +30 -38
- data/lib/toolshed/client.rb +87 -293
- data/lib/toolshed/commands/base.rb +65 -23
- data/lib/toolshed/commands/checkout_branch.rb +15 -2
- data/lib/toolshed/commands/create_branch.rb +34 -29
- data/lib/toolshed/commands/create_pivotal_tracker_note.rb +9 -3
- data/lib/toolshed/commands/create_pull_request.rb +115 -68
- data/lib/toolshed/commands/create_ticket_comment.rb +17 -1
- data/lib/toolshed/commands/delete_branch.rb +34 -3
- data/lib/toolshed/commands/get_daily_time_update.rb +20 -3
- data/lib/toolshed/commands/list_branches.rb +16 -5
- data/lib/toolshed/commands/push_branch.rb +28 -9
- data/lib/toolshed/commands/rename_branch.rb +29 -0
- data/lib/toolshed/commands/ssh.rb +44 -3
- data/lib/toolshed/commands/ticket_information.rb +30 -4
- data/lib/toolshed/commands/update_pivotal_tracker_story_status.rb +9 -3
- data/lib/toolshed/commands/update_ticket_status.rb +8 -2
- data/lib/toolshed/entry_point.rb +89 -0
- data/lib/toolshed/git.rb +59 -0
- data/lib/toolshed/git/branch.rb +224 -0
- data/lib/toolshed/git/github.rb +45 -57
- data/lib/toolshed/git/validator.rb +14 -0
- data/lib/toolshed/logger.rb +46 -0
- data/lib/toolshed/password.rb +11 -6
- data/lib/toolshed/server_administration/ssh.rb +4 -2
- data/lib/toolshed/ticket_tracking/jira.rb +8 -6
- data/lib/toolshed/ticket_tracking/pivotal_tracker.rb +8 -6
- data/lib/toolshed/time_tracking/harvest.rb +8 -14
- data/lib/toolshed/version.rb +25 -1
- data/test/commands/checkout_branch_test.rb +11 -7
- data/test/commands/create_branch_test.rb +29 -24
- data/test/commands/create_pull_request_test.rb +39 -31
- data/test/commands/delete_branch_test.rb +35 -25
- data/test/commands/get_daily_time_update_test.rb +8 -8
- data/test/commands/push_branch_test.rb +27 -15
- data/test/commands/rename_branch_test.rb +59 -0
- data/test/git/git_helper.rb +5 -5
- data/test/git/git_test.rb +36 -31
- data/test/git/github_test.rb +9 -46
- data/test/helper.rb +11 -11
- data/test/server_administration/ssh_test.rb +1 -0
- data/test/ticket_tracking/jira_test.rb +18 -16
- data/test/time_tracking/harvest_test.rb +8 -6
- data/toolshed.gemspec +23 -20
- metadata +95 -46
- data/bin/toolshed.rb +0 -261
- data/lib/toolshed/git/git.rb +0 -119
@@ -3,16 +3,16 @@ require 'toolshed/commands/get_daily_time_update'
|
|
3
3
|
|
4
4
|
class GetDailyTimeUpdateTest < Test::Unit::TestCase
|
5
5
|
def self.startup
|
6
|
-
Toolshed::Client.time_tracking_tool = 'harvest'
|
7
|
-
Toolshed::Client.time_tracking_default_project_id = '1234'
|
8
|
-
Toolshed::Client.time_tracking_username = 'sample_username'
|
9
|
-
Toolshed::Client.time_tracking_password = 'sample1234'
|
10
|
-
Toolshed::Client.time_tracking_owner = 'me'
|
6
|
+
Toolshed::Client.instance.time_tracking_tool = 'harvest'
|
7
|
+
Toolshed::Client.instance.time_tracking_default_project_id = '1234'
|
8
|
+
Toolshed::Client.instance.time_tracking_username = 'sample_username'
|
9
|
+
Toolshed::Client.instance.time_tracking_password = 'sample1234'
|
10
|
+
Toolshed::Client.instance.time_tracking_owner = 'me'
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_get_daily_time_update_with_defaults
|
14
14
|
::Harvest.expects(:client).
|
15
|
-
with(subdomain: Toolshed::Client.time_tracking_owner, username: Toolshed::Client.time_tracking_username, password: Toolshed::Client.time_tracking_password).
|
15
|
+
with(subdomain: Toolshed::Client.instance.time_tracking_owner, username: Toolshed::Client.instance.time_tracking_username, password: Toolshed::Client.instance.time_tracking_password).
|
16
16
|
returns('')
|
17
17
|
|
18
18
|
harvest_mock = mock('Harvest::TimeEntry')
|
@@ -33,10 +33,10 @@ class GetDailyTimeUpdateTest < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_get_daily_time_update_with_use_defaults_on
|
36
|
-
Toolshed::Client.use_defaults = true
|
36
|
+
Toolshed::Client.instance.use_defaults = true
|
37
37
|
|
38
38
|
::Harvest.expects(:client).
|
39
|
-
with(subdomain: Toolshed::Client.time_tracking_owner, username: Toolshed::Client.time_tracking_username, password: Toolshed::Client.time_tracking_password).
|
39
|
+
with(subdomain: Toolshed::Client.instance.time_tracking_owner, username: Toolshed::Client.instance.time_tracking_username, password: Toolshed::Client.instance.time_tracking_password).
|
40
40
|
returns('')
|
41
41
|
|
42
42
|
harvest_mock = mock('Harvest::TimeEntry')
|
@@ -2,48 +2,60 @@ require 'commands/commands_helper'
|
|
2
2
|
require 'toolshed/commands/push_branch'
|
3
3
|
|
4
4
|
class PushBranchTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Toolshed.expects(:die).at_least(0).returns('Exiting')
|
7
|
+
@branch = Toolshed::Git::Branch.new
|
8
|
+
end
|
9
|
+
|
5
10
|
def test_push_branch_current_working_branch
|
6
|
-
Toolshed::Client.push_to_remote_name = 'origin'
|
11
|
+
Toolshed::Client.instance.push_to_remote_name = 'origin'
|
7
12
|
|
8
|
-
current_branch = Toolshed::Git::
|
13
|
+
current_branch = Toolshed::Git::Branch.name
|
9
14
|
|
10
15
|
new_branch_name = random_branch_name
|
11
16
|
create_and_checkout_branch(new_branch_name, 'master')
|
12
17
|
|
13
|
-
|
14
|
-
|
18
|
+
push_branch_command = Toolshed::Commands::PushBranch.new
|
19
|
+
push_branch_command.execute({})
|
20
|
+
|
21
|
+
assert_equal new_branch_name, @branch.name
|
15
22
|
|
16
|
-
Toolshed::Git::
|
23
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
17
24
|
delete_branch(new_branch_name)
|
18
25
|
end
|
19
26
|
|
20
27
|
def test_push_branch_by_ticket_id
|
21
|
-
Toolshed::Client.push_to_remote_name = 'origin'
|
28
|
+
Toolshed::Client.instance.push_to_remote_name = 'origin'
|
22
29
|
|
23
|
-
current_branch =
|
30
|
+
current_branch = @branch.name
|
24
31
|
|
25
32
|
new_branch_name = "555558_#{random_branch_name}"
|
26
33
|
create_and_checkout_branch(new_branch_name, 'master')
|
27
34
|
|
28
|
-
|
29
|
-
assert_match /#{new_branch_name} has been pushed/, output
|
35
|
+
push_branch_command = Toolshed::Commands::PushBranch.new
|
30
36
|
|
31
|
-
Toolshed::Git::
|
37
|
+
expected_git = Toolshed::Git::Branch.new(branch_name: '555558')
|
38
|
+
push_branch_command.execute({}, { branch_name: '555558' })
|
39
|
+
assert_equal new_branch_name, expected_git.name
|
40
|
+
|
41
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
32
42
|
delete_branch(new_branch_name)
|
33
43
|
end
|
34
44
|
|
35
45
|
def test_push_branch_current_working_branch_with_force
|
36
|
-
Toolshed::Client.push_to_remote_name = 'origin'
|
46
|
+
Toolshed::Client.instance.push_to_remote_name = 'origin'
|
37
47
|
|
38
|
-
current_branch = Toolshed::Git::
|
48
|
+
current_branch = Toolshed::Git::Branch.name
|
39
49
|
|
40
50
|
new_branch_name = random_branch_name
|
41
51
|
create_and_checkout_branch(new_branch_name, 'master')
|
42
52
|
|
43
|
-
|
44
|
-
|
53
|
+
push_branch_command = Toolshed::Commands::PushBranch.new
|
54
|
+
push_branch_command.execute({}, { force: true })
|
55
|
+
|
56
|
+
assert_equal new_branch_name, @branch.name
|
45
57
|
|
46
|
-
Toolshed::Git::
|
58
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
47
59
|
delete_branch(new_branch_name)
|
48
60
|
end
|
49
61
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'commands/commands_helper'
|
2
|
+
require 'toolshed/commands/rename_branch'
|
3
|
+
|
4
|
+
class DeleteBranchTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Toolshed.expects(:die).at_least(0).returns('Exiting')
|
7
|
+
@branch = Toolshed::Git::Branch.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_with_options_passed_in
|
11
|
+
current_branch = @branch.name
|
12
|
+
|
13
|
+
new_branch_name = random_branch_name
|
14
|
+
create_and_checkout_branch(new_branch_name, 'master')
|
15
|
+
|
16
|
+
# go to the remote repo and verify it exists
|
17
|
+
Dir.chdir(File.join(TEST_ROOT, "remote"))
|
18
|
+
remote_current_branch = @branch.name
|
19
|
+
Toolshed::Git::Branch.checkout(new_branch_name)
|
20
|
+
assert_equal new_branch_name, @branch.name
|
21
|
+
Toolshed::Git::Branch.checkout(remote_current_branch)
|
22
|
+
|
23
|
+
Dir.chdir(File.join(TEST_ROOT, "local"))
|
24
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
25
|
+
|
26
|
+
rename_branch_command = Toolshed::Commands::RenameBranch.new
|
27
|
+
result = rename_branch_command.execute({}, branch_name: new_branch_name, new_branch_name: 'testing_command')
|
28
|
+
assert_equal 'Exiting', result
|
29
|
+
|
30
|
+
branch_found = `git branch | grep #{new_branch_name}`
|
31
|
+
assert_equal '', branch_found
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_without_passing_in_options
|
35
|
+
current_branch = @branch.name
|
36
|
+
|
37
|
+
new_branch_name = random_branch_name
|
38
|
+
create_and_checkout_branch(new_branch_name, 'master')
|
39
|
+
|
40
|
+
# go to the remote repo and verify it exists
|
41
|
+
Dir.chdir(File.join(TEST_ROOT, "remote"))
|
42
|
+
remote_current_branch = @branch.name
|
43
|
+
Toolshed::Git::Branch.checkout(new_branch_name)
|
44
|
+
assert_equal new_branch_name, @branch.name
|
45
|
+
Toolshed::Git::Branch.checkout(remote_current_branch)
|
46
|
+
|
47
|
+
Dir.chdir(File.join(TEST_ROOT, "local"))
|
48
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
49
|
+
|
50
|
+
rename_branch_command = Toolshed::Commands::RenameBranch.new
|
51
|
+
rename_branch_command.expects(:read_user_input).with('Branch name?', required: true).returns(new_branch_name)
|
52
|
+
rename_branch_command.expects(:read_user_input).with('New Branch name?', required: true).returns('testing_command_no_options')
|
53
|
+
result = rename_branch_command.execute({})
|
54
|
+
assert_equal 'Exiting', result
|
55
|
+
|
56
|
+
branch_found = `git branch | grep #{new_branch_name}`
|
57
|
+
assert_equal '', branch_found
|
58
|
+
end
|
59
|
+
end
|
data/test/git/git_helper.rb
CHANGED
@@ -3,25 +3,25 @@ require 'helper'
|
|
3
3
|
def create_and_checkout_branch(name, branch_from='master')
|
4
4
|
save_stash
|
5
5
|
|
6
|
-
until system("git checkout -b #{name} origin/#{branch_from} #{Toolshed::Client.git_quiet}")
|
6
|
+
until system("git checkout -b #{name} origin/#{branch_from} #{Toolshed::Client.instance.git_quiet}")
|
7
7
|
sleep 1
|
8
8
|
end
|
9
9
|
|
10
|
-
until system("git push origin #{name} #{Toolshed::Client.git_quiet}")
|
10
|
+
until system("git push origin #{name} #{Toolshed::Client.instance.git_quiet}")
|
11
11
|
sleep 1
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def pop_stash
|
16
|
-
system("git stash pop #{Toolshed::Client.git_quiet}")
|
16
|
+
system("git stash pop #{Toolshed::Client.instance.git_quiet}")
|
17
17
|
end
|
18
18
|
|
19
19
|
def save_stash
|
20
|
-
system("git stash save #{Toolshed::Client.git_quiet}")
|
20
|
+
system("git stash save #{Toolshed::Client.instance.git_quiet}")
|
21
21
|
end
|
22
22
|
|
23
23
|
def delete_branch(branch_name)
|
24
|
-
until system("git branch -D #{branch_name} #{Toolshed::Client.git_quiet}")
|
24
|
+
until system("git branch -D #{branch_name} #{Toolshed::Client.instance.git_quiet}")
|
25
25
|
sleep 1
|
26
26
|
end
|
27
27
|
end
|
data/test/git/git_test.rb
CHANGED
@@ -1,34 +1,39 @@
|
|
1
1
|
require 'git/git_helper'
|
2
2
|
|
3
3
|
class GitTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Toolshed.expects(:die).at_least(0).returns('Exiting')
|
6
|
+
@branch = Toolshed::Git::Branch.new
|
7
|
+
end
|
8
|
+
|
4
9
|
def test_get_branch_name
|
5
|
-
current_branch = Toolshed::Git::
|
10
|
+
current_branch = Toolshed::Git::Branch.name
|
6
11
|
|
7
12
|
new_branch_name = random_branch_name
|
8
13
|
create_and_checkout_branch(new_branch_name)
|
9
14
|
|
10
|
-
assert_equal new_branch_name, Toolshed::Git::
|
15
|
+
assert_equal new_branch_name, Toolshed::Git::Branch.name
|
11
16
|
|
12
|
-
Toolshed::Git::
|
17
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
13
18
|
pop_stash
|
14
19
|
delete_branch(new_branch_name)
|
15
20
|
end
|
16
21
|
|
17
22
|
def test_checkout_branch
|
18
|
-
current_branch = Toolshed::Git::
|
23
|
+
current_branch = Toolshed::Git::Branch.name
|
19
24
|
|
20
25
|
new_branch_name = random_branch_name
|
21
26
|
create_and_checkout_branch(new_branch_name)
|
22
27
|
|
23
|
-
Toolshed::Git::
|
28
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
24
29
|
|
25
|
-
assert_equal current_branch, Toolshed::Git::
|
30
|
+
assert_equal current_branch, Toolshed::Git::Branch.name
|
26
31
|
|
27
32
|
delete_branch(new_branch_name)
|
28
33
|
end
|
29
34
|
|
30
35
|
def test_checkout_branch_by_id
|
31
|
-
current_branch = Toolshed::Git::
|
36
|
+
current_branch = Toolshed::Git::Branch.name
|
32
37
|
|
33
38
|
branch_id = "124233"
|
34
39
|
|
@@ -36,78 +41,78 @@ class GitTest < Test::Unit::TestCase
|
|
36
41
|
new_branch_name = "#{branch_id}_#{new_branch_name}"
|
37
42
|
create_and_checkout_branch(new_branch_name)
|
38
43
|
|
39
|
-
Toolshed::Git::
|
40
|
-
assert_equal current_branch, Toolshed::Git::
|
44
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
45
|
+
assert_equal current_branch, Toolshed::Git::Branch.name
|
41
46
|
|
42
|
-
Toolshed::Git::
|
43
|
-
assert_equal new_branch_name, Toolshed::Git::
|
47
|
+
Toolshed::Git::Branch.checkout(branch_id)
|
48
|
+
assert_equal new_branch_name, Toolshed::Git::Branch.name
|
44
49
|
|
45
|
-
Toolshed::Git::
|
50
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
46
51
|
delete_branch(new_branch_name)
|
47
52
|
end
|
48
53
|
|
49
54
|
def test_branched_from
|
50
|
-
current_branch = Toolshed::Git::
|
51
|
-
current_branch_branched_from = Toolshed::Git::
|
55
|
+
current_branch = Toolshed::Git::Branch.name
|
56
|
+
current_branch_branched_from = Toolshed::Git::Branch.from
|
52
57
|
|
53
58
|
new_branch_name = random_branch_name
|
54
59
|
create_and_checkout_branch(new_branch_name, 'development')
|
55
60
|
|
56
|
-
assert_equal 'development', Toolshed::Git::
|
61
|
+
assert_equal 'development', Toolshed::Git::Branch.from
|
57
62
|
|
58
|
-
Toolshed::Git::
|
63
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
59
64
|
delete_branch(new_branch_name)
|
60
65
|
end
|
61
66
|
|
62
67
|
def test_create_new_branch
|
63
|
-
current_branch = Toolshed::Git::
|
68
|
+
current_branch = Toolshed::Git::Branch.name
|
64
69
|
|
65
70
|
new_branch_name = random_branch_name
|
66
|
-
|
71
|
+
git_branch = Toolshed::Git::Branch.new({
|
67
72
|
from_remote_branch_name: 'development',
|
68
73
|
to_remote_branch_name: new_branch_name,
|
69
74
|
from_remote_name: 'origin',
|
70
75
|
to_remote_name: 'origin',
|
71
76
|
})
|
72
|
-
|
77
|
+
git_branch.create
|
73
78
|
|
74
|
-
assert_equal new_branch_name, Toolshed::Git::
|
75
|
-
assert_equal 'development', Toolshed::Git::
|
79
|
+
assert_equal new_branch_name, Toolshed::Git::Branch.name
|
80
|
+
assert_equal 'development', Toolshed::Git::Branch.from
|
76
81
|
|
77
|
-
Toolshed::Git::
|
82
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
78
83
|
delete_branch(new_branch_name)
|
79
84
|
end
|
80
85
|
|
81
86
|
def test_create_branch_from_remote_name_empty
|
82
87
|
new_branch_name = random_branch_name
|
83
|
-
|
88
|
+
branch = Toolshed::Git::Branch.new({
|
84
89
|
from_remote_branch_name: '',
|
85
90
|
to_remote_branch_name: new_branch_name,
|
86
91
|
from_remote_name: 'origin',
|
87
92
|
to_remote_name: 'origin',
|
88
93
|
})
|
89
94
|
|
90
|
-
exception = assert_raise(Veto::InvalidEntity) {
|
95
|
+
exception = assert_raise(Veto::InvalidEntity) { branch.create }
|
91
96
|
assert_equal 'from_remote_branch_name is not present', exception.message.first
|
92
97
|
end
|
93
98
|
|
94
99
|
def test_delete_branch
|
95
|
-
current_branch = Toolshed::Git::
|
100
|
+
current_branch = Toolshed::Git::Branch.name
|
96
101
|
|
97
102
|
new_branch_name = random_branch_name
|
98
103
|
create_and_checkout_branch(new_branch_name, 'master')
|
99
104
|
|
100
105
|
# go to the remote repo and verify it exists
|
101
106
|
Dir.chdir(File.join(TEST_ROOT, "remote"))
|
102
|
-
remote_current_branch = Toolshed::Git::
|
103
|
-
Toolshed::Git::
|
104
|
-
assert_equal new_branch_name, Toolshed::Git::
|
105
|
-
Toolshed::Git::
|
107
|
+
remote_current_branch = Toolshed::Git::Branch.name
|
108
|
+
Toolshed::Git::Branch.checkout(new_branch_name)
|
109
|
+
assert_equal new_branch_name, Toolshed::Git::Branch.name
|
110
|
+
Toolshed::Git::Branch.checkout(remote_current_branch)
|
106
111
|
|
107
112
|
Dir.chdir(File.join(TEST_ROOT, "local"))
|
108
|
-
Toolshed::Git::
|
113
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
109
114
|
|
110
|
-
|
115
|
+
@branch.delete(new_branch_name)
|
111
116
|
|
112
117
|
branch_found = `git branch | grep #{new_branch_name}`
|
113
118
|
assert_equal '', branch_found
|
data/test/git/github_test.rb
CHANGED
@@ -1,49 +1,12 @@
|
|
1
1
|
require 'git/git_helper'
|
2
2
|
|
3
3
|
class GitHubTest < Test::Unit::TestCase
|
4
|
-
def test_list_branches
|
5
|
-
Toolshed::Client.github_username = 'sample'
|
6
|
-
Toolshed::Client.pull_from_repository_name = 'sample'
|
7
|
-
|
8
|
-
expected_result = [
|
9
|
-
{
|
10
|
-
"name" => "master",
|
11
|
-
"commit" => {
|
12
|
-
"sha" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
|
13
|
-
"url" => "https://api.github.com/repos/octocat/Hello-World/commits/c5b97d5ae6c19d5c5df71a34c7fbeeda2479ccbc"
|
14
|
-
}
|
15
|
-
},
|
16
|
-
{
|
17
|
-
"name" => "develop",
|
18
|
-
"commit" => {
|
19
|
-
"sha" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
|
20
|
-
"url" => "https://api.github.com/repos/octocat/Hello-World/commits/345lj5ae6c19d5c5df71a34c7fbeeda2479ccbc"
|
21
|
-
}
|
22
|
-
}
|
23
|
-
].to_json
|
24
|
-
http_mock = mock('Net::HTTPResponse')
|
25
|
-
http_mock.stubs(:code => '200', :message => "OK", :content_type => "text/html", :body => expected_result)
|
26
|
-
|
27
|
-
http_party_mock = mock('HTTParty')
|
28
|
-
http_party_mock.stubs(:response => http_mock)
|
29
|
-
|
30
|
-
# create new github object
|
31
|
-
github = Toolshed::Git::Github.new
|
32
|
-
|
33
|
-
HTTParty.
|
34
|
-
expects(:get).
|
35
|
-
with("#{Toolshed::Client::GITHUB_BASE_API_URL}repos/#{Toolshed::Client.github_username}/#{Toolshed::Client.pull_from_repository_name}/branches", github.default_options).
|
36
|
-
returns(http_party_mock)
|
37
|
-
|
38
|
-
assert_equal JSON.parse(expected_result), github.list_branches
|
39
|
-
end
|
40
|
-
|
41
4
|
def test_create_pull_request
|
42
|
-
current_branch = Toolshed::Git::
|
5
|
+
current_branch = Toolshed::Git::Branch.name
|
43
6
|
new_branch_name = '1234_testing'
|
44
7
|
|
45
|
-
Toolshed::Client.pull_from_repository_user = 'sample'
|
46
|
-
Toolshed::Client.pull_from_repository_name = 'sample_repo'
|
8
|
+
Toolshed::Client.instance.pull_from_repository_user = 'sample'
|
9
|
+
Toolshed::Client.instance.pull_from_repository_name = 'sample_repo'
|
47
10
|
create_and_checkout_branch(new_branch_name)
|
48
11
|
|
49
12
|
expected_result = {
|
@@ -63,29 +26,29 @@ class GitHubTest < Test::Unit::TestCase
|
|
63
26
|
body: {
|
64
27
|
title: 'Sample',
|
65
28
|
body: 'Sample Body',
|
66
|
-
head: "#{Toolshed::Client.github_username}:#{Toolshed::Git::
|
67
|
-
base: Toolshed::Git::
|
29
|
+
head: "#{Toolshed::Client.instance.github_username}:#{Toolshed::Git::Branch.name}",
|
30
|
+
base: Toolshed::Git::Branch.from
|
68
31
|
}.to_json
|
69
32
|
})
|
70
33
|
|
71
34
|
HTTParty.
|
72
35
|
expects(:post).
|
73
|
-
with("#{Toolshed::Client::GITHUB_BASE_API_URL}repos/#{Toolshed::Client.pull_from_repository_user}/#{Toolshed::Client.pull_from_repository_name}/pulls", github_default_options).
|
36
|
+
with("#{Toolshed::Client::GITHUB_BASE_API_URL}repos/#{Toolshed::Client.instance.pull_from_repository_user}/#{Toolshed::Client.instance.pull_from_repository_name}/pulls", github_default_options).
|
74
37
|
returns(http_party_mock)
|
75
38
|
|
76
39
|
assert_equal JSON.parse(expected_result), github.create_pull_request('Sample', 'Sample Body')
|
77
40
|
|
78
|
-
Toolshed::Git::
|
41
|
+
Toolshed::Git::Branch.checkout(current_branch)
|
79
42
|
delete_branch(new_branch_name)
|
80
43
|
end
|
81
44
|
|
82
45
|
def test_get_username
|
83
|
-
Toolshed::Client.github_username = 'tester'
|
46
|
+
Toolshed::Client.instance.github_username = 'tester'
|
84
47
|
assert_equal 'tester', Toolshed::Git::Github.username
|
85
48
|
end
|
86
49
|
|
87
50
|
def test_get_password
|
88
|
-
Toolshed::Client.github_password = 'tester1234'
|
51
|
+
Toolshed::Client.instance.github_password = 'tester1234'
|
89
52
|
assert_equal 'tester1234', Toolshed::Git::Github.password
|
90
53
|
end
|
91
54
|
end
|
data/test/helper.rb
CHANGED
@@ -20,9 +20,9 @@ require 'json'
|
|
20
20
|
require 'toolshed'
|
21
21
|
|
22
22
|
Test::Unit.at_start do
|
23
|
-
Toolshed::Client.use_git_submodules = false
|
23
|
+
Toolshed::Client.instance.use_git_submodules = false
|
24
24
|
#Toolshed::Client.git_quiet = '&> /dev/null' unless ENV['RUNNING_ON_CI']
|
25
|
-
Toolshed::Client.git_quiet = ''
|
25
|
+
Toolshed::Client.instance.git_quiet = ''
|
26
26
|
|
27
27
|
I18n.config.enforce_available_locales = true
|
28
28
|
|
@@ -38,25 +38,25 @@ Test::Unit.at_start do
|
|
38
38
|
Dir.chdir(File.join(TEST_ROOT, "remote"))
|
39
39
|
|
40
40
|
# setup a couple of branches acting as the remote repository
|
41
|
-
until system("git init #{Toolshed::Client.git_quiet}")
|
41
|
+
until system("git init #{Toolshed::Client.instance.git_quiet}")
|
42
42
|
sleep 1
|
43
43
|
end
|
44
44
|
|
45
45
|
FileUtils.touch('file.txt')
|
46
46
|
|
47
|
-
until system("git add file.txt #{Toolshed::Client.git_quiet}")
|
47
|
+
until system("git add file.txt #{Toolshed::Client.instance.git_quiet}")
|
48
48
|
sleep 1
|
49
49
|
end
|
50
50
|
|
51
|
-
until system("git commit -m 'Add empty file as commit' #{Toolshed::Client.git_quiet}")
|
51
|
+
until system("git commit -m 'Add empty file as commit' #{Toolshed::Client.instance.git_quiet}")
|
52
52
|
sleep 1
|
53
53
|
end
|
54
54
|
|
55
|
-
until system("git checkout -b development master #{Toolshed::Client.git_quiet}")
|
55
|
+
until system("git checkout -b development master #{Toolshed::Client.instance.git_quiet}")
|
56
56
|
sleep 1
|
57
57
|
end
|
58
58
|
|
59
|
-
until system("git checkout master #{Toolshed::Client.git_quiet}")
|
59
|
+
until system("git checkout master #{Toolshed::Client.instance.git_quiet}")
|
60
60
|
sleep 1
|
61
61
|
end
|
62
62
|
|
@@ -68,19 +68,19 @@ Test::Unit.at_start do
|
|
68
68
|
Dir.chdir(File.join(TEST_ROOT, "local"))
|
69
69
|
|
70
70
|
# setup the new repository with an empty set this is configured in the config.rb file
|
71
|
-
until system("git init #{Toolshed::Client.git_quiet}")
|
71
|
+
until system("git init #{Toolshed::Client.instance.git_quiet}")
|
72
72
|
sleep 1
|
73
73
|
end
|
74
74
|
|
75
|
-
until system("git remote add origin #{File.join(TEST_ROOT, "remote")} #{Toolshed::Client.git_quiet}")
|
75
|
+
until system("git remote add origin #{File.join(TEST_ROOT, "remote")} #{Toolshed::Client.instance.git_quiet}")
|
76
76
|
sleep 1
|
77
77
|
end
|
78
78
|
|
79
|
-
until system("git remote update #{Toolshed::Client.git_quiet}")
|
79
|
+
until system("git remote update #{Toolshed::Client.instance.git_quiet}")
|
80
80
|
sleep 1
|
81
81
|
end
|
82
82
|
|
83
|
-
until system("git checkout -b master origin/master #{Toolshed::Client.git_quiet}")
|
83
|
+
until system("git checkout -b master origin/master #{Toolshed::Client.instance.git_quiet}")
|
84
84
|
sleep 1
|
85
85
|
end
|
86
86
|
end
|