ghedsh 1.1.9 → 1.1.10
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 +27 -25
- data/lib/actions/system.rb +29 -16
- data/lib/interface.rb +26 -12
- data/lib/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: 10c27568227695c5e7166c854a1e58e3ac74908c
|
4
|
+
data.tar.gz: 472ff14bd2ddc02686f346ca74b1f2935d360b35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 228dc8b4b3dbaff83deb9f4dde4e555063ee14ef598004387a9d8d681fcc637fe381c655639ea69fe92f92b5dd97f68d2bb27fc401d9eef245a73cd062f901aa
|
7
|
+
data.tar.gz: eb5604973f82e1ad6eab5f91adf885ae1bbe61b35bbf9949144b7b0ddeadbc9d0c287d0bfc08fe9d825739e9952d59112db8abbc3989bf0fe9d9fb8d180ff814
|
data/lib/actions/repo.rb
CHANGED
@@ -24,11 +24,20 @@ class Repositories
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def show_repos(client,config,scope)
|
27
|
+
def show_repos(client,config,scope,exp)
|
28
28
|
print "\n"
|
29
29
|
reposlist=[]
|
30
30
|
options=Hash.new
|
31
31
|
o=Organizations.new
|
32
|
+
regex=false
|
33
|
+
|
34
|
+
if exp!=nil
|
35
|
+
if exp.match(/^\//)
|
36
|
+
regex=true
|
37
|
+
sp=exp.split('/')
|
38
|
+
exp=sp[1]
|
39
|
+
end
|
40
|
+
end
|
32
41
|
|
33
42
|
case
|
34
43
|
when scope==1
|
@@ -43,11 +52,24 @@ class Repositories
|
|
43
52
|
repo=client.team_repositories(config["TeamID"])
|
44
53
|
end
|
45
54
|
repo.each do |i|
|
46
|
-
|
47
|
-
|
55
|
+
if regex==false
|
56
|
+
puts i.name
|
57
|
+
reposlist.push(i.name)
|
58
|
+
else
|
59
|
+
|
60
|
+
if i.name.match(/#{exp}/)
|
61
|
+
puts i.name
|
62
|
+
reposlist.push(i.name)
|
63
|
+
end
|
64
|
+
end
|
48
65
|
end
|
49
|
-
|
50
|
-
|
66
|
+
if reposlist.empty?
|
67
|
+
puts "No repository matches with that expression"
|
68
|
+
else
|
69
|
+
print "\n"
|
70
|
+
puts "Repositories found: #{reposlist.size}"
|
71
|
+
end
|
72
|
+
|
51
73
|
return reposlist
|
52
74
|
end
|
53
75
|
|
@@ -63,26 +85,6 @@ class Repositories
|
|
63
85
|
end
|
64
86
|
|
65
87
|
|
66
|
-
def show_repos_smart(client,config,exp,scope)
|
67
|
-
reposlist=[]
|
68
|
-
case
|
69
|
-
when scope==1
|
70
|
-
repo=client.repositories(config["User"])
|
71
|
-
#repo=client.all_repositories()
|
72
|
-
when scope==2
|
73
|
-
repo=client.organization_repositories(config["Org"])
|
74
|
-
when scope==3
|
75
|
-
repo=client.team_repositories(config["TeamID"])
|
76
|
-
end
|
77
|
-
repo.each do |i|
|
78
|
-
reposlist.push(i.name)
|
79
|
-
end
|
80
|
-
|
81
|
-
reposlist=Sys.new.search_rexp(reposlist,exp)
|
82
|
-
puts reposlist
|
83
|
-
return reposlist
|
84
|
-
end
|
85
|
-
|
86
88
|
def show_forks(client,config,scope)
|
87
89
|
print "\n"
|
88
90
|
forklist=[]
|
data/lib/actions/system.rb
CHANGED
@@ -12,21 +12,20 @@ class Sys
|
|
12
12
|
def load_config(configure_path,argv_token)
|
13
13
|
if File.exist?(configure_path)
|
14
14
|
if argv_token==nil
|
15
|
-
token=
|
15
|
+
token=self.get_login_token(configure_path)
|
16
16
|
else
|
17
17
|
token=argv_token
|
18
18
|
end
|
19
19
|
json = File.read("#{configure_path}/ghedsh-cache.json")
|
20
20
|
config=JSON.parse(json)
|
21
21
|
|
22
|
-
if token!=
|
22
|
+
if token!=nil
|
23
23
|
@client=self.login(token)
|
24
24
|
config["User"]=@client.login
|
25
25
|
userslist=self.load_users(configure_path)
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
self.save_users(configure_path,userslist)
|
27
|
+
if userslist["users"].detect {|f| f["#{config["User"]}"] }==nil
|
28
|
+
self.add_users(configure_path,"#{config["User"]}"=>token)
|
30
29
|
end
|
31
30
|
if argv_token!=nil
|
32
31
|
self.save_token(configure_path,argv_token)
|
@@ -44,12 +43,13 @@ class Sys
|
|
44
43
|
def load_config_user(configure_path, user)
|
45
44
|
if File.exist?(configure_path)
|
46
45
|
list=self.load_users(configure_path)
|
47
|
-
|
46
|
+
userFound=list["users"].detect {|f| f["#{user}"]}
|
47
|
+
if userFound!=nil
|
48
48
|
json = File.read("#{configure_path}/ghedsh-cache.json")
|
49
49
|
config=JSON.parse(json)
|
50
|
-
@client=self.login(
|
50
|
+
@client=self.login(userFound["#{user}"])
|
51
51
|
config["User"]=@client.login
|
52
|
-
self.save_token(configure_path,
|
52
|
+
self.save_token(configure_path,userFound["#{user}"])
|
53
53
|
return config
|
54
54
|
else
|
55
55
|
puts "User not found"
|
@@ -67,8 +67,24 @@ class Sys
|
|
67
67
|
return users
|
68
68
|
end
|
69
69
|
|
70
|
+
def add_users(path,data)
|
71
|
+
json=File.read("#{path}/ghedsh-users.json")
|
72
|
+
users=JSON.parse(json)
|
73
|
+
users["users"].push(data)
|
74
|
+
File.write("#{path}/ghedsh-users.json",users.to_json)
|
75
|
+
end
|
76
|
+
|
70
77
|
def save_token(path,token)
|
71
|
-
File.
|
78
|
+
json=File.read("#{path}/ghedsh-users.json")
|
79
|
+
login=JSON.parse(json)
|
80
|
+
login["login"]=token
|
81
|
+
File.write("#{path}/ghedsh-users.json",login.to_json)
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_login_token(path)
|
85
|
+
json=File.read("#{path}/ghedsh-users.json")
|
86
|
+
us=JSON.parse(json)
|
87
|
+
return us["login"]
|
72
88
|
end
|
73
89
|
|
74
90
|
def login(token)
|
@@ -90,9 +106,8 @@ class Sys
|
|
90
106
|
if us!=nil
|
91
107
|
puts "Login succesful as #{us.login}\n"
|
92
108
|
config["User"]=us.login
|
93
|
-
|
94
|
-
self.
|
95
|
-
File.write("#{configure_path}/ghedsh-token",token) #config["Token"]=token
|
109
|
+
self.add_users(configure_path,"#{config["User"]}"=>token)
|
110
|
+
self.save_token(configure_path,token)
|
96
111
|
@client=us
|
97
112
|
return config
|
98
113
|
end
|
@@ -111,9 +126,8 @@ class Sys
|
|
111
126
|
|
112
127
|
def create_config(configure_path)
|
113
128
|
con={:User=>nil,:Org=>nil,:Repo=>nil,:Team=>nil,:TeamID=>nil}
|
114
|
-
us={}
|
129
|
+
us={:login=>nil, :users=>[]}
|
115
130
|
FileUtils.mkdir_p(configure_path)
|
116
|
-
File.new("#{configure_path}/ghedsh-token","w")
|
117
131
|
File.write("#{configure_path}/ghedsh-cache.json",con.to_json)
|
118
132
|
File.write("#{configure_path}/ghedsh-users.json",us.to_json)
|
119
133
|
puts "Confiration files created in #{configure_path}"
|
@@ -138,7 +152,6 @@ class Sys
|
|
138
152
|
|
139
153
|
def search_rexp(list,exp)
|
140
154
|
list= list.select{|o| o.match(/#{exp}/)}
|
141
|
-
#puts list
|
142
155
|
return list
|
143
156
|
end
|
144
157
|
|
@@ -169,7 +182,7 @@ class Sys
|
|
169
182
|
begin
|
170
183
|
parser.parse!
|
171
184
|
rescue
|
172
|
-
puts "Argument error. Use ghedsh -
|
185
|
+
puts "Argument error. Use ghedsh -h or ghedsh --help for more information about the usage of this program"
|
173
186
|
exit
|
174
187
|
end
|
175
188
|
return options
|
data/lib/interface.rb
CHANGED
@@ -4,7 +4,6 @@ require 'json'
|
|
4
4
|
require 'readline'
|
5
5
|
require 'octokit'
|
6
6
|
require 'optparse'
|
7
|
-
|
8
7
|
require 'actions/help'
|
9
8
|
require 'actions/orgs'
|
10
9
|
require 'actions/repo'
|
@@ -13,6 +12,13 @@ require 'actions/teams'
|
|
13
12
|
require 'actions/user'
|
14
13
|
require 'version'
|
15
14
|
|
15
|
+
USER=1
|
16
|
+
ORGS=2
|
17
|
+
USER_REPO=10
|
18
|
+
ORGS_REPO=3
|
19
|
+
TEAM=4
|
20
|
+
TEAM_REPO=5
|
21
|
+
|
16
22
|
class Interface
|
17
23
|
attr_reader :option
|
18
24
|
attr_accessor :config
|
@@ -26,12 +32,18 @@ class Interface
|
|
26
32
|
def initialize
|
27
33
|
sysbh=Sys.new()
|
28
34
|
options=sysbh.parse
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
35
|
+
begin
|
36
|
+
if options[:user]==nil && options[:token]==nil && options[:path]!=nil
|
37
|
+
self.run(options[:path],options[:token],options[:user])
|
38
|
+
else
|
39
|
+
self.run("#{ENV['HOME']}/.ghedsh",options[:token],options[:user])
|
40
|
+
end
|
41
|
+
rescue SystemExit, Interrupt
|
42
|
+
raise
|
43
|
+
rescue Exception => e
|
44
|
+
puts "exit"
|
34
45
|
end
|
46
|
+
|
35
47
|
end
|
36
48
|
|
37
49
|
def add_history(value)
|
@@ -181,13 +193,13 @@ class Interface
|
|
181
193
|
repo=Repositories.new()
|
182
194
|
case
|
183
195
|
when @deep == 1
|
184
|
-
list=repo.show_repos(@client,@config,1)
|
196
|
+
list=repo.show_repos(@client,@config,1,nil)
|
185
197
|
self.add_history_str(2,list)
|
186
198
|
when @deep ==2
|
187
|
-
list=repo.show_repos(@client,@config,2)
|
199
|
+
list=repo.show_repos(@client,@config,2,nil)
|
188
200
|
self.add_history_str(2,list)
|
189
201
|
when @deep==4
|
190
|
-
list=repo.show_repos(@client,@config,3)
|
202
|
+
list=repo.show_repos(@client,@config,3,nil)
|
191
203
|
self.add_history_str(2,list)
|
192
204
|
end
|
193
205
|
end
|
@@ -240,6 +252,7 @@ class Interface
|
|
240
252
|
s=Sys.new
|
241
253
|
# orden de búsqueda: ~/.ghedsh.json ./ghedsh.json ENV["ghedsh"] --configpath path/to/file.json
|
242
254
|
|
255
|
+
#control de carga de parametros en el logueo de la aplicacion
|
243
256
|
if user!=nil
|
244
257
|
@config=s.load_config_user(config_path,user)
|
245
258
|
@client=s.client
|
@@ -257,6 +270,7 @@ class Interface
|
|
257
270
|
end
|
258
271
|
|
259
272
|
while ex != 0
|
273
|
+
|
260
274
|
op=Readline.readline(self.prompt,true)
|
261
275
|
opcd=op.split
|
262
276
|
case
|
@@ -289,11 +303,11 @@ class Interface
|
|
289
303
|
if opcd[0]=="repos" and opcd.size>1
|
290
304
|
case
|
291
305
|
when @deep==1
|
292
|
-
r.
|
306
|
+
r.show_repos(@client,@config,1,opcd[1])
|
293
307
|
when @deep==2
|
294
|
-
r.
|
308
|
+
r.show_repos(@client,@config,2,opcd[1])
|
295
309
|
when @deep==3
|
296
|
-
r.
|
310
|
+
r.show_repos(@client,@config,3,opcd[1])
|
297
311
|
end
|
298
312
|
end
|
299
313
|
if opcd[0]=="add_team_member"
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghedsh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Clemente
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-04-
|
12
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: octokit
|