ghedsh 1.1.16 → 1.1.17

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: b7bed6aad874d5f0faf8a0b387eba24d5b4a9353
4
- data.tar.gz: 519dafec3cc338ede392b2dd1bf38f6c1e864efc
3
+ metadata.gz: cfce703f3220d07630cd5f9adc1539ec839dbba9
4
+ data.tar.gz: 477ad295f07f76878c80f4b7b19dd0494c02b892
5
5
  SHA512:
6
- metadata.gz: 7ec45575411bc1e8062f486fa71664fa3f0932c5a203afc3970181ee7124959629a90fa3fa35f1a506b480ba260fe65ad4ff03639f0a6ba21a1deffe5275e81c
7
- data.tar.gz: 1c53cedf872f4fcc6c544456ab357ea07d8faa4651a6299823a7c58e3b06e45d961288c7dea7958baccc74f9c1a25802bee824609758ca1428a0487944e1e5fe
6
+ metadata.gz: 6e1725d1ead956077ac671593d4b8907ad3cad3ad6748726228b333c8972e23e9e910ee52de1af24d589a5cb372026c9b198dfc9067f6baac7f41b918ec3254e
7
+ data.tar.gz: b40325d1ba5acd754f803e44fd426add5c3bf99e1f88be80cebadbb41c6221d474594eb4e4e0c7e1c92a28f5728a42965e9e0166159fa320a1d1f2d5911f31fd
data/lib/actions/orgs.rb CHANGED
@@ -3,6 +3,7 @@ require 'octokit'
3
3
  require 'json'
4
4
  require 'require_all'
5
5
  require_rel '.'
6
+ require 'readline'
6
7
 
7
8
  class Organizations
8
9
 
@@ -28,11 +29,12 @@ class Organizations
28
29
  puts "\n"
29
30
  puts i["name_assig"]
30
31
  puts "Repository: #{i["repo"]}"
31
- puts "Groups: "
32
- puts "Teams: "
33
- # i["teams"].each do |j|
34
- # puts "\t#{j}"
35
- # end
32
+ print "Groups: "
33
+ i["groups"].each do |y|
34
+ print y
35
+ print " "
36
+ end
37
+ print "\n"
36
38
  end
37
39
  end
38
40
  else
@@ -52,16 +54,56 @@ class Organizations
52
54
  Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list)
53
55
  end
54
56
 
57
+ ex=false
58
+ until ex==true
59
+ puts "Assignment: #{name}"
60
+ puts "1) Add a repository already created "
61
+ puts "2) Create a new empty repository"
62
+ puts "3) Don't assign a repository yet"
63
+ print "option => "
64
+ op=gets.chomp
65
+ if op=="3" or op=="1" or op=="2"
66
+ ex=true
67
+ end
68
+ end
69
+
70
+ case
71
+ when op=="1" || op=="2"
72
+ puts "Name of the repository: "
73
+ reponame=gets.chomp
74
+ if client.repository?("#{config["Org"]}/#{reponame}")==false
75
+ puts "The repository #{reponame} doesn't exist"
76
+ reponame=nil
77
+ end
78
+ if op=="2"
79
+ Repositories.new().create_repository(client,config,reponame,ORGS)
80
+ end
81
+ when op=="3" then reponame=""
82
+ end
83
+
84
+ groupslist=Teams.new().get_groupslist(config)
85
+ puts "Add groups to your assignment (Press enter to skip): "
86
+ op=gets.chomp
87
+ if op!=nil
88
+
89
+ groupsadd=op.split(" ")
90
+ groupsadd.each do |item|
91
+ if groupslist.detect{|aux| aux==item}==nil
92
+ groupsadd.delete(item)
93
+ end
94
+ end
95
+ else
96
+ groupsadd=[]
97
+ end
98
+
55
99
  begin
56
- list["orgs"][list["orgs"].index{|aux| aux["name"]==config["Org"]}]["assigs"].push({"name_assig"=>name,"teams"=>[],"groups"=>[],"repo"=>nil})
100
+ list["orgs"][list["orgs"].index{|aux| aux["name"]==config["Org"]}]["assigs"].push({"name_assig"=>name,"teams"=>[],"groups"=>groupsadd,"repo"=>reponame})
57
101
  rescue Exception => e
58
102
  puts e
59
103
  end
60
104
  Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list)
61
-
62
105
  end
63
106
 
64
-
65
107
  def get_assigs(client,config)
66
108
  list=self.load_assig()
67
109
  assiglist=[]
data/lib/actions/repo.rb CHANGED
@@ -33,6 +33,38 @@ class Repositories
33
33
  end
34
34
  end
35
35
 
36
+ def open_issue(client,config,scope)
37
+ puts "Insert Issue tittle: "
38
+ tittle=gets.chomp
39
+ puts "Add a description: "
40
+ desc=gets.chomp
41
+
42
+ case
43
+ when scope==USER_REPO
44
+ if config["Repo"].split("/").size == 1
45
+ client.create_issue(config["User"]+"/"+config["Repo"],tittle,desc)
46
+ else
47
+ client.create_issue(config["Repo"],tittle,desc)
48
+ end
49
+ when scope==ORGS_REPO || scope==TEAM_REPO
50
+ client.create_issue(config["Org"]+"/"+config["Repo"],tittle,desc)
51
+ end
52
+
53
+ end
54
+
55
+ def close_issue(client,config,scope,id)
56
+ case
57
+ when scope==USER_REPO
58
+ if config["Repo"].split("/").size == 1
59
+ client.close_issue(config["User"]+"/"+config["Repo"],id)
60
+ else
61
+ client.close_issue(config["Repo"],id)
62
+ end
63
+ when scope==ORGS_REPO || scope==TEAM_REPO
64
+ client.close_issue(config["Org"]+"/"+config["Repo"],id)
65
+ end
66
+ end
67
+
36
68
  def show_issues(client,config,scope)
37
69
  print "\n"
38
70
  case
@@ -196,16 +228,17 @@ class Repositories
196
228
 
197
229
  def create_repository(client,config,repo,scope)
198
230
  options=Hash.new
231
+ options[:auto_init]=true
199
232
  case
200
233
  when scope==ORGS
201
- puts "created repository in org"
234
+ puts "created repository in #{config["Org"]}"
202
235
  options[:organization]=config["Org"]
203
236
  client.create_repository(repo,options)
204
237
  when scope==USER
205
238
  puts "created repository in user"
206
239
  client.create_repository(repo)
207
240
  when scope==TEAM
208
- puts "created repository in org team"
241
+ puts "created repository in #{config["Org"]} team"
209
242
  options[:team_id]=config["TeamID"]
210
243
  options[:organization]=config["Org"]
211
244
  client.create_repository(config["Team"]+"/"+repo,options)
@@ -10,7 +10,7 @@ class Sys
10
10
  attr_reader :client
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
- 'version', 'cat ', 'groups', 'files', 'assignments'].sort
13
+ 'version', 'cat ', 'groups', 'files', 'assignments', 'new_group ', 'do '].sort
14
14
 
15
15
  def initialize()
16
16
  @memory=[]
data/lib/actions/teams.rb CHANGED
@@ -72,6 +72,22 @@ class Teams
72
72
  print "\n"
73
73
  end
74
74
 
75
+ def get_team_members(client,config,team)
76
+ memberlist=[]
77
+ if @teamlist.empty?
78
+ self.read_teamlist(client,config)
79
+ end
80
+
81
+ if @teamlist["#{team}"]!=nil
82
+ mem=client.team_members(@teamlist["#{team}"])
83
+ mem.each do |i|
84
+ m=eval(i.inspect)
85
+ memberlist.push(m[:login])
86
+ end
87
+ end
88
+ return memberlist
89
+ end
90
+
75
91
  def list_groups(client,config)
76
92
  sys=Sys.new()
77
93
  list=sys.load_groups("#{ENV['HOME']}/.ghedsh")
@@ -80,11 +96,15 @@ class Teams
80
96
  if groups["groups"].empty?
81
97
  puts "No groups are available yet"
82
98
  else
99
+ puts "\nGroup\tTeams\tMembers"
83
100
  groups["groups"].each do |i|
84
101
  puts "\n"
85
102
  puts i["name_group"]
86
103
  i["teams"].each do |j|
87
104
  puts "\t#{j}"
105
+ self.get_team_members(client,config,j).each do |k|
106
+ puts "\t\t#{k}"
107
+ end
88
108
  end
89
109
  end
90
110
  end
@@ -95,6 +115,17 @@ class Teams
95
115
  end
96
116
  end
97
117
 
118
+ def get_groupslist(config)
119
+ sys=Sys.new()
120
+ grouplist=[]
121
+ list=sys.load_groups("#{ENV['HOME']}/.ghedsh")
122
+ groups=list["orgs"].detect{|aux| aux["name"]==config["Org"]}
123
+ groups["groups"].each do |i|
124
+ grouplist.push(i["name_group"])
125
+ end
126
+ return grouplist
127
+ end
128
+
98
129
  def new_group(client,config,name,listgroups)
99
130
  sys=Sys.new()
100
131
  list=sys.load_groups("#{ENV['HOME']}/.ghedsh")
@@ -126,4 +157,36 @@ class Teams
126
157
  end
127
158
  end
128
159
 
160
+ def delete_group(config,name)
161
+ sys=Sys.new()
162
+ list=sys.load_groups("#{ENV['HOME']}/.ghedsh")
163
+ groups=list["orgs"].detect{|aux| aux["name"]==config["Org"]}
164
+
165
+ if groups!=nil
166
+ if groups["groups"].empty?
167
+ puts "No groups are available yet"
168
+ else
169
+ del=groups["groups"].detect{|aux| aux["name_group"]==name}
170
+ if del==nil
171
+ puts "Group not found"
172
+ else
173
+ puts "Group #{name} will be deleted Are your sure? (Press y to confirm)"
174
+ op=gets.chomp
175
+ if op=="y"
176
+ list["orgs"].detect{|aux| aux["name"]==config["Org"]}["groups"].delete(groups["groups"].detect{|aux2| aux2["name_group"]==name})
177
+ sys.save_groups("#{ENV['HOME']}/.ghedsh",list)
178
+ end
179
+ end
180
+ end
181
+ end
182
+
183
+ end
184
+
185
+ def add_to_group(config,name)
186
+ end
187
+
188
+ def del_of_group(config,name)
189
+ #list=sys.load_groups("#{ENV['HOME']}/.ghedsh")
190
+ #list["orgs"].detect{|aux| aux["name"]==config["Org"]}["groups"].delete(groups["groups"].detect{|aux2| aux2["name_group"]==name})
191
+ end
129
192
  end
data/lib/interface.rb CHANGED
@@ -561,12 +561,27 @@ class Interface
561
561
  @teamlist=t.read_teamlist(@client,@config)
562
562
  @sysbh.add_history_str(1,@teamlist)
563
563
  end
564
+ if opcd[0]=="new_issue" and opcd.size==1
565
+ if @deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO
566
+ r.open_issue(@client,@config,@deep)
567
+ end
568
+ end
569
+ if opcd[0]=="close_issue" and opcd.size==2
570
+ if @deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO
571
+ r.close_issue(@client,@config,@deep,opcd[1])
572
+ end
573
+ end
564
574
  if opcd[0]=="rm_team"
565
575
  t.delete_team(@client,@teamlist[opcd[1]])
566
576
  self.quit_history(@teamlist[opcd[1]])
567
577
  @teamlist=t.read_teamlist(@client,@config)
568
578
  @sysbh.add_history_str(1,@teamlist)
569
579
  end
580
+ if opcd[0]=="rm_group" and opcd.size==2
581
+ if @deep==ORGS
582
+ t.delete_group(@config,opcd[1])
583
+ end
584
+ end
570
585
  if opcd[0]=="new_team" and opcd.size>2
571
586
  t.create_team_with_members(@client,@config,opcd[1],opcd[2..opcd.size])
572
587
  @teamlist=t.read_teamlist(@client,@config)
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ghedsh
2
- VERSION='1.1.16'
2
+ VERSION='1.1.17'
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.16
4
+ version: 1.1.17
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-06-01 00:00:00.000000000 Z
12
+ date: 2016-06-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: octokit