commit-live-cli 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/commit-live/lesson/current.rb +10 -2
- data/lib/commit-live/lesson/git-helper.rb +18 -13
- data/lib/commit-live/lesson/open.rb +6 -2
- data/lib/commit-live/tests/runner.rb +9 -2
- data/lib/commit-live/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74baeabdd3c9227117b5c1170e10df0cb660be0d
|
4
|
+
data.tar.gz: 103fa9e8c6f7459b3736a86e384f0617277037b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65a20d039813f73d1c192611f90bedba23bed6ec7b04cc5b799ad270128c031b23a644429d5856ea3ed744abd51977bbad496266e825287115c67adc4f1bbefc
|
7
|
+
data.tar.gz: 8d443f3e1641e6ed9a8d2c4b0db33d209ca94aa65de5da1c3751398d412930e7dd18ec55714fe2f2e58e03e6e6ab68f7ad40b50ded43ada78fe038aa62280614
|
@@ -10,13 +10,21 @@ module CommitLive
|
|
10
10
|
@netrc = CommitLive::NetrcInteractor.new()
|
11
11
|
end
|
12
12
|
|
13
|
-
def getCurrentLesson(
|
13
|
+
def getCurrentLesson(puzzle_name)
|
14
|
+
url = '/v1/current_lesson'
|
15
|
+
if !puzzle_name.empty?
|
16
|
+
url = "/v1/user/lesson/#{puzzle_name}"
|
17
|
+
end
|
18
|
+
getLesson(url)
|
19
|
+
end
|
20
|
+
|
21
|
+
def getLesson(url)
|
14
22
|
begin
|
15
23
|
Timeout::timeout(15) do
|
16
24
|
netrc.read
|
17
25
|
token = netrc.password
|
18
26
|
response = CommitLive::API.new().get(
|
19
|
-
|
27
|
+
url,
|
20
28
|
headers: { 'access-token' => "#{token}" }
|
21
29
|
)
|
22
30
|
if response.status == 200
|
@@ -99,22 +99,23 @@ module CommitLive
|
|
99
99
|
|
100
100
|
def createPullRequest
|
101
101
|
puts 'Creating Pull Request...'
|
102
|
-
|
102
|
+
lessonName = repo_name(remote: 'origin')
|
103
|
+
currentLesson.getCurrentLesson(lessonName)
|
103
104
|
userGithub = CommitLive::Github.new()
|
104
105
|
netrc.read(machine: 'ga-extra')
|
105
106
|
username = netrc.login
|
106
107
|
begin
|
107
108
|
Timeout::timeout(45) do
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
109
|
+
lessonData = currentLesson.getAttr('data')
|
110
|
+
parentRepo = lessonData['repo_url']
|
111
|
+
pullRequest = userGithub.client.create_pull_request(
|
112
|
+
parentRepo,
|
113
|
+
'master',
|
114
|
+
"#{username}:master",
|
115
|
+
"PR by #{username}"
|
116
|
+
)
|
117
|
+
puts "Lesson submitted successfully!"
|
118
|
+
end
|
118
119
|
rescue Octokit::Error => err
|
119
120
|
puts "Error while creating PR!"
|
120
121
|
puts err
|
@@ -125,10 +126,14 @@ module CommitLive
|
|
125
126
|
end
|
126
127
|
end
|
127
128
|
|
129
|
+
def repo_name(remote: remote_name)
|
130
|
+
url = git.remote(remote).url
|
131
|
+
url.match(/^.+[\w-]+\/(.*?)(?:\.git)?$/)[1]
|
132
|
+
end
|
133
|
+
|
128
134
|
def update_lesson_status
|
129
135
|
puts 'Updating lesson status...'
|
130
|
-
|
131
|
-
lessonName = lessonData['chapters']['lessons']['title']
|
136
|
+
lessonName = repo_name(remote: 'origin')
|
132
137
|
status.update('submitted_pull_request', lessonName)
|
133
138
|
end
|
134
139
|
end
|
@@ -20,12 +20,16 @@ module CommitLive
|
|
20
20
|
@lesson_status = CommitLive::Status.new
|
21
21
|
end
|
22
22
|
|
23
|
-
def openALesson(
|
23
|
+
def openALesson(puzzle_name)
|
24
24
|
# get currently active lesson
|
25
25
|
puts "Getting current lesson..."
|
26
26
|
lesson.getCurrentLesson(puzzle_name)
|
27
27
|
lessonData = lesson.getAttr('data')
|
28
|
-
|
28
|
+
if !lessonData['chapters'].nil?
|
29
|
+
@lessonName = lessonData['chapters']['lessons']['title']
|
30
|
+
else
|
31
|
+
@lessonName = lessonData['title']
|
32
|
+
end
|
29
33
|
if !File.exists?("#{rootDir}/#{lessonName}")
|
30
34
|
# fork lesson repo via github api
|
31
35
|
forkCurrentLesson
|
@@ -5,6 +5,8 @@ require 'commit-live/tests/strategies/python-test'
|
|
5
5
|
|
6
6
|
module CommitLive
|
7
7
|
class Test
|
8
|
+
attr_reader :git
|
9
|
+
|
8
10
|
REPO_BELONGS_TO_US = [
|
9
11
|
'commit-live-students'
|
10
12
|
]
|
@@ -23,7 +25,7 @@ module CommitLive
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def check_lesson_dir
|
26
|
-
git = set_git
|
28
|
+
@git = set_git
|
27
29
|
netrc = CommitLive::NetrcInteractor.new()
|
28
30
|
netrc.read(machine: 'ga-extra')
|
29
31
|
username = netrc.login
|
@@ -32,6 +34,11 @@ module CommitLive
|
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
37
|
+
def repo_name(remote: remote_name)
|
38
|
+
url = git.remote(remote).url
|
39
|
+
url.match(/^.+[\w-]+\/(.*?)(?:\.git)?$/)[1]
|
40
|
+
end
|
41
|
+
|
35
42
|
def put_error_msg
|
36
43
|
puts "It doesn't look like you're in a lesson directory."
|
37
44
|
puts 'Please cd into an appropriate directory and try again.'
|
@@ -43,7 +50,7 @@ module CommitLive
|
|
43
50
|
strategy.configure
|
44
51
|
results = strategy.run
|
45
52
|
puts 'Updating lesson status...'
|
46
|
-
lessonName =
|
53
|
+
lessonName = repo_name(remote: 'origin')
|
47
54
|
if results
|
48
55
|
# test case passed
|
49
56
|
CommitLive::Status.new().update('test_case_pass', lessonName)
|
data/lib/commit-live/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commit-live-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- greyatom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|