ghedsh 1.1.40 → 2.3.8

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.
data/lib/actions/repo.rb DELETED
@@ -1,832 +0,0 @@
1
- require 'readline'
2
- require 'octokit'
3
- require 'json'
4
- require 'readline'
5
- require 'require_all'
6
- require 'base64'
7
- require_rel '.'
8
-
9
- class Repositories
10
- attr_reader :reposlist
11
- attr_reader :clonedrepos
12
- #scope = 1 -> organization repos
13
- #scope = 2 -> user repos
14
- #scope = 3 -> team repos
15
-
16
- def initialize
17
- @reposlist=[]
18
- @clonedrepos=Sys.new.load_clonefile("#{ENV['HOME']}/.ghedsh")
19
- end
20
-
21
- def clonedpush()
22
- Sys.new.refresh_clonefile("#{ENV['HOME']}/.ghedsh",@clonedrepos)
23
- end
24
-
25
- def show_commits(client,config,scope)
26
- print "\n"
27
- empty=0
28
- begin
29
- case
30
- when scope==USER_REPO
31
- if config["Repo"].split("/").size == 1
32
- mem=client.commits(config["User"]+"/"+config["Repo"],"master")
33
- else
34
- mem=client.commits(config["Repo"],"master")
35
- end
36
- when scope==ORGS_REPO || scope==TEAM_REPO
37
- mem=client.commits(config["Org"]+"/"+config["Repo"],"master")
38
- end
39
- rescue
40
- puts "The Repository is empty"
41
- empty=1
42
- end
43
- if empty==0
44
- mem.each do |i|
45
- print i[:sha],"\n",i[:commit][:author][:name],"\n",i[:commit][:author][:date],"\n",i[:commit][:message],"\n\n"
46
- end
47
- end
48
- end
49
-
50
- def info_repository(client,config,scope)
51
- empty=0
52
- begin
53
- case
54
- when scope==USER_REPO
55
- if config["Repo"].split("/").size == 1
56
- mem=client.repository(config["User"]+"/"+config["Repo"])
57
- else
58
- mem=client.repository(config["Repo"])
59
- end
60
- when scope==ORGS_REPO || scope==TEAM_REPO
61
- mem=client.repository(config["Org"]+"/"+config["Repo"])
62
- end
63
- rescue
64
- puts "The Repository is empty"
65
- empty=1
66
- end
67
- if empty==0
68
- puts "\n Name: \t\t#{mem[:name]}"
69
- puts " Full name: \t#{mem[:full_name]}"
70
- puts " Description: \t#{mem[:description]}"
71
- puts " Private: \t#{mem[:private]}"
72
- puts "\n Created: \t#{mem[:created_at]}"
73
- puts " Last update: \t#{mem[:updated_at]}"
74
- puts " Url: \t\t#{mem[:html_url]}"
75
- puts
76
- end
77
- end
78
-
79
- def open_repository(client,config,scope)
80
- case
81
- when scope==USER_REPO
82
- if config["Repo"].split("/").size == 1
83
- mem=client.repository(config["User"]+"/"+config["Repo"])
84
- else
85
- mem=client.repository(config["Repo"])
86
- end
87
- when scope==ORGS_REPO || scope==TEAM_REPO
88
- mem=client.repository(config["Org"]+"/"+config["Repo"])
89
- end
90
- Sys.new.open_url(mem[:html_url])
91
- end
92
-
93
- def create_issue(client,config,scope,path)
94
- title=""
95
- while title==""
96
- puts "\nInsert Issue title: "
97
- title=gets.chomp
98
- end
99
- puts "Write the description in you editor, press enter when you finish "
100
-
101
- if ENV["EDITOR"]==nil
102
- editor="vi"
103
- else
104
- editor=ENV["EDITOR"]
105
- end
106
-
107
- system("#{editor} #{path}/temp.txt")
108
- gets
109
- begin
110
- desc=File.read("#{path}/temp.txt")
111
- rescue
112
- puts "Empty description"
113
- end
114
- puts "This issue is gonna be created"
115
- puts "\ntitle: #{title}"
116
- puts "\n--------------------------------------"
117
- puts desc
118
- puts "--------------------------------------"
119
- puts "\nTo proceed press enter, or to discard press any key and enter"
120
- an=gets.chomp
121
- if an==""
122
- case
123
- when scope==USER_REPO
124
- if config["Repo"].split("/").size == 1
125
- client.create_issue(config["User"]+"/"+config["Repo"],title,desc)
126
- else
127
- client.create_issue(config["Repo"],title,desc)
128
- end
129
- when scope==ORGS_REPO || scope==TEAM_REPO
130
- client.create_issue(config["Org"]+"/"+config["Repo"],title,desc)
131
- end
132
- puts "Issue correctly created"
133
- else
134
- puts "Issue not created"
135
- end
136
- Sys.new().remove_temp("#{path}/temp.txt")
137
- end
138
-
139
- def close_issue(client,config,scope,id)
140
- begin
141
- case
142
- when scope==USER_REPO
143
- if config["Repo"].split("/").size == 1
144
- client.close_issue(config["User"]+"/"+config["Repo"],id)
145
- else
146
- client.close_issue(config["Repo"],id)
147
- end
148
- when scope==ORGS_REPO || scope==TEAM_REPO
149
- client.close_issue(config["Org"]+"/"+config["Repo"],id)
150
- end
151
- rescue
152
- puts "Issue not found"
153
- end
154
- end
155
-
156
- def open_issue(client,config,scope,id)
157
- begin
158
- case
159
- when scope==USER_REPO
160
- if config["Repo"].split("/").size == 1
161
- client.reopen_issue(config["User"]+"/"+config["Repo"],id)
162
- else
163
- client.reopen_issue(config["Repo"],id)
164
- end
165
- when scope==ORGS_REPO || scope==TEAM_REPO
166
- client.reopen_issue(config["Org"]+"/"+config["Repo"],id)
167
- end
168
- rescue
169
- puts "Issue not found"
170
- end
171
- end
172
-
173
- def get_issues(client,config,scope)
174
- case
175
- when scope==USER_REPO
176
- if config["Repo"].split("/").size == 1
177
- mem=client.list_issues(config["User"]+"/"+config["Repo"],{:state=>"all"})
178
- else
179
- mem=client.list_issues(config["Repo"],{:state=>"all"})
180
- end
181
- when scope==ORGS_REPO || scope==TEAM_REPO
182
- mem=client.list_issues(config["Org"]+"/"+config["Repo"],{:state=>"all"})
183
- end
184
- return mem
185
- end
186
-
187
- #show all issues from a repository
188
- def show_issues(client,config,scope)
189
- print "\n"
190
- mem=self.get_issues(client,config,scope)
191
- mem.each do |i|
192
- #print i[:sha],"\n",i[:commit][:author][:name],"\n",i[:commit][:author][:date],"\n",i[:commit][:message],"\n\n"
193
- puts "##{i[:number]} state: #{i[:state]} -> #{i[:title]} "
194
- end
195
- print "\n"
196
- return mem
197
- end
198
-
199
- #show an specific issue from a repository
200
- def show_issue(client,config,scope,id)
201
- issfound=0
202
- issues_list=self.get_issues(client,config,scope)
203
- if issues_list!=nil
204
- issues_list.each do |i|
205
- if i[:number]==id.to_i
206
- puts
207
- puts " --------------------------------------"
208
- puts " Author: #{i[:user][:login]}"
209
- puts " ##{i[:number]} state: #{i[:state]}"
210
- puts " title: #{i[:title]}"
211
- puts " --------------------------------------"
212
- puts "\n#{i[:body]}"
213
- issfound=1
214
- print "\nShow comments (Press any key and enter to proceed, or only enter to skip) -> "
215
- show=gets.chomp
216
- puts
217
- if show!=""
218
- self.show_issues_cm(client,config,scope,i[:number])
219
- end
220
- end
221
- end
222
- end
223
- if issfound==0
224
- puts "Issue not found"
225
- end
226
- puts "\n"
227
- end
228
-
229
- #show issues comment
230
- def show_issues_cm(client,config,scope,id)
231
- case
232
- when scope==USER_REPO
233
- if config["Repo"].split("/").size == 1
234
- mem=client.issue_comments(config["User"]+"/"+config["Repo"],id)
235
- else
236
- mem=client.issue_comments(config["Repo"],id)
237
- end
238
- when scope==ORGS_REPO || scope==TEAM_REPO
239
- mem=client.issue_comments(config["Org"]+"/"+config["Repo"],id)
240
- end
241
- if mem!=nil
242
- puts
243
- puts " < COMMENTS (#{mem.size}) >"
244
- mem.each do |i|
245
- puts
246
- puts " --------------------------------------"
247
- puts " Author: #{i[:user][:login]} "
248
- puts " Date: #{i[:created_at]}"
249
- puts " --------------------------------------"
250
- puts "\n#{i[:body]}"
251
- end
252
- else
253
- puts "No comments have been added yet"
254
- end
255
- end
256
-
257
- #add issue comment
258
- def add_issue_cm(client,config,scope,id,path)
259
- if self.issue_exist?(client,config,scope,id)
260
- puts "Write the description in you editor, press enter when you finish "
261
-
262
- if ENV["EDITOR"]==nil
263
- editor="vi"
264
- else
265
- editor=ENV["EDITOR"]
266
- end
267
- system("#{editor} #{path}/temp.txt")
268
- gets
269
- begin
270
- desc=File.read("#{path}/temp.txt")
271
- rescue
272
- puts "Empty description"
273
- end
274
-
275
- puts "This comment is gonna be created"
276
- puts "\n--------------------------------------"
277
- puts desc
278
- puts "--------------------------------------"
279
- puts "\nTo proceed press enter, or to discard press any key and enter"
280
- an=gets.chomp
281
-
282
- if an==""
283
- begin
284
- case
285
- when scope==USER_REPO
286
- if config["Repo"].split("/").size == 1
287
- client.add_comment(config["User"]+"/"+config["Repo"],id,desc)
288
- else
289
- client.add_comment(config["Repo"],id,desc)
290
- end
291
- when scope==ORGS_REPO || scope==TEAM_REPO
292
- client.add_comment(config["Org"]+"/"+config["Repo"],id,desc)
293
- end
294
- puts "Comment created"
295
- rescue
296
- puts "Issue not found"
297
- end
298
- else
299
- puts "comment not created"
300
- end
301
- Sys.new().remove_temp("#{path}/temp.txt")
302
- else
303
- puts "Issue not found"
304
- end
305
- end
306
-
307
- def issue_exist?(client,config,scope,id)
308
- begin
309
- case
310
- when scope==USER_REPO
311
- if config["Repo"].split("/").size == 1
312
- client.issue(config["User"]+"/"+config["Repo"],id)
313
- else
314
- client.issue(config["Repo"],id)
315
- end
316
- when scope==ORGS_REPO || scope==TEAM_REPO
317
- client.issue(config["Org"]+"/"+config["Repo"],id)
318
- end
319
- rescue
320
- return false
321
- end
322
- return true
323
- end
324
-
325
- #Show repositories and return a list of them
326
- #exp = regular expression
327
- def show_repos(client,config,scope,exp)
328
- print "\n"
329
- rlist=[]
330
- options=Hash.new
331
- o=Organizations.new
332
- regex=false
333
- force_exit=false
334
-
335
- if exp!=nil
336
- if exp.match(/^\//)
337
- regex=true
338
- sp=exp.split('/')
339
- exp=Regexp.new(sp[1],sp[2])
340
- end
341
- end
342
-
343
- case
344
- when scope==USER
345
- repo=client.repositories(options) #config["User"]
346
- listorgs=o.read_orgs(client)
347
- when scope==ORGS
348
- repo=client.organization_repositories(config["Org"])
349
- when scope==TEAM
350
- repo=client.team_repositories(config["TeamID"])
351
- end
352
-
353
- counter=0
354
- allpages=true
355
-
356
- repo.each do |i|
357
- if force_exit==false
358
- if regex==false
359
- if counter==100 && allpages==true
360
- op=Readline.readline("\nThere are more results. Show next repositories (press any key), show all repositories (press a) or quit (q): ",true)
361
- if op=="a"
362
- allpages=false
363
- end
364
- if op=="q"
365
- force_exit=true
366
- end
367
- counter=0
368
- end
369
- if scope ==USER
370
- if i[:owner][:login]==config["User"]
371
- puts i.name
372
- rlist.push(i.name)
373
- else
374
- puts i.full_name
375
- rlist.push(i.full_name)
376
- end
377
- else
378
- puts i.name
379
- rlist.push(i.name)
380
- end
381
- counter=counter+1
382
- else
383
- if i.name.match(exp)
384
- if scope ==USER
385
- puts i.full_name
386
- rlist.push(i.full_name)
387
- else
388
- puts i.name
389
- rlist.push(i.name)
390
- end
391
- counter=counter+1
392
- end
393
- end
394
- end
395
- end
396
-
397
- if rlist.empty?
398
- puts "\e[31m No repository matches with that expression\e[0m"
399
- else
400
- print "\n"
401
- puts "Repositories found: #{rlist.size}"
402
- end
403
-
404
- if force_exit==true
405
- return self.get_repos_list(client,config,scope)
406
- else
407
- return rlist
408
- end
409
- end
410
-
411
- def show_user_orgs_repos(client,config,listorgs)
412
- options=Hash.new
413
- options[:member]=config["User"]
414
- listorgs.each do |i|
415
- repo=client.organization_repositories(i,options)
416
- repo.each do |y|
417
- puts y.name
418
- end
419
- end
420
- end
421
-
422
- def show_forks(client,config,scope)
423
- print "\n"
424
- forklist=[]
425
- case
426
- when scope==USER_REPO
427
- if config["Repo"].split("/").size == 1
428
- mem=client.forks(config["User"]+"/"+config["Repo"],"master")
429
- else
430
- mem=client.forks(config["Repo"],"master")
431
- end
432
- when scope==ORGS_REPO || scope==TEAM_REPO
433
- mem=client.forks(config["Org"]+"/"+config["Repo"])
434
- end
435
- if mem.size==0
436
- puts "No forks found in this repository"
437
- else
438
- mem.each do |i|
439
- puts i[:login]
440
- forklist.push(i[:login])
441
- end
442
- print "\n"
443
- return forklist
444
- end
445
- end
446
- def add_collaborator(client,repo,name)
447
- client.add_collaborator(repo,name)
448
- end
449
-
450
- def show_collaborators(client,config,scope)
451
- print "\n"
452
- collalist=[]
453
- case
454
- when scope==USER_REPO
455
- if config["Repo"].split("/").size == 1
456
- mem=client.collaborators(config["User"]+"/"+config["Repo"])
457
- else
458
- mem=client.collaborators(config["Repo"])
459
- end
460
- when scope==ORGS_REPO || scope==TEAM_REPO
461
- mem=client.collaborators(config["Org"]+"/"+config["Repo"])
462
- end
463
- print " Collaborators\n\n"
464
- if mem!=nil
465
- mem.each do |i|
466
- puts " #{i[:login]}"
467
- collalist.push(i[:login])
468
- end
469
- print "\n"
470
- end
471
- return collalist
472
- end
473
-
474
- def fork(client,config,repo)
475
- mem=client.fork(repo)
476
- return mem
477
- end
478
-
479
- def delete_repository(client,config,repo,scope)
480
- if scope==ORGS
481
- if client.repository?("#{config["Org"]}/#{repo}")==false
482
- puts "\e[31m It doesn't exist a repository with that name in #{config["Org"]}\e[0m"
483
- else
484
- ex=false
485
- until ex==true
486
- puts "Repository #{repo} will be delete. Are you sure? (yes/no) (y/n)"
487
- op=gets.chomp
488
- if op=="yes" or op=="y"
489
- client.delete_repository("#{config["Org"]}/#{repo}")
490
- ex=true
491
- end
492
- if op=="no" or op=="n" then ex=true end
493
- end
494
- end
495
- end
496
- if scope==USER || scope==TEAM
497
- if client.repository?("#{config["User"]}/#{repo}")==false
498
- puts "\e[31m It doesn't exist a repository with that name in #{config["User"]}\e[0m"
499
- else
500
- ex=false
501
- until ex==true
502
- puts "Repository #{repo} will be delete. Are you sure? (yes/no) (y/n)"
503
- op=gets.chomp
504
- if op=="yes" or op=="y"
505
- client.delete_repository("#{config["User"]}/#{repo}")
506
- ex=true
507
- end
508
- if op=="no" or op=="n" then ex=true end
509
- end
510
- end
511
- end
512
- end
513
-
514
- def create_repository(client,config,repo,empty,scope)
515
- options=Hash.new
516
- if empty==false
517
- options[:auto_init]=true
518
- end
519
-
520
- case
521
- when scope==ORGS
522
- options[:organization]=config["Org"]
523
- if client.repository?("#{config["Org"]}/#{repo}")==false
524
- client.create_repository(repo,options)
525
- puts "created repository in #{config["Org"]}"
526
- return true
527
- else
528
- puts "\e[31m Already exists a repository with that name in #{config["Org"]}\e[0m"
529
- return false
530
- end
531
- when scope==USER
532
- if client.repository?("#{config["User"]}/#{repo}")==false
533
- client.create_repository(repo)
534
- puts "created repository #{config["User"]}"
535
- return true
536
- else
537
- puts "\e[31m Already exists a repository with that name in #{config["User"]}\e[0m"
538
- return false
539
- end
540
- when scope==TEAM
541
- puts "created repository in #{config["Org"]} team"
542
- options[:team_id]=config["TeamID"]
543
- options[:organization]=config["Org"]
544
-
545
- if client.repository?("#{config["Org"]}/#{repo}")==false
546
- client.create_repository(repo,options)
547
- puts "created repository in #{config["Org"]} for team #{config["Team"]}"
548
- return true
549
- else
550
- puts "\e[31m Already exists a repository with that name in #{config["Org"]}\e[0m"
551
- return false
552
- end
553
- end
554
- end
555
-
556
- def edit_repository(client, config, scope, privacy)
557
- options=Hash.new
558
- if privacy=="true"
559
- privacy=true
560
- else
561
- privacy=false
562
- end
563
- options[:private]=privacy
564
- begin
565
- case
566
- when scope==USER_REPO
567
- if config["Repo"].split("/").size == 1
568
- mem=client.edit_repository(config["User"]+"/"+config["Repo"],options)
569
- else
570
- mem=client.edit_repository(config["Repo"],options)
571
- end
572
- when scope==ORGS_REPO || scope==TEAM_REPO
573
- mem=client.edit_repository(config["Org"]+"/"+config["Repo"],options)
574
- end
575
- rescue
576
- puts "Not allow to change privacy"
577
- end
578
- end
579
-
580
- def change_privacy(client,config,repo,list,list_id,privacy)
581
- list.each do |i|
582
- end
583
- end
584
-
585
- def create_repository_by_teamlist(client,config,repo,list,list_id)
586
- options=Hash.new
587
- options[:organization]=config["Org"]
588
- y=0
589
- list.each do |i|
590
- options[:team_id]=list_id[y]
591
- client.create_repository(i+"/"+repo,false,options)
592
- y=y+1
593
- end
594
- end
595
-
596
- #Gete the repository list from a given scope
597
- def get_repos_list(client,config,scope)
598
- reposlist=[]
599
- case
600
- when scope==USER
601
- repo=client.repositories()
602
- when scope==ORGS
603
- repo=client.organization_repositories(config["Org"])
604
- when scope==ASSIG
605
- repo=client.organization_repositories(config["Org"])
606
- when scope==TEAM
607
- repo=client.team_repositories(config["TeamID"])
608
- end
609
- if repo!=nil
610
- repo.each do |i|
611
- if scope!=USER
612
- reposlist.push(i.name)
613
- else
614
- if i[:owner][:login]==config["User"]
615
- reposlist.push(i.name)
616
- else
617
- reposlist.push(i.full_name)
618
- end
619
- end
620
- end
621
- end
622
- return reposlist
623
- end
624
-
625
- #clone repositories
626
- #exp = regular expression
627
- def clone_repo(client,config,exp,scope)
628
- web="https://github.com/"
629
- web2="git@github.com:"
630
-
631
- if scope==USER_REPO || scope==TEAM_REPO || scope==ORGS_REPO
632
- case
633
- when scope==USER_REPO
634
- if config["Repo"].split("/").size == 1
635
- command = "git clone #{web2}#{config["User"]}/#{config["Repo"]}.git"
636
- else
637
- command = "git clone #{web2}#{config["Repo"]}.git"
638
- end
639
- when scope==TEAM_REPO
640
- command = "git clone #{web2}#{config["Org"]}/#{config["Repo"]}.git"
641
- when scope==ORGS_REPO
642
- command = "git clone #{web2}#{config["Org"]}/#{config["Repo"]}.git"
643
- end
644
- system(command)
645
- if scope==USER_REPO
646
- @clonedrepos.push("#{config["User"]}/#{config["Repo"]}")
647
- else
648
- @clonedrepos.push("#{config["Org"]}/#{config["Repo"]}")
649
- end
650
- self.clonedpush()
651
- else
652
- if exp.match(/^\//)
653
- exps=exp.split('/')
654
- list=self.get_repos_list(client,config,scope)
655
- list=Sys.new.search_rexp(list,exps[1])
656
- else
657
- list=[]
658
- list.push(exp)
659
- end
660
-
661
- if (list.empty?) == false
662
- case
663
- when scope==USER
664
- list.each do |i|
665
- if i.include?("/")
666
- command = "git clone #{web2}#{i}.git"
667
- @clonedrepos.push(i)
668
- else
669
- command = "git clone #{web2}#{config["User"]}/#{i}.git"
670
- @clonedrepos.push("#{config["User"]}/#{i}")
671
- end
672
- system(command)
673
- end
674
- when scope==ORGS
675
- list.each do |i|
676
- command = "git clone #{web2}#{config["Org"]}/#{i}.git"
677
- @clonedrepos.push("#{config["Org"]}/#{i}")
678
- system(command)
679
- end
680
- when scope==ASSIG
681
- list.each do |i|
682
- command = "git clone #{web2}#{config["Org"]}/#{i}.git"
683
- @clonedrepos.push("#{config["Org"]}/#{i}")
684
- system(command)
685
- end
686
- end
687
- self.clonedpush()
688
- else
689
- puts "No repositories found it with the parameters given"
690
- end
691
- end
692
- end
693
-
694
- def rm_clone(client,config,scope,all,exp)
695
- files=@clonedrepos
696
-
697
- if all==false
698
- if exp.match(/^\//)
699
- exps=exp.split('/')
700
- list=self.get_repos_list(client,config,scope)
701
- list=Sys.new.search_rexp(files,exps[1])
702
- else
703
- list=[]
704
- list.push(exp)
705
- end
706
- files=list
707
- end
708
- if files!=[]
709
- print "\n"
710
- puts files
711
- puts "Are gone to be removed (y/N)"
712
- op=gets.chomp
713
- if op.downcase=="y" || op.downcase=="yes"
714
- files.each do |i|
715
- i=i.delete("\"")
716
- if !File.exists?(i)
717
- sp=i.split("/")
718
- i=sp[1]
719
- end
720
- system("rm -rf #{i}")
721
- if all==false
722
- @clonedrepos.delete(i)
723
- end
724
- end
725
- puts "Cloned files deleted"
726
- if all==true then @clonedrepos.clear end
727
- self.clonedpush()
728
- end
729
- else
730
- puts "Not cloned files found"
731
- end
732
- end
733
-
734
- def show_files(list)
735
- print "\n"
736
-
737
- list.each do |i|
738
- if i.name.match(/.\./)!=nil
739
- puts i.name
740
- else
741
- puts "\e[33m#{i.name}\e[0m"
742
- end
743
- end
744
- print "\n"
745
- end
746
-
747
- def cat_file(client,config,path,scope)
748
- if path.match(/.\./)!=nil
749
- case
750
- when scope==USER_REPO
751
- if config["Repo"].split("/").size > 1
752
- begin
753
- data=Base64.decode64(client.content(config["Repo"],:path=>path).content)
754
- rescue Exception, Interrupt
755
- puts "File not found"
756
- end
757
- else
758
- begin
759
- data=Base64.decode64(client.content(config["User"]+"/"+config["Repo"],:path=>path).content)
760
- rescue Exception, Interrupt
761
- puts "File not found"
762
- end
763
- end
764
-
765
- when scope==ORGS_REPO
766
- begin
767
- data=Base64.decode64(client.content(config["Org"]+"/"+config["Repo"],:path=>path).content)
768
- rescue Exception, Interrupt
769
- puts "File not found"
770
- end
771
- when scope==TEAM_REPO
772
- begin
773
- data=Base64.decode64(client.content(config["Org"]+"/"+config["Repo"],:path=>path).content)
774
- rescue Exception, Interrupt
775
- puts "File not found"
776
- end
777
- end
778
- # s=Sys.new()
779
- # s.createTempFile(data)
780
- # s.execute_bash("vi -R #{data}")
781
- puts data
782
- else
783
- puts "#{path} is not a file."
784
- end
785
- end
786
-
787
- def get_files(client,config,path,show,scope)
788
- #show=true
789
- if path.match(/.\./)==nil
790
- case
791
- when scope==USER_REPO
792
- if config["Repo"].split("/").size > 1
793
- begin
794
- list=client.content(config["Repo"],:path=>path)
795
- rescue Exception, Interrupt => e
796
- puts "No files found"
797
- show=false
798
- end
799
- else
800
- begin
801
- list=client.content(config["User"]+"/"+config["Repo"],:path=>path)
802
- rescue Exception, Interrupt => e
803
- puts "No files found"
804
- show=false
805
- end
806
- end
807
-
808
- when scope==ORGS_REPO
809
- begin
810
- list=client.content(config["Org"]+"/"+config["Repo"],:path=>path)
811
- rescue Exception, Interrupt => e
812
- puts "No files found"
813
- show=false
814
- end
815
- when scope==TEAM_REPO
816
- begin
817
- list=client.content(config["Org"]+"/"+config["Repo"],:path=>path)
818
- rescue Exception, Interrupt => e
819
- puts "No files found"
820
- show=false
821
- end
822
- end
823
- if show!=false
824
- self.show_files(list)
825
- else
826
- return list
827
- end
828
- else
829
- puts "#{path} is not a directory. If you want to open a file try to use cat <path>"
830
- end
831
- end
832
- end