smdev 0.6.0 → 0.7.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/smdev.rb +28 -9
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5e395ee05d1f53774b0b9f9fa37beac7c1a6f5f921605c38427fbc06e07e76e
4
- data.tar.gz: 6fc9f20054b455d1c4ba7ab2447d4bda9cb5bf55df98f15f4938d7df948369e0
3
+ metadata.gz: 68f87bb98d072e7bc59c529f581a7c8ae96c4d66b3793f9357a99a8a0ac30f87
4
+ data.tar.gz: e7cf6b40abd1062104800ac076f31400841f9571e3c257374609fd3f60eb4c53
5
5
  SHA512:
6
- metadata.gz: 43f5e4b2112b6d7e338e56655e567d1a73fd8a3c2210499fb3278f467fa4394780755b597d4a67e5337cce6f9c32494a440b28d95adf23cc95cc78d1677dec77
7
- data.tar.gz: e70efeab8b186294b7a1a7847cdf1f91953a7fa82eaedae3d60f69511fdad360e562a12b3d85cd7dddc1ac85c76ea0f7743cc06eda8d4e31794ad646dffeedf3
6
+ metadata.gz: c2fd59b0dbfb6ff0f1c3ca50c02212531da7a81c1d50f50e91fbc752ef7332f858ee1a6c20569cf0d2195c149664127c9ac3a5269deba2d5e29cc2a63994317c
7
+ data.tar.gz: 53be714003b7f14f90fdd46a8c167c9f35d3cd1dbcc96db3f10a5818ece89135b9787554374d072c36d0fea5c68fb03dbed52a8deb7143249c15ec0c84841e41
data/lib/smdev.rb CHANGED
@@ -66,6 +66,8 @@ module Smdev
66
66
  system_install
67
67
  when "checkout_repos"
68
68
  checkout_repos(options)
69
+ when "update_repos"
70
+ update_repos(options)
69
71
  when "console"
70
72
  options[:command] = "rails c"
71
73
  open_ssh(options)
@@ -143,7 +145,7 @@ module Smdev
143
145
  system('sudo', 'gem', 'install', 'rails')
144
146
  end
145
147
 
146
- def checkout_repos(options)
148
+ def get_repos(options)
147
149
  token = ENV['GITHUB_TOKEN']
148
150
  if token.nil?
149
151
  # Prompt the user for their GitHub personal access token
@@ -182,17 +184,34 @@ module Smdev
182
184
  break if repos_page.length < per_page
183
185
  page_number += 1
184
186
  end
187
+ end
185
188
 
186
- # # No team name was provided, so get a list of all teams in the organization
187
- # teams = client.organization_teams(org_name)
188
- # # Get a list of all repositories in the organization that are assigned to each team
189
- # repos = []
190
- # teams.each do |team|
191
- # team_repos = client.team_repos(team.id)
192
- # repos.concat(team_repos)
193
- # end
189
+ return repos
190
+ end
191
+
192
+ def update_repos(options)
193
+ repos = get_repos(options)
194
+ # Clone each repository to a local directory
195
+ repos.each do |repo|
196
+ clone_url = repo.clone_url
197
+ ssh_url = repo.ssh_url
198
+ repo_name = repo.name
199
+ url = options[:https] ? clone_url : ssh_url
200
+
201
+ if Dir.exist?(repo_name)
202
+ puts "Checking for updates to '#{repo_name}'"
203
+ `cd #{repo_name} && git pull`
204
+ else
205
+ puts "Repository '#{repo_name}' isn't cloned locally. Skipping update."
206
+ end
194
207
  end
195
208
 
209
+ end
210
+
211
+
212
+ def checkout_repos(options)
213
+ repos = get_repos(options)
214
+
196
215
  # Clone each repository to a local directory
197
216
  repos.each do |repo|
198
217
  clone_url = repo.clone_url
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smdev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Neighbors