ghedsh 1.1.37 → 1.1.38

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8a23a5d1197103228e5bea247ad7fa410ce2b76
4
- data.tar.gz: ad4d31c781bbf7019e64e0328e08fd827c8833c0
3
+ metadata.gz: 6fe3fa8042c7233e78cc4fc2424d4ca7892675ea
4
+ data.tar.gz: c24e5dfc9d262fd21c4ba622816ba77fbe9400b3
5
5
  SHA512:
6
- metadata.gz: aa9066ed944f65d672e33c6a53363cf69bfa632c6c6ce3dc2762a83bdddd9ae657f77787650820372dd3dcdccd55ea542bd7cbdac8a37f491c90815b978ca824
7
- data.tar.gz: e84a02d13736d6199a0d90c8db0956cedf1b311fa59f6cdad25878b12e17aa0ef90ad41fdc61876225ab52690411557084405ea8dc492b3bad7f8354400aa5a8
6
+ metadata.gz: c91ca1b3582071de94eb21dce1da08ce91efb1d30c5fa33498df366d5bd884e3b60405aa6870b5df5984219fb3dfd6606efddd91d49d5bfe924dc343be61c70f
7
+ data.tar.gz: 0b87d7f4bb5574e12f22619989ce1c3bb51b08b9bb800cfc7a7368e851d88d89a992e96d9faf835959f00cdb035222e69a219ae00efd4706694de9c4c51eb7b6
data/lib/actions/help.rb CHANGED
@@ -17,6 +17,18 @@ class HelpM
17
17
  end
18
18
  end
19
19
 
20
+ def clone(scope)
21
+ case
22
+ when scope==USER || scope==ORGS
23
+ print "\tclone\t\t\tClone a repository.\n"
24
+ print "\t\t\t\t->\tclone [repository]\n\n"
25
+ print "\t\t\t\tYou can use a RegExp to clone several repositories with \/ parameter \n"
26
+ print "\t\t\t\t->\tclone /[RegExp]/\n\n"
27
+ when scope==USER_REPO || scope==TEAM_REPO || scope==ORGS_REPO
28
+ print "\tclone\t\t\tClone the current repository.\n"
29
+ end
30
+ end
31
+
20
32
  def repos(scope)
21
33
  case
22
34
  when scope==USER
@@ -26,6 +38,8 @@ class HelpM
26
38
  when scope==TEAM
27
39
  print "\trepos\t\t\tList the team's repositories\n"
28
40
  end
41
+ print "\t\t\t\tUse the parameter -a, to directly show all repositories\n"
42
+ print "\t\t\t\t->\trepos -a\n\n"
29
43
  print "\t\t\t\tYou can use a RegExp to improve the search using the \/ parameter \n"
30
44
  print "\t\t\t\t->\trepos /[RegExp]/\n\n"
31
45
  end
@@ -62,10 +76,14 @@ class HelpM
62
76
  print "\topen\t\t\tOpen the organization's url of github in your web browser.\n"
63
77
  print "\t\t\t\tIf you have added the aditional .csv information with, you can open an specific github profile.\n"
64
78
  print "\t\t\t\t->\topen [user]\n\n"
79
+ print "\t\t\t\tYou can use a RegExp to open several users.\n"
80
+ print "\t\t\t\t->\topen /RegExp/\n\n"
65
81
  print "\t\t\t\tYou can open an specific field if its contains an url.\n"
66
82
  print "\t\t\t\t->\topen [user] [fieldname]\n\n"
67
83
  print "\t\t\t\tIf you don't want to put the whole field, you can open the url contained with \"/\" parameter.\n"
68
84
  print "\t\t\t\t->\topen [user] /[part of the url]/\n\n"
85
+ print "\t\t\t\tYo can also use the RegExp in first parameter too, in order to open several websites.\n"
86
+ print "\t\t\t\t->\topen /RegExp/ /[part of the url]/\n\n"
69
87
  when scope==ORGS_REPO
70
88
  print "\topen\t\t\tOpen the repository's url of github in your web browser.\n"
71
89
  when scope==TEAM
@@ -77,6 +95,12 @@ class HelpM
77
95
  end
78
96
  end
79
97
 
98
+ def rm_clone_files(scope)
99
+ print "\trm clone files\t\tDelete the repositories cloned with GHEDSH.\n"
100
+ print "\t\t\t\tYou can use a RegExp to choose the repositories that you want to be deleted\n"
101
+ print "\t\t\t\t->\trm clone files /RegExp/\n\n"
102
+ end
103
+ alias_method :rm_clone,:rm_clone_files
80
104
  def people(scope)
81
105
  case
82
106
  when scope==ORGS
@@ -197,7 +221,7 @@ class HelpM
197
221
  print "\torgs\t\t\tShow your organizations\n"
198
222
  self.open(USER)
199
223
  self.repos(USER)
200
- print "\tclone\t\t\tClone a repository or a list of repositories using a regular expresion\n"
224
+ self.clone(USER)
201
225
  self.new_repository(USER)
202
226
  self.rm_repository(USER)
203
227
  print "\tset\t\t\tMove you to a specific repository\n"
@@ -208,10 +232,10 @@ class HelpM
208
232
  puts " Organization options:"
209
233
  print "\n\tCOMMAND\t\t\tDESCRIPTION\n\n"
210
234
  self.repos(ORGS)
235
+ self.clone(ORGS)
211
236
  self.new_repository(ORGS)
212
237
  self.rm_repository(ORGS)
213
238
  self.open(ORGS)
214
- print "\tclone\t\t\tClone a repository or a list of repositories using a regular expresion\n"
215
239
  print "\tset\t\t\tMove you to a specific repository\n"
216
240
  self.people(ORGS)
217
241
  self.new_people_info(ORGS)
@@ -225,6 +249,7 @@ class HelpM
225
249
  puts " Repository options:"
226
250
  print "\n\tCOMMAND\t\t\tDESCRIPTION\n\n"
227
251
  self.info(ORGS_REPO)
252
+ self.clone(ORGS_REPO)
228
253
  self.open(ORGS_REPO)
229
254
  print "\tcommits\t\t\tShow the list of commits from the repository\n"
230
255
  self.issues(ORGS_REPO)
@@ -242,8 +267,8 @@ class HelpM
242
267
  print "\n\tCOMMAND\t\t\tDESCRIPTION\n\n"
243
268
  self.repos(TEAM)
244
269
  self.people(TEAM)
270
+ self.clone(TEAM)
245
271
  self.open(TEAM)
246
- print "\tclone\t\t\tClone a repository or a list of repositories using a regular expresion\n"
247
272
  print "\tadd team member\t\tAdd a member in the team\n\n"
248
273
  print "\t\t\t\t->\tadd team member [new member]\n\n"
249
274
  end
@@ -253,6 +278,7 @@ class HelpM
253
278
  puts " Repository options:"
254
279
  print "\n\tCOMMAND\t\t\tDESCRIPTION\n\n"
255
280
  self.info(USER_REPO)
281
+ self.clone(USER_REPO)
256
282
  self.open(USER_REPO)
257
283
  print "\tcommits\t\t\tShow the list of commits from the repository\n"
258
284
  self.issues(USER_REPO)
@@ -296,6 +322,7 @@ class HelpM
296
322
  puts " Repository options:"
297
323
  print "\n\tCOMMAND\t\t\tDESCRIPTION\n\n"
298
324
  self.info(TEAM_REPO)
325
+ self.clone(TEAM_REPO)
299
326
  self.open(TEAM_REPO)
300
327
  print "\tcommits\t\t\tShow the list of commits from the repository\n"
301
328
  self.issues(TEAM_REPO)
@@ -315,6 +342,7 @@ class HelpM
315
342
  print "\n\tCOMMAND\t\t\tDESCRIPTION\n\n"
316
343
  print "\tdo\t\t\tRun a script in ghedsh execute path\n"
317
344
  print "\t\t\t\t->\tdo [filename]\n\n"
345
+ self.rm_clone_files(1)
318
346
  print "\texit\t\t\tExit from this program\n"
319
347
  print "\thelp\t\t\tList of commands available\n"
320
348
  self.cd(1)
data/lib/actions/orgs.rb CHANGED
@@ -317,13 +317,15 @@ class Organizations
317
317
  end
318
318
  end
319
319
 
320
- def get_assigs(client,config)
320
+ def get_assigs(client,config,show)
321
321
  list=self.load_assig()
322
322
  assiglist=[]
323
323
  assig=list["orgs"].detect{|aux| aux["name"]==config["Org"]}
324
324
  if assig!=nil
325
325
  if assig["assigs"].empty?
326
- puts "\e[31m No assignments are available yet\e[0m"
326
+ if show==true
327
+ puts "\e[31m No assignments are available yet\e[0m"
328
+ end
327
329
  else
328
330
  assig["assigs"].each do |i|
329
331
  assiglist.push(i["name_assig"])
@@ -874,45 +876,65 @@ class Organizations
874
876
  Sys.new.save_people("#{ENV['HOME']}/.ghedsh",list)
875
877
  puts "Extended information has not been added yet"
876
878
  else
877
- inuser=list["orgs"].detect{|aux| aux["name"]==config["Org"]}["users"].detect{|aux2| aux2["github"]==user}
879
+ if user.downcase.start_with?("/") and user.downcase.end_with?("/")
880
+ sp=user.split('/')
881
+ exp=Regexp.new(sp[1],sp[2])
882
+ inuser=Sys.new.search_rexp_peoplehash(list["orgs"].detect{|aux| aux["name"]==config["Org"]}["users"],exp)
883
+ user.slice!(0); user=user.chop
884
+ else
885
+ inuser=[]
886
+ inuser.push(list["orgs"].detect{|aux| aux["name"]==config["Org"]}["users"].detect{|aux2| aux2["github"]==user})
887
+ end
878
888
  if inuser==nil
879
889
  puts "Not extended information has been added of that user."
880
890
  else
881
891
  if field==nil
882
- inuser.each_value do |j|
883
- if j.include?("github.com")
884
- if !j.include?("https://") && !j.include?("http://")
885
- Sys.new.open_url("https://"+j)
886
- else
887
- Sys.new.open_url(j)
892
+ inuser.each do |i|
893
+ i.each_value do |j|
894
+ if j.include?("github.com")
895
+ if !j.include?("https://") && !j.include?("http://")
896
+ Sys.new.open_url("https://"+j)
897
+ else
898
+ Sys.new.open_url(j)
899
+ end
900
+ found=1
888
901
  end
889
- found=1
890
902
  end
891
903
  end
892
904
  if found==0
893
905
  puts "No github web profile in the aditional information"
894
906
  end
895
907
  else
896
- if field.downcase.start_with?("/") and field.downcase.end_with?("/") ##regexp
897
- field=field.delete("/")
898
- inuser.each_value do |j|
899
- if j.include?(field)
900
- if j.include?("https://") || j.include?("http://")
901
- Sys.new.open_url(j)
908
+ if inuser!=[]
909
+ if field.downcase.start_with?("/") and field.downcase.end_with?("/") ##regexp
910
+ field=field.delete("/")
911
+ inuser.each do |i|
912
+ if i!=nil
913
+ i.each_value do |j|
914
+ if j.include?(field)
915
+ if j.include?("https://") || j.include?("http://")
916
+ Sys.new.open_url(j)
917
+ end
918
+ end
919
+ end
902
920
  end
903
921
  end
904
- end
905
- else
906
- if inuser.keys.include?(field.downcase)
907
- if inuser[field.downcase].include?("https://") or inuser[field.downcase].include?("http://")
908
- url=inuser["#{field.downcase}"]
909
- else
910
- url="http://"+inuser["#{field.downcase}"]
911
- end
912
- Sys.new.open_url(url)
913
922
  else
914
- puts "No field found with that name"
923
+ inuser.each do |i|
924
+ if inuser.keys.include?(field.downcase)
925
+ if inuser[field.downcase].include?("https://") or inuser[field.downcase].include?("http://")
926
+ url=inuser["#{field.downcase}"]
927
+ else
928
+ url="http://"+inuser["#{field.downcase}"]
929
+ end
930
+ Sys.new.open_url(url)
931
+ else
932
+ puts "No field found with that name"
933
+ end
934
+ end
915
935
  end
936
+ else
937
+ puts "No field found with that name"
916
938
  end
917
939
  end
918
940
  end
data/lib/actions/repo.rb CHANGED
@@ -8,12 +8,18 @@ require_rel '.'
8
8
 
9
9
  class Repositories
10
10
  attr_reader :reposlist
11
+ attr_reader :clonedrepos
11
12
  #scope = 1 -> organization repos
12
13
  #scope = 2 -> user repos
13
14
  #scope = 3 -> team repos
14
15
 
15
16
  def initialize
16
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)
17
23
  end
18
24
 
19
25
  def show_commits(client,config,scope)
@@ -395,7 +401,11 @@ class Repositories
395
401
  puts "Repositories found: #{rlist.size}"
396
402
  end
397
403
 
398
- return rlist
404
+ if force_exit==true
405
+ return self.get_repos_list(client,config,scope)
406
+ else
407
+ return rlist
408
+ end
399
409
  end
400
410
 
401
411
  def show_user_orgs_repos(client,config,listorgs)
@@ -586,20 +596,22 @@ class Repositories
586
596
  reposlist=[]
587
597
  case
588
598
  when scope==USER
589
- repo=client.repositories
599
+ repo=client.repositories()
590
600
  when scope==ORGS
591
601
  repo=client.organization_repositories(config["Org"])
592
602
  when scope==TEAM
593
603
  repo=client.team_repositories(config["TeamID"])
594
604
  end
595
- repo.each do |i|
596
- if scope!=USER
597
- reposlist.push(i.name)
598
- else
599
- if i[:owner][:login]==config["User"]
605
+ if repo!=nil
606
+ repo.each do |i|
607
+ if scope!=USER
600
608
  reposlist.push(i.name)
601
609
  else
602
- reposlist.push(i.full_name)
610
+ if i[:owner][:login]==config["User"]
611
+ reposlist.push(i.name)
612
+ else
613
+ reposlist.push(i.full_name)
614
+ end
603
615
  end
604
616
  end
605
617
  end
@@ -626,6 +638,12 @@ class Repositories
626
638
  command = "git clone #{web2}#{config["Org"]}/#{config["Repo"]}.git"
627
639
  end
628
640
  system(command)
641
+ if scope==USER_REPO
642
+ @clonedrepos.push("#{config["User"]}/#{config["Repo"]}")
643
+ else
644
+ @clonedrepos.push("#{config["Org"]}/#{config["Repo"]}")
645
+ end
646
+ self.clonedpush()
629
647
  else
630
648
  if exp.match(/^\//)
631
649
  exps=exp.split('/')
@@ -640,21 +658,69 @@ class Repositories
640
658
  case
641
659
  when scope==USER
642
660
  list.each do |i|
643
- command = "git clone #{web2}#{config["User"]}/#{i}.git"
661
+ if i.include?("/")
662
+ command = "git clone #{web2}#{i}.git"
663
+ @clonedrepos.push(i)
664
+ else
665
+ command = "git clone #{web2}#{config["User"]}/#{i}.git"
666
+ @clonedrepos.push("#{config["User"]}/#{i}")
667
+ end
644
668
  system(command)
645
669
  end
646
670
  when scope==ORGS
647
671
  list.each do |i|
648
672
  command = "git clone #{web2}#{config["Org"]}/#{i}.git"
673
+ @clonedrepos.push("#{config["Org"]}/#{i}")
649
674
  system(command)
650
675
  end
651
676
  end
677
+ self.clonedpush()
652
678
  else
653
679
  puts "No repositories found it with the parameters given"
654
680
  end
655
681
  end
656
682
  end
657
683
 
684
+ def rm_clone(client,config,scope,all,exp)
685
+ files=@clonedrepos
686
+
687
+ if all==false
688
+ if exp.match(/^\//)
689
+ exps=exp.split('/')
690
+ list=self.get_repos_list(client,config,scope)
691
+ list=Sys.new.search_rexp(files,exps[1])
692
+ else
693
+ list=[]
694
+ list.push(exp)
695
+ end
696
+ files=list
697
+ end
698
+ if files!=[]
699
+ print "\n"
700
+ puts files
701
+ puts "Are gone to be removed (Y/N)"
702
+ op=gets.chomp
703
+ if op.downcase=="y" || op.downcase=="yes"
704
+ files.each do |i|
705
+ i=i.delete("\"")
706
+ if !File.exists?(i)
707
+ sp=i.split("/")
708
+ i=sp[1]
709
+ end
710
+ system("rm -rf #{i}")
711
+ if all==false
712
+ @clonedrepos.delete(i)
713
+ end
714
+ end
715
+ puts "Cloned files deleted"
716
+ if all==true then @clonedrepos.clear end
717
+ self.clonedpush()
718
+ end
719
+ else
720
+ puts "Not cloned files found"
721
+ end
722
+ end
723
+
658
724
  def show_files(list)
659
725
  print "\n"
660
726
 
@@ -11,7 +11,7 @@ class Sys
11
11
  attr_reader :memory
12
12
  LIST = ['repos', 'exit', 'orgs','help', 'people','teams', 'cd ', 'cd repo ','commits','forks', 'add_team_member ','new team ','rm team ','new repository ','new assignment ','clone ', 'issues',
13
13
  'version', 'cat ', 'groups', 'files', 'assignments','new issue ', 'open issue', 'new ','open ', 'close issue', 'new group ', 'rm group', 'rm ', 'do ', 'info','make','add repo',
14
- 'add group','rm repository ', 'new people info ', 'private ', 'people info ', 'new issue comment ', "rm people info", "change repo",'add students','new relation'].sort
14
+ 'add group','rm repository ', 'new people info ', 'private ', 'people info ', 'new issue comment ', "rm people info", "change repo",'add students','new relation','rm clone files'].sort
15
15
 
16
16
  def initialize()
17
17
  @memory=[]
@@ -285,6 +285,26 @@ class Sys
285
285
  return config
286
286
  end
287
287
 
288
+ def refresh_clonefile(path,list)
289
+ if (File.exist?(path))==true
290
+ File.write("#{path}/ghedsh-clonedfiles",list)
291
+ end
292
+ end
293
+
294
+ def load_clonefile(path)
295
+ if (File.exist?(path))==true
296
+ if File.exist?("#{path}/ghedsh-clonedfiles")
297
+ files=File.read("#{path}/ghedsh-clonedfiles")
298
+ files=files.delete("["); files=files.delete("]")
299
+ files=files.split(",")
300
+ return files
301
+ else
302
+ File.write("#{path}/ghedsh-clonedfiles","")
303
+ return []
304
+ end
305
+ end
306
+ end
307
+
288
308
  def create_temp(path)
289
309
  if (File.exist?(path))==false
290
310
  FileUtils.mkdir_p(path)
data/lib/interface.rb CHANGED
@@ -177,16 +177,17 @@ class Interface
177
177
  if @deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO
178
178
  self.cdrepo(path)
179
179
  end
180
-
180
+ o=Organizations.new
181
181
  path_split=path.split("/")
182
182
  if path_split.size==1 ##cd con path simple
183
183
  case
184
184
  when @deep==USER
185
- @orgs_list=Organizations.new.read_orgs(@client)
185
+ @orgs_list=o.read_orgs(@client)
186
186
  aux=@orgs_list
187
187
  if aux.one?{|aux| aux==path}
188
188
  @config["Org"]=path
189
189
  @teamlist=Teams.new.read_teamlist(@client,@config)
190
+ @sysbh.add_history_str(2,o.get_assigs(@client,@config,false))
190
191
  @sysbh.add_history_str(1,@teamlist)
191
192
  @deep=2
192
193
  else
@@ -283,7 +284,7 @@ class Interface
283
284
 
284
285
  def cdassig(path)
285
286
  o=Organizations.new()
286
- list=o.get_assigs(@client,@config)
287
+ list=o.get_assigs(@client,@config,true)
287
288
  if list.one?{|aux| aux==path}
288
289
  @deep=ASSIG
289
290
  puts "Set in #{@config["Org"]} assignment: #{path}\n\n"
@@ -339,7 +340,7 @@ class Interface
339
340
  @orgs_repos=list
340
341
  else
341
342
  #list=repo.show_repos(@client,@config,ORGS)
342
- list=repo.get_repos(@client,@config,ORGS)
343
+ list=repo.get_repos_list(@client,@config,ORGS)
343
344
  @sysbh.add_history_str(2,list)
344
345
  @orgs_repos=list
345
346
  puts list
@@ -570,6 +571,12 @@ class Interface
570
571
  if @deep==ASSIG and opcd.size==3
571
572
  o.rm_assigment_repo(@config,@config["Assig"],opcd[2])
572
573
  end
574
+ when op.include?("rm clone files") && opcd[0]=="rm" && opcd[1]="clone" && opcd[2]="files"
575
+ if opcd.size>3
576
+ r.rm_clone(@client,@config,@scope,false,opcd[3])
577
+ else
578
+ r.rm_clone(@client,@config,@scope,true,nil)
579
+ end
573
580
  when op == "info"
574
581
  if @deep==ASSIG then o.show_assig_info(@config,@config["Assig"]) end
575
582
  if @deep==USER_REPO || @deep==TEAM_REPO || @deep==ORGS_REPO then r.info_repository(@client,@config,@deep) end
@@ -616,6 +623,7 @@ class Interface
616
623
  when op == "assignments"
617
624
  if @deep==ORGS
618
625
  o.show_assignments(@client,@config)
626
+ @sysbh.add_history_str(2,o.get_assigs(@client,@config,false))
619
627
  end
620
628
  when op =="make"
621
629
  if @deep==ASSIG
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ghedsh
2
- VERSION='1.1.37'
2
+ VERSION='1.1.38'
3
3
  end
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.37
4
+ version: 1.1.38
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: 2017-05-11 00:00:00.000000000 Z
12
+ date: 2017-05-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: octokit