ghedsh 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/actions/repo.rb +29 -6
- data/lib/actions/system.rb +35 -27
- data/lib/interface.rb +5 -11
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4db7042e1bd392d890e24fb1628fcbbd1b3c442c
|
4
|
+
data.tar.gz: 74ce61927464885c34d375c201abf845ec379b72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 831513a2fb92dd9bcfacec2ff485be6d19684c6ecab8f593882e8681b8741b7934906f69d1cc3ab193e2ebafa032034d630e28ff9b0ac21d7651e2d3a38ab6b5
|
7
|
+
data.tar.gz: 0aa8ed91722586e70e46b962dd4e61fe0c61b81becdc64bb8ce11a20f17607b113be745422a8d243c5fc5c7dc9fb37e5cc313d0744971740446df45f3dc859c3
|
data/lib/actions/repo.rb
CHANGED
@@ -42,6 +42,7 @@ class Repositories
|
|
42
42
|
return reposlist
|
43
43
|
end
|
44
44
|
|
45
|
+
|
45
46
|
def show_repos_smart(client,config,exp,scope)
|
46
47
|
reposlist=[]
|
47
48
|
case
|
@@ -55,7 +56,7 @@ class Repositories
|
|
55
56
|
repo.each do |i|
|
56
57
|
reposlist.push(i.name)
|
57
58
|
end
|
58
|
-
|
59
|
+
|
59
60
|
reposlist=Sys.new.search_rexp(reposlist,exp)
|
60
61
|
puts reposlist
|
61
62
|
return reposlist
|
@@ -130,19 +131,41 @@ class Repositories
|
|
130
131
|
end
|
131
132
|
end
|
132
133
|
|
133
|
-
def
|
134
|
+
def get_repos_list(client,config,scope)
|
135
|
+
reposlist=[]
|
136
|
+
case
|
137
|
+
when scope==1
|
138
|
+
repo=client.repositories
|
139
|
+
when scope==2
|
140
|
+
repo=client.organization_repositories(config["Org"])
|
141
|
+
when scope==3
|
142
|
+
repo=client.team_repositories(config["TeamID"])
|
143
|
+
end
|
144
|
+
repo.each do |i|
|
145
|
+
reposlist.push(i.name)
|
146
|
+
end
|
147
|
+
return reposlist
|
148
|
+
end
|
149
|
+
|
150
|
+
def clone_repo(client,config,exp,scope)
|
134
151
|
web="https://github.com/"
|
135
152
|
web2="git@github.com:"
|
136
153
|
|
154
|
+
list=self.get_repos_list(client,config,scope)
|
137
155
|
list=Sys.new.search_rexp(list,exp)
|
156
|
+
|
138
157
|
if (list.empty?) == false
|
139
158
|
case
|
140
159
|
when scope==1
|
141
|
-
|
142
|
-
|
160
|
+
list.each do |i|
|
161
|
+
command = "git clone #{web}#{config["User"]}/#{i}.git"
|
162
|
+
system(command)
|
163
|
+
end
|
143
164
|
when scope==2
|
144
|
-
|
145
|
-
|
165
|
+
list.each do |i|
|
166
|
+
command = "git clone #{web}#{config["Org"]}/#{i}.git"
|
167
|
+
system(command)
|
168
|
+
end
|
146
169
|
end
|
147
170
|
else
|
148
171
|
puts "No repositories found it with the parameters given"
|
data/lib/actions/system.rb
CHANGED
@@ -25,14 +25,37 @@ class Sys
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def login(token)
|
29
|
+
user=Octokit::Client.new(:access_token =>token)
|
30
|
+
if user==false
|
31
|
+
puts "Oauth error"
|
32
|
+
else
|
33
|
+
return user
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_loguin_data_sh(config)
|
38
|
+
puts "Insert you Access Token: "
|
39
|
+
token = gets.chomp
|
40
|
+
us=self.login(token)
|
41
|
+
if us!=nil
|
42
|
+
puts "Login succesful as #{us.login}"
|
43
|
+
config["User"]=us.login
|
44
|
+
config["Token"]=token
|
45
|
+
return config
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
28
49
|
def load_assig_db
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
50
|
+
path='./lib/db/assignments.json'
|
51
|
+
if (File.exist?(path))==true
|
52
|
+
json = File.read(path)
|
53
|
+
else
|
54
|
+
path="#{ENV['GEM_HOME']}/gems/ghedsh-#{Ghedsh::VERSION}/lib/db/assignments.json"
|
55
|
+
json = File.read(path)
|
56
|
+
end
|
57
|
+
config=JSON.parse(json)
|
34
58
|
return config
|
35
|
-
#end
|
36
59
|
end
|
37
60
|
|
38
61
|
def create_config(path)
|
@@ -49,33 +72,18 @@ class Sys
|
|
49
72
|
end
|
50
73
|
|
51
74
|
def save_db(data)
|
52
|
-
File.
|
53
|
-
|
54
|
-
|
55
|
-
def get_config
|
56
|
-
end
|
57
|
-
|
58
|
-
def login(token)
|
59
|
-
user=Octokit::Client.new(:access_token =>token)
|
60
|
-
if user==false
|
61
|
-
puts "Oauth error"
|
75
|
+
if (File.exist?('./lib/db/assignments.json'))==true
|
76
|
+
File.write('./lib/db/assignments.json', data.to_json)
|
62
77
|
else
|
63
|
-
|
78
|
+
File.write("#{ENV['GEM_HOME']}/gems/ghedsh-#{Ghedsh::VERSION}/lib/db/assignments.json", data.to_json)
|
64
79
|
end
|
65
80
|
end
|
66
81
|
|
67
|
-
def
|
68
|
-
|
69
|
-
token = gets.chomp
|
70
|
-
us=self.login(token)
|
71
|
-
if us!=nil
|
72
|
-
puts "Login succesful as #{us.login}"
|
73
|
-
config["User"]=us.login
|
74
|
-
config["Token"]=token
|
75
|
-
return config
|
76
|
-
end
|
82
|
+
def get_config
|
83
|
+
#todo
|
77
84
|
end
|
78
85
|
|
86
|
+
|
79
87
|
def search_rexp(list,exp)
|
80
88
|
list= list.select{|o| o.match(/#{exp}/)}
|
81
89
|
#puts list
|
data/lib/interface.rb
CHANGED
@@ -18,7 +18,7 @@ class Interface
|
|
18
18
|
attr_accessor :deep
|
19
19
|
attr_accessor :memory
|
20
20
|
attr_accessor :teamlist
|
21
|
-
LIST = ['repos', 'exit', 'orgs','help', 'members','teams', 'cd ', 'commits','forks', 'add_team_member ','create_team ','delete_team ','create_repository '].sort
|
21
|
+
LIST = ['repos', 'exit', 'orgs','help', 'members','teams', 'cd ', 'commits','forks', 'add_team_member ','create_team ','delete_team ','create_repository ','clone_repo '].sort
|
22
22
|
|
23
23
|
def initialize
|
24
24
|
self.run
|
@@ -276,7 +276,7 @@ class Interface
|
|
276
276
|
when @deep==2
|
277
277
|
r.show_repos_smart(@client,@config,opcd[1],2)
|
278
278
|
when @deep==3
|
279
|
-
r.show_repos_smart(@client,@config,opcd[1],3)
|
279
|
+
r.show_repos_smart(@client,@config,opcd[1],3)
|
280
280
|
end
|
281
281
|
end
|
282
282
|
if opcd[0]=="add_team_member"
|
@@ -299,14 +299,7 @@ class Interface
|
|
299
299
|
self.add_history_str(1,@teamlist)
|
300
300
|
end
|
301
301
|
if opcd[0]=="create_repository" and opcd.size==2
|
302
|
-
|
303
|
-
when @deep==1
|
304
|
-
r.create_repository(@client,@config,opcd[1],1)
|
305
|
-
when @deep==2
|
306
|
-
r.create_repository(@client,@config,opcd[1],2)
|
307
|
-
when @deep==4
|
308
|
-
r.create_repository(@client,@config,opcd[1],4)
|
309
|
-
end
|
302
|
+
r.create_repository(@client,@config,opcd[1],@deep)
|
310
303
|
end
|
311
304
|
if opcd[0]=="create_repository" and opcd.size>2
|
312
305
|
case
|
@@ -316,10 +309,11 @@ class Interface
|
|
316
309
|
end
|
317
310
|
|
318
311
|
if opcd[0]=="clone_repo" and opcd.size==2
|
312
|
+
r.clone_repo(@client,@config,opcd[1],@deep)
|
319
313
|
end
|
320
314
|
|
321
315
|
if opcd[0]=="clone_repo" and opcd.size>2
|
322
|
-
#r.clone_repo(@client,@
|
316
|
+
#r.clone_repo(@client,@config,opcd[1])
|
323
317
|
end
|
324
318
|
end
|
325
319
|
else
|
data/lib/version.rb
CHANGED