Class: Repositories

Inherits:
Object
  • Object
show all
Defined in:
lib/actions/repo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRepositories

scope = 1 -> organization repos scope = 2 -> user repos scope = 3 -> team repos



15
16
17
# File 'lib/actions/repo.rb', line 15

def initialize
  @reposlist=[]
end

Instance Attribute Details

#reposlistObject (readonly)

Returns the value of attribute reposlist.



10
11
12
# File 'lib/actions/repo.rb', line 10

def reposlist
  @reposlist
end

Instance Method Details

#add_issue_cm(client, config, scope, id, path) ⇒ Object

add issue comment



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/actions/repo.rb', line 259

def add_issue_cm(client,config,scope,id,path)
  if self.issue_exist?(client,config,scope,id)
    puts "Write the description in you editor, press enter when you finish "

    if ENV["EDITOR"]==nil
      editor="vi"
    else
      editor=ENV["EDITOR"]
    end
    system("#{editor} #{path}/temp.txt")
    gets
    begin
      desc=File.read("#{path}/temp.txt")
    rescue
      puts "Empty description"
    end

    puts "This comment is gonna be created"
    puts "\n--------------------------------------"
    puts desc
    puts "--------------------------------------"
    puts "\nTo proceed press enter, or to discard press any key and enter"
    an=gets.chomp

    if an==""
      begin
        case
        when scope==USER_REPO
          if config["Repo"].split("/").size == 1
            client.add_comment(config["User"]+"/"+config["Repo"],id,desc)
          else
            client.add_comment(config["Repo"],id,desc)
          end
        when scope==ORGS_REPO || scope==TEAM_REPO
          client.add_comment(config["Org"]+"/"+config["Repo"],id,desc)
        end
        puts "Comment created"
      rescue
        puts "Issue not found"
      end
    else
      puts "comment not created"
    end
    Sys.new().remove_temp("#{path}/temp.txt")
  else
    puts "Issue not found"
  end
end

#cat_file(client, config, path, scope) ⇒ Object



675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
# File 'lib/actions/repo.rb', line 675

def cat_file(client,config,path,scope)
  if path.match(/.\./)!=nil
    case
    when scope==USER_REPO
      if config["Repo"].split("/").size > 1
        begin
          data=Base64.decode64(client.content(config["Repo"],:path=>path).content)
        rescue Exception, Interrupt
          puts "File not found"
        end
      else
        begin
          data=Base64.decode64(client.content(config["User"]+"/"+config["Repo"],:path=>path).content)
        rescue Exception, Interrupt
          puts "File not found"
        end
      end

    when scope==ORGS_REPO
      begin
        data=Base64.decode64(client.content(config["Org"]+"/"+config["Repo"],:path=>path).content)
      rescue Exception, Interrupt
        puts "File not found"
      end
    when scope==TEAM_REPO
      begin
        data=Base64.decode64(client.content(config["Org"]+"/"+config["Repo"],:path=>path).content)
      rescue Exception, Interrupt
        puts "File not found"
      end
    end
    # s=Sys.new()
    # s.createTempFile(data)
    # s.execute_bash("vi -R #{data}")
    puts data
  else
    puts "#{path} is not a file."
  end
end

#change_privacy(client, config, repo, list, list_id, privacy) ⇒ Object



572
573
574
575
# File 'lib/actions/repo.rb', line 572

def change_privacy(client,config,repo,list,list_id,privacy)
  list.each do |i|
  end
end

#clone_repo(client, config, exp, scope) ⇒ Object

clone repositories exp = regular expression



615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
# File 'lib/actions/repo.rb', line 615

def clone_repo(client,config,exp,scope)
  web="https://github.com/"
  web2="[email protected]:"

  if scope==USER_REPO || scope==TEAM_REPO || scope==ORGS_REPO
    case
      when scope==USER_REPO
        if config["Repo"].split("/").size == 1
          command = "git clone #{web2}#{config["User"]}/#{config["Repo"]}.git"
        else
          command = "git clone #{web2}#{config["Repo"]}.git"
        end
      when scope==TEAM_REPO
        command = "git clone #{web2}#{config["Org"]}/#{config["Repo"]}.git"
      when scope==ORGS_REPO
        command = "git clone #{web2}#{config["Org"]}/#{config["Repo"]}.git"
    end
      system(command)
  else
    if exp.match(/^\//)
      exps=exp.split('/')
      list=self.get_repos_list(client,config,scope)
      list=Sys.new.search_rexp(list,exps[1])
    else
      list=[]
      list.push(exp)
    end

    if (list.empty?) == false
      case
      when scope==USER
        list.each do |i|
          command = "git clone #{web2}#{config["User"]}/#{i}.git"
          system(command)
        end
      when scope==ORGS
        list.each do |i|
          command = "git clone #{web2}#{config["Org"]}/#{i}.git"
          system(command)
        end
      end
    else
      puts "No repositories found it with the parameters given"
    end
  end
end

#close_issue(client, config, scope, id) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/actions/repo.rb', line 140

def close_issue(client,config,scope,id)
  begin
    case
    when scope==USER_REPO
      if config["Repo"].split("/").size == 1
        client.close_issue(config["User"]+"/"+config["Repo"],id)
      else
        client.close_issue(config["Repo"],id)
      end
    when scope==ORGS_REPO || scope==TEAM_REPO
      client.close_issue(config["Org"]+"/"+config["Repo"],id)
    end
  rescue
    puts "Issue not found"
  end
end

#create_issue(client, config, scope, path) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/actions/repo.rb', line 94

def create_issue(client,config,scope,path)
  title=""
  while title==""
    puts "\nInsert Issue title: "
    title=gets.chomp
  end
  puts "Write the description in you editor, press enter when you finish "

  if ENV["EDITOR"]==nil
    editor="vi"
  else
    editor=ENV["EDITOR"]
  end

  system("#{editor} #{path}/temp.txt")
  gets
  begin
    desc=File.read("#{path}/temp.txt")
  rescue
    puts "Empty description"
  end
  puts "This issue is gonna be created"
  puts "\ntitle: #{title}"
  puts "\n--------------------------------------"
  puts desc
  puts "--------------------------------------"
  puts "\nTo proceed press enter, or to discard press any key and enter"
  an=gets.chomp
  if an==""
    case
    when scope==USER_REPO
      if config["Repo"].split("/").size == 1
        client.create_issue(config["User"]+"/"+config["Repo"],title,desc)
      else
        client.create_issue(config["Repo"],title,desc)
      end
    when scope==ORGS_REPO || scope==TEAM_REPO
      client.create_issue(config["Org"]+"/"+config["Repo"],title,desc)
    end
    puts "Issue correctly created"
  else
    puts "Issue not created"
  end
  Sys.new().remove_temp("#{path}/temp.txt")
end

#create_repository(client, config, repo, empty, scope) ⇒ Object



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
# File 'lib/actions/repo.rb', line 506

def create_repository(client,config,repo,empty,scope)
  options=Hash.new
  if empty==false
    options[:auto_init]=true
  end

  case
  when scope==ORGS
    options[:organization]=config["Org"]
    if client.repository?("#{config["Org"]}/#{repo}")==false
      client.create_repository(repo,options)
      puts "created repository in #{config["Org"]}"
      return true
    else
      puts "\e[31m Already exists a repository with that name in #{config["Org"]}\e[0m"
      return false
    end
  when scope==USER
    if client.repository?("#{config["User"]}/#{repo}")==false
      client.create_repository(repo)
      puts "created repository #{config["User"]}"
      return true
    else
      puts "\e[31m Already exists a repository with that name in #{config["User"]}\e[0m"
      return false
    end
  when scope==TEAM
    puts "created repository in #{config["Org"]} team"
    options[:team_id]=config["TeamID"]
    options[:organization]=config["Org"]

    if client.repository?("#{config["Org"]}/#{repo}")==false
      client.create_repository(repo,options)
      puts "created repository in #{config["Org"]} for team #{config["Team"]}"
      return true
    else
      puts "\e[31m Already exists a repository with that name in #{config["Org"]}\e[0m"
      return false
    end
  end
end

#create_repository_by_teamlist(client, config, repo, list, list_id) ⇒ Object



577
578
579
580
581
582
583
584
585
586
# File 'lib/actions/repo.rb', line 577

def create_repository_by_teamlist(client,config,repo,list,list_id)
  options=Hash.new
  options[:organization]=config["Org"]
  y=0
  list.each do |i|
    options[:team_id]=list_id[y]
    client.create_repository(i+"/"+repo,false,options)
    y=y+1
  end
end

#delete_repository(client, config, repo, scope) ⇒ Object



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/actions/repo.rb', line 471

def delete_repository(client,config,repo,scope)
  if scope==ORGS
    if client.repository?("#{config["Org"]}/#{repo}")==false
      puts "\e[31m It doesn't exist a repository with that name in #{config["Org"]}\e[0m"
    else
      ex=false
      until ex==true
        puts "Repository #{repo} will be delete. Are you sure? (yes/no) (y/n)"
        op=gets.chomp
        if op=="yes" or op=="y"
          client.delete_repository("#{config["Org"]}/#{repo}")
          ex=true
        end
        if op=="no" or op=="n" then ex=true end
      end
    end
  end
  if scope==USER || scope==TEAM
    if client.repository?("#{config["User"]}/#{repo}")==false
      puts "\e[31m It doesn't exist a repository with that name in #{config["User"]}\e[0m"
    else
      ex=false
      until ex==true
        puts "Repository #{repo} will be delete. Are you sure? (yes/no) (y/n)"
        op=gets.chomp
        if op=="yes" or op=="y"
          client.delete_repository("#{config["User"]}/#{repo}")
          ex=true
        end
        if op=="no" or op=="n" then ex=true end
      end
    end
  end
end

#edit_repository(client, config, scope, privacy) ⇒ Object



548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
# File 'lib/actions/repo.rb', line 548

def edit_repository(client, config, scope, privacy)
  options=Hash.new
  if privacy=="true"
    privacy=true
  else
    privacy=false
  end
  options[:private]=privacy
  begin
    case
    when scope==USER_REPO
      if config["Repo"].split("/").size == 1
        mem=client.edit_repository(config["User"]+"/"+config["Repo"],options)
      else
        mem=client.edit_repository(config["Repo"],options)
      end
    when scope==ORGS_REPO || scope==TEAM_REPO
        mem=client.edit_repository(config["Org"]+"/"+config["Repo"],options)
    end
  rescue
    puts "Not allow to change privacy"
  end
end

#fork(client, config, repo) ⇒ Object



466
467
468
469
# File 'lib/actions/repo.rb', line 466

def fork(client,config,repo)
  mem=client.fork(repo)
  return mem
end

#get_files(client, config, path, show, scope) ⇒ Object



715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
# File 'lib/actions/repo.rb', line 715

def get_files(client,config,path,show,scope)
  #show=true
  if path.match(/.\./)==nil
    case
    when scope==USER_REPO
      if config["Repo"].split("/").size > 1
        begin
          list=client.content(config["Repo"],:path=>path)
        rescue Exception, Interrupt => e
          puts "No files found"
          show=false
        end
      else
        begin
          list=client.content(config["User"]+"/"+config["Repo"],:path=>path)
        rescue Exception, Interrupt => e
          puts "No files found"
          show=false
        end
      end

    when scope==ORGS_REPO
      begin
        list=client.content(config["Org"]+"/"+config["Repo"],:path=>path)
      rescue Exception, Interrupt => e
        puts "No files found"
        show=false
      end
    when scope==TEAM_REPO
      begin
        list=client.content(config["Org"]+"/"+config["Repo"],:path=>path)
      rescue Exception, Interrupt => e
        puts "No files found"
        show=false
      end
    end
    if show!=false
      self.show_files(list)
    else
      return list
    end
  else
    puts "#{path} is not a directory. If you want to open a file try to use cat <path>"
  end
end

#get_issues(client, config, scope) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/actions/repo.rb', line 174

def get_issues(client,config,scope)
  case
  when scope==USER_REPO
    if config["Repo"].split("/").size == 1
      mem=client.list_issues(config["User"]+"/"+config["Repo"],{:state=>"all"})
    else
      mem=client.list_issues(config["Repo"],{:state=>"all"})
    end
  when scope==ORGS_REPO || scope==TEAM_REPO
      mem=client.list_issues(config["Org"]+"/"+config["Repo"],{:state=>"all"})
  end
  return mem
end

#get_repos_list(client, config, scope) ⇒ Object

Gete the repository list from a given scope



589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
# File 'lib/actions/repo.rb', line 589

def get_repos_list(client,config,scope)
  reposlist=[]
  case
    when scope==USER
      repo=client.repositories
    when scope==ORGS
      repo=client.organization_repositories(config["Org"])
    when scope==TEAM
      repo=client.team_repositories(config["TeamID"])
  end
  repo.each do |i|
    if scope!=USER
      reposlist.push(i.name)
    else
      if i[:owner][:login]==config["User"]
        reposlist.push(i.name)
      else
        reposlist.push(i.full_name)
      end
    end
  end
  return reposlist
end

#info_repository(client, config, scope) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/actions/repo.rb', line 44

def info_repository(client,config,scope)
  empty=0
  begin
    case
    when scope==USER_REPO
        if config["Repo"].split("/").size == 1
          mem=client.repository(config["User"]+"/"+config["Repo"])
        else
          mem=client.repository(config["Repo"])
        end
    when scope==ORGS_REPO || scope==TEAM_REPO
        mem=client.repository(config["Org"]+"/"+config["Repo"])
    end
    rescue
     puts "The Repository is empty"
     empty=1
  end
  if empty==0
    puts "\n Name: \t\t#{mem[:name]}"
    puts " Full name: \t#{mem[:full_name]}"
    puts " Description: \t#{mem[:description]}"
    puts " Private: \t#{mem[:private]}"
    puts "\n Created: \t#{mem[:created_at]}"
    puts " Last update: \t#{mem[:updated_at]}"
    puts " Url: \t\t#{mem[:html_url]}"
    puts
  end
end

#issue_exist?(client, config, scope, id) ⇒ Boolean

Returns:

  • (Boolean)


308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/actions/repo.rb', line 308

def issue_exist?(client,config,scope,id)
  begin
    case
    when scope==USER_REPO
      if config["Repo"].split("/").size == 1
        client.issue(config["User"]+"/"+config["Repo"],id)
      else
        client.issue(config["Repo"],id)
      end
    when scope==ORGS_REPO || scope==TEAM_REPO
      client.issue(config["Org"]+"/"+config["Repo"],id)
    end
  rescue
    return false
  end
    return true
end

#open_issue(client, config, scope, id) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/actions/repo.rb', line 157

def open_issue(client,config,scope,id)
  begin
    case
    when scope==USER_REPO
      if config["Repo"].split("/").size == 1
        client.reopen_issue(config["User"]+"/"+config["Repo"],id)
      else
        client.reopen_issue(config["Repo"],id)
      end
    when scope==ORGS_REPO || scope==TEAM_REPO
      client.reopen_issue(config["Org"]+"/"+config["Repo"],id)
    end
  rescue
    puts "Issue not found"
  end
end

#open_repository(client, config, scope) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/actions/repo.rb', line 73

def open_repository(client,config,scope)
  case
  when scope==USER_REPO
      if config["Repo"].split("/").size == 1
        mem=client.repository(config["User"]+"/"+config["Repo"])
      else
        mem=client.repository(config["Repo"])
      end
  when scope==ORGS_REPO || scope==TEAM_REPO
      mem=client.repository(config["Org"]+"/"+config["Repo"])
  end

  case
  when RUBY_PLATFORM.downcase.include?("darwin")
    system("open #{mem[:html_url]}")
  when RUBY_PLATFORM.downcase.include?("linux")
    system("xdg-open #{mem[:html_url]}")
  end

end

#show_collaborators(client, config, scope) ⇒ Object



444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/actions/repo.rb', line 444

def show_collaborators(client,config,scope)
  print "\n"
  collalist=[]
  case
  when scope==USER_REPO
    if config["Repo"].split("/").size == 1
      mem=client.collaborators(config["User"]+"/"+config["Repo"],"master")
    else
      mem=client.collaborators(config["Repo"],"master")
    end
  when scope==ORGS_REPO || scope==TEAM_REPO
    mem=client.collaborators(config["Org"]+"/"+config["Repo"])
  end
  print " Collaborators\n\n"
  mem.each do |i|
    puts " #{i[:login]}"
    collalist.push(i[:login])
  end
  print "\n"
  return collalist
end

#show_commits(client, config, scope) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/actions/repo.rb', line 19

def show_commits(client,config,scope)
  print "\n"
  empty=0
  begin
    case
    when scope==USER_REPO
        if config["Repo"].split("/").size == 1
          mem=client.commits(config["User"]+"/"+config["Repo"],"master")
        else
          mem=client.commits(config["Repo"],"master")
        end
    when scope==ORGS_REPO || scope==TEAM_REPO
        mem=client.commits(config["Org"]+"/"+config["Repo"],"master")
    end
  rescue
    puts "The Repository is empty"
    empty=1
  end
  if empty==0
    mem.each do |i|
      print i[:sha],"\n",i[:commit][:author][:name],"\n",i[:commit][:author][:date],"\n",i[:commit][:message],"\n\n"
    end
  end
end

#show_files(list) ⇒ Object



662
663
664
665
666
667
668
669
670
671
672
673
# File 'lib/actions/repo.rb', line 662

def show_files(list)
  print "\n"

  list.each do |i|
    if i.name.match(/.\./)!=nil
      puts i.name
    else
      puts "\e[33m#{i.name}\e[0m"
    end
  end
  print "\n"
end

#show_forks(client, config, scope) ⇒ Object



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/actions/repo.rb', line 419

def show_forks(client,config,scope)
  print "\n"
  forklist=[]
  case
  when scope==USER_REPO
    if config["Repo"].split("/").size == 1
      mem=client.forks(config["User"]+"/"+config["Repo"],"master")
    else
      mem=client.forks(config["Repo"],"master")
    end
  when scope==ORGS_REPO || scope==TEAM_REPO
      mem=client.forks(config["Org"]+"/"+config["Repo"])
  end
  if mem.size==0
    puts "No forks found in this repository"
  else
    mem.each do |i|
      puts i[:login]
      forklist.push(i[:login])
    end
    print "\n"
    return forklist
  end
end

#show_issue(client, config, scope, id) ⇒ Object

show an specific issue from a repository



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/actions/repo.rb', line 201

def show_issue(client,config,scope,id)
  issfound=0
  issues_list=self.get_issues(client,config,scope)
  if issues_list!=nil
    issues_list.each do |i|
      if i[:number]==id.to_i
        puts
        puts "  --------------------------------------"
        puts "  Author: #{i[:user][:login]}"
        puts "  ##{i[:number]} state: #{i[:state]}"
        puts "  title: #{i[:title]}"
        puts "  --------------------------------------"
        puts "\n#{i[:body]}"
        issfound=1
        print "\nShow comments (Press any key and enter to proceed, or only enter to skip) -> "
        show=gets.chomp
        puts
        if show!=""
          self.show_issues_cm(client,config,scope,i[:number])
        end
      end
    end
  end
  if issfound==0
    puts "Issue not found"
  end
  puts "\n"
end

#show_issues(client, config, scope) ⇒ Object

show all issues from a repository



189
190
191
192
193
194
195
196
197
198
# File 'lib/actions/repo.rb', line 189

def show_issues(client,config,scope)
    print "\n"
    mem=self.get_issues(client,config,scope)
    mem.each do |i|
      #print i[:sha],"\n",i[:commit][:author][:name],"\n",i[:commit][:author][:date],"\n",i[:commit][:message],"\n\n"
      puts "##{i[:number]} state: #{i[:state]} -> #{i[:title]} "
    end
    print "\n"
    return mem
end

#show_issues_cm(client, config, scope, id) ⇒ Object

show issues comment



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/actions/repo.rb', line 231

def show_issues_cm(client,config,scope,id)
  case
  when scope==USER_REPO
    if config["Repo"].split("/").size == 1
      mem=client.issue_comments(config["User"]+"/"+config["Repo"],id)
    else
      mem=client.issue_comments(config["Repo"],id)
    end
  when scope==ORGS_REPO || scope==TEAM_REPO
      mem=client.issue_comments(config["Org"]+"/"+config["Repo"],id)
  end
  if mem!=nil
    puts
    puts " < COMMENTS (#{mem.size}) >"
    mem.each do |i|
      puts
      puts " --------------------------------------"
      puts " Author: #{i[:user][:login]} "
      puts " Date: #{i[:created_at]}"
      puts " --------------------------------------"
      puts "\n#{i[:body]}"
    end
  else
    puts "No comments have been added yet"
  end
end

#show_repos(client, config, scope, exp) ⇒ Object

Show repositories and return a list of them exp = regular expression



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/actions/repo.rb', line 328

def show_repos(client,config,scope,exp)
  print "\n"
  rlist=[]
  options=Hash.new
  o=Organizations.new
  regex=false
  force_exit=false

  if exp!=nil
    if exp.match(/^\//)
      regex=true
      sp=exp.split('/')
      exp=Regexp.new(sp[1],sp[2])
    end
  end

  case
    when scope==USER
      repo=client.repositories(options) #config["User"]
      listorgs=o.read_orgs(client)
    when scope==ORGS
      repo=client.organization_repositories(config["Org"])
    when scope==TEAM
      repo=client.team_repositories(config["TeamID"])
  end

  counter=0
  allpages=true

  repo.each do |i|
    if force_exit==false
      if regex==false
        if counter==100 && allpages==true
          op=Readline.readline("\nThere are more results. Show next repositories (press any key), show all repositories (press a) or quit (q): ",true)
          if op=="a"
            allpages=false
          end
          if op=="q"
            force_exit=true
          end
          counter=0
        end
        if scope ==USER
          if i[:owner][:login]==config["User"]
            puts i.name
            rlist.push(i.name)
          else
            puts i.full_name
            rlist.push(i.full_name)
          end
        else
          puts i.name
          rlist.push(i.name)
        end
        counter=counter+1
      else
        if i.name.match(exp)
          if scope ==USER
            puts i.full_name
            rlist.push(i.full_name)
          else
            puts i.name
            rlist.push(i.name)
          end
            counter=counter+1
          end
      end
    end
  end

  if rlist.empty?
    puts "\e[31m No repository matches with that expression\e[0m"
  else
    print "\n"
    puts "Repositories found: #{rlist.size}"
  end

  return rlist
end

#show_user_orgs_repos(client, config, listorgs) ⇒ Object



408
409
410
411
412
413
414
415
416
417
# File 'lib/actions/repo.rb', line 408

def show_user_orgs_repos(client,config,listorgs)
  options=Hash.new
  options[:member]=config["User"]
  listorgs.each do |i|
    repo=client.organization_repositories(i,options)
        repo.each do |y|
          puts y.name
        end
  end
end