tbgit 1.0.5 → 1.0.6
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/bin/tbgit +2 -0
- data/lib/add_webhooks.rb +38 -0
- data/lib/tbgit/version.rb +1 -1
- data/lib/tbgit/version.rb~ +3 -0
- data/lib/tbgit.rb +49 -13
- data/tbgit.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eb15c5320ffda2798b568ff362e5048a9056970
|
4
|
+
data.tar.gz: c10caeb230277b6e3f2968b11ae264582852972a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 784640d659c9c8b9aef4bea90bf55caf775c76a91aaa0cb9a4c9276eda8597878e0e27bb384fec4aabe77dd7cbcbb981c6769e84d44a34b707c13c052bd36656
|
7
|
+
data.tar.gz: c003f1d1af994c744518a857628b95221d3b4e336575eeefaa797222118b551cbd029104a3c17e57aeb5ae0cbdc7351c78d46176da10897366601f2bc66ff676
|
data/bin/tbgit
CHANGED
data/lib/add_webhooks.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
class CreateWebhooks
|
7
|
+
|
8
|
+
@@host = "https://api.github.com"
|
9
|
+
@@port = 443
|
10
|
+
|
11
|
+
def post(organization,student,reponame,user,pass,url)
|
12
|
+
|
13
|
+
payload ='{
|
14
|
+
"name": "web",
|
15
|
+
"active": true,
|
16
|
+
"events": ["push"],
|
17
|
+
"config": {
|
18
|
+
"url": "' + url + '",
|
19
|
+
"content_type": "json"
|
20
|
+
}
|
21
|
+
}'
|
22
|
+
|
23
|
+
post_url = @@host + "/repos/" + organization + "/" + student + "-" + reponame + "/hooks"
|
24
|
+
uri = URI(post_url)
|
25
|
+
|
26
|
+
Net::HTTP.start(uri.host,uri.port,
|
27
|
+
:use_ssl => uri.scheme = 'https') do |http|
|
28
|
+
request = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'})
|
29
|
+
request.basic_auth user, pass
|
30
|
+
request.body = payload
|
31
|
+
http.request request do |response|
|
32
|
+
response.read_body do |chunk|
|
33
|
+
puts chunk
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/tbgit/version.rb
CHANGED
data/lib/tbgit.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "tbgit/version"
|
2
2
|
require "tempfile"
|
3
3
|
require "score_parser"
|
4
|
+
require "add_webhooks"
|
5
|
+
require 'highline/import'
|
4
6
|
|
5
7
|
module Main
|
6
8
|
|
@@ -39,7 +41,7 @@ module Main
|
|
39
41
|
|
40
42
|
#gather necessary information
|
41
43
|
def gather(students_file, organization, reponame)
|
42
|
-
if students_file ==
|
44
|
+
if students_file == nil
|
43
45
|
puts 'Students file |../students|:'
|
44
46
|
@students_file = $stdin.gets.chomp
|
45
47
|
if @students_file == ""
|
@@ -49,7 +51,7 @@ module Main
|
|
49
51
|
@students_file = students_file
|
50
52
|
end
|
51
53
|
|
52
|
-
if organization ==
|
54
|
+
if organization == nil
|
53
55
|
puts 'Organization name |yale-stc-developer-curriculum|:'
|
54
56
|
@organization = $stdin.gets.chomp
|
55
57
|
if @organization == ""
|
@@ -59,7 +61,7 @@ module Main
|
|
59
61
|
@organization = organization
|
60
62
|
end
|
61
63
|
|
62
|
-
if reponame ==
|
64
|
+
if reponame == nil
|
63
65
|
puts 'Student Repo Name |TechBootcampHomework|:'
|
64
66
|
@reponame = $stdin.gets.chomp
|
65
67
|
if @reponame == ""
|
@@ -135,12 +137,12 @@ module Main
|
|
135
137
|
|
136
138
|
confirm(flag,"A merge and commit will be performed on each local student branch (from the branch you specify). Continue?")
|
137
139
|
|
138
|
-
if merge_branch
|
140
|
+
if merge_branch == nil
|
139
141
|
puts "Merge from branch: "
|
140
142
|
merge_branch = $stdin.gets.chomp
|
141
143
|
end
|
142
144
|
|
143
|
-
if message
|
145
|
+
if message == nil
|
144
146
|
puts "Commit Message: "
|
145
147
|
message = $stdin.gets.chomp
|
146
148
|
end
|
@@ -171,8 +173,8 @@ module Main
|
|
171
173
|
|
172
174
|
end
|
173
175
|
|
174
|
-
#takes an array of commands, and executes
|
175
|
-
def
|
176
|
+
#takes an array of commands, and executes a ruby command on each student branch
|
177
|
+
def on_each_ruby(input)
|
176
178
|
all_remotes = all_remotes_list
|
177
179
|
all_remotes.each do |branch|
|
178
180
|
branch.delete!("\n")
|
@@ -187,7 +189,7 @@ module Main
|
|
187
189
|
final_command = command.gsub("<branch>", branch)
|
188
190
|
|
189
191
|
puts final_command
|
190
|
-
|
192
|
+
eval(final_command)
|
191
193
|
end
|
192
194
|
end
|
193
195
|
|
@@ -195,25 +197,30 @@ module Main
|
|
195
197
|
switch_to_master
|
196
198
|
end
|
197
199
|
|
198
|
-
|
200
|
+
#takes an array of commands, and executes a system command on each student branch
|
201
|
+
def on_each_exec(input)
|
202
|
+
input.map! { |a| "system '" + a.gsub("'"){"\\'"} + "'"}
|
203
|
+
on_each_ruby(input)
|
204
|
+
end
|
205
|
+
|
199
206
|
def git_status
|
200
207
|
on_each_exec(["git status <branch>"])
|
201
208
|
end
|
202
209
|
|
203
210
|
def spec(flag,specfile,studentcopy,mastercopy,commit_message)
|
204
211
|
|
205
|
-
if specfile==
|
212
|
+
if specfile==nil
|
206
213
|
puts "Please specify the relative path from your pwd to the rspec file you would like to spec, eg. 'hw1/spec/spec.rb'"
|
207
214
|
specfile = $stdin.gets.chomp
|
208
215
|
end
|
209
216
|
|
210
|
-
if studentcopy==
|
217
|
+
if studentcopy==nil
|
211
218
|
puts "Where would you like to save each student's individual results?"
|
212
219
|
puts "**Must be inside the student's repo directory, eg. 'hw1/spec/results.txt'**"
|
213
220
|
studentcopy = $stdin.gets.chomp
|
214
221
|
end
|
215
222
|
|
216
|
-
if mastercopy==
|
223
|
+
if mastercopy==nil
|
217
224
|
puts "In which folder would you like to save a copy of all results?"
|
218
225
|
puts "**Must be outside the student's repo directory, eg. '../results'**"
|
219
226
|
mastercopy = $stdin.gets.chomp
|
@@ -222,7 +229,7 @@ module Main
|
|
222
229
|
puts "mkdir " + mastercopy
|
223
230
|
system "mkdir " + mastercopy
|
224
231
|
|
225
|
-
if commit_message==
|
232
|
+
if commit_message==nil
|
226
233
|
puts "Commit message (commiting each student's results to their repo):"
|
227
234
|
commit_message = $stdin.gets.chomp
|
228
235
|
end
|
@@ -241,5 +248,34 @@ module Main
|
|
241
248
|
|
242
249
|
end
|
243
250
|
|
251
|
+
def add_webhooks(organization,reponame,user,pass,url)
|
252
|
+
if organization == nil
|
253
|
+
puts "Organization Name:"
|
254
|
+
organization = $stdin.gets.chomp
|
255
|
+
end
|
256
|
+
|
257
|
+
if reponame == nil
|
258
|
+
puts "Student Repository Name:"
|
259
|
+
reponame = $stdin.gets.chomp
|
260
|
+
end
|
261
|
+
|
262
|
+
if user == nil
|
263
|
+
print "Username:"
|
264
|
+
user = $stdin.gets.chomp
|
265
|
+
end
|
266
|
+
|
267
|
+
if pass == nil
|
268
|
+
pass = ask("Password: ") { |q| q.echo = false }
|
269
|
+
end
|
270
|
+
|
271
|
+
if url == nil
|
272
|
+
puts "Webhook url:"
|
273
|
+
url = $stdin.gets.chomp
|
274
|
+
end
|
275
|
+
|
276
|
+
on_each_ruby(['create = CreateWebhooks.new; create.post(\''+ organization.to_s + '\',\'<branch>\',\''+reponame.to_s+'\',
|
277
|
+
\''+user.to_s+'\',\''+pass.to_s+'\',\''+url.to_s+'\')'])
|
278
|
+
|
279
|
+
end
|
244
280
|
end #class
|
245
281
|
end #module
|
data/tbgit.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tbgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Proctor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: highline/import
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: ''
|
70
84
|
email:
|
71
85
|
- charlie@charlieproctor.com
|
@@ -80,11 +94,13 @@ files:
|
|
80
94
|
- README.md
|
81
95
|
- Rakefile
|
82
96
|
- bin/tbgit
|
97
|
+
- lib/add_webhooks.rb
|
83
98
|
- lib/helptext.rb
|
84
99
|
- lib/score_parser.rb
|
85
100
|
- lib/scoresheet.txt
|
86
101
|
- lib/tbgit.rb
|
87
102
|
- lib/tbgit/version.rb
|
103
|
+
- lib/tbgit/version.rb~
|
88
104
|
- tbgit.gemspec
|
89
105
|
homepage: ''
|
90
106
|
licenses:
|