Class: Repositories
- Inherits:
-
Object
- Object
- Repositories
- Defined in:
- lib/actions/repo.rb
Instance Method Summary collapse
- #clone_repo(client, config, exp, scope) ⇒ Object
- #create_repository(client, config, repo, scope) ⇒ Object
- #create_repository_by_teamlist(client, config, repo, list, list_id) ⇒ Object
- #fork(client, config, repo) ⇒ Object
- #get_repos_list(client, config, scope) ⇒ Object
- #show_collaborators(client, config, scope) ⇒ Object
-
#show_commits(client, config, scope) ⇒ Object
scope = 1 -> organization repos scope = 2 -> user repos scope = 3 -> team repos.
- #show_forks(client, config, scope) ⇒ Object
- #show_repos(client, config, scope) ⇒ Object
- #show_repos_smart(client, config, exp, scope) ⇒ Object
- #show_user_orgs_repos(client, config, listorgs) ⇒ Object
Instance Method Details
#clone_repo(client, config, exp, scope) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/actions/repo.rb', line 171 def clone_repo(client,config,exp,scope) web="https://github.com/" web2="[email protected]:" 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==1 list.each do |i| command = "git clone #{web}#{config["User"]}/#{i}.git" system(command) end when scope==2 list.each do |i| command = "git clone #{web}#{config["Org"]}/#{i}.git" system(command) end end else puts "No repositories found it with the parameters given" end end |
#create_repository(client, config, repo, scope) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/actions/repo.rb', line 121 def create_repository(client,config,repo,scope) =Hash.new case when scope==2 puts "created repository in org" [:organization]=config["Org"] client.create_repository(repo,) when scope==1 puts "created repository in user" client.create_repository(repo) when scope==4 puts "created repository in org team" [:team_id]=config["TeamID"] [:organization]=config["Org"] client.create_repository(config["Team"]+"/"+repo,) end end |
#create_repository_by_teamlist(client, config, repo, list, list_id) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/actions/repo.rb', line 139 def create_repository_by_teamlist(client,config,repo,list,list_id) =Hash.new [:organization]=config["Org"] #puts list_id y=0 list.each do |i| [:team_id]=list_id[y] # puts i, list_id[y] # puts repo # puts options # puts "\n" client.create_repository(i+"/"+repo,) y=y+1 end end |
#fork(client, config, repo) ⇒ Object
116 117 118 119 |
# File 'lib/actions/repo.rb', line 116 def fork(client,config,repo) mem=client.fork(repo) return mem end |
#get_repos_list(client, config, scope) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/actions/repo.rb', line 155 def get_repos_list(client,config,scope) reposlist=[] case when scope==1 repo=client.repositories when scope==2 repo=client.organization_repositories(config["Org"]) when scope==3 repo=client.team_repositories(config["TeamID"]) end repo.each do |i| reposlist.push(i.name) end return reposlist end |
#show_collaborators(client, config, scope) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/actions/repo.rb', line 101 def show_collaborators(client,config,scope) print "\n" collalist=[] case when scope==1 mem=client.collaborators(config["Org"]+"/"+config["Repo"]) end mem.each do |i| puts i[:author][:login] collalist.push(i[:author][:login]) end print "\n" return collalist end |
#show_commits(client, config, scope) ⇒ Object
scope = 1 -> organization repos scope = 2 -> user repos scope = 3 -> team repos
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/actions/repo.rb', line 14 def show_commits(client,config,scope) print "\n" case when scope==1 mem=client.commits(config["Org"]+"/"+config["Repo"],"master") when scope==2 mem=client.commits(config["User"]+"/"+config["Repo"],"master") end 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 |
#show_forks(client, config, scope) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/actions/repo.rb', line 86 def show_forks(client,config,scope) print "\n" forklist=[] case when scope==1 mem=client.forks(config["Org"]+"/"+config["Repo"]) end mem.each do |i| puts i[:owner][:login] forklist.push(i[:owner][:login]) end print "\n" return forklist end |
#show_repos(client, config, scope) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/actions/repo.rb', line 27 def show_repos(client,config,scope) print "\n" reposlist=[] =Hash.new o=Organizations.new case when scope==1 #options[:affiliation]="organization_member" repo=client.repositories() #config["User"] listorgs=o.read_orgs(client) #self.show_user_orgs_repos(client,config,listorgs) when scope==2 repo=client.organization_repositories(config["Org"]) when scope==3 repo=client.team_repositories(config["TeamID"]) end repo.each do |i| puts i.name reposlist.push(i.name) end print "\n" puts "Repositories found: #{reposlist.size}" return reposlist end |
#show_repos_smart(client, config, exp, scope) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/actions/repo.rb', line 66 def show_repos_smart(client,config,exp,scope) reposlist=[] case when scope==1 repo=client.repositories(config["User"]) #repo=client.all_repositories() when scope==2 repo=client.organization_repositories(config["Org"]) when scope==3 repo=client.team_repositories(config["TeamID"]) end repo.each do |i| reposlist.push(i.name) end reposlist=Sys.new.search_rexp(reposlist,exp) puts reposlist return reposlist end |
#show_user_orgs_repos(client, config, listorgs) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/actions/repo.rb', line 54 def show_user_orgs_repos(client,config,listorgs) =Hash.new [:member]=config["User"] listorgs.each do |i| repo=client.organization_repositories(i,) repo.each do |y| puts y.name end end end |