smdev 0.6.0 → 0.8.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 +36 -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: 6756e94f34ed4d1ec94eba484d664034bb59a90a508d36b1261c5744c8d9082f
4
+ data.tar.gz: 4b3c3a8f3478d71247c90a38226d9cd263fd47aba6ccebaa76a8d86a1e0dd502
5
5
  SHA512:
6
- metadata.gz: 43f5e4b2112b6d7e338e56655e567d1a73fd8a3c2210499fb3278f467fa4394780755b597d4a67e5337cce6f9c32494a440b28d95adf23cc95cc78d1677dec77
7
- data.tar.gz: e70efeab8b186294b7a1a7847cdf1f91953a7fa82eaedae3d60f69511fdad360e562a12b3d85cd7dddc1ac85c76ea0f7743cc06eda8d4e31794ad646dffeedf3
6
+ metadata.gz: b77a5e17d8b7e23241c4f3645894e6ab86b498f50b919e9b1b367c70b0f9d5644199ed45440741f1f19b4d5d1163571efa222d83ace85be8faf498b74cd69d6a
7
+ data.tar.gz: 73d4de11312a3cae6ab6d7d4a1e80bad8e22cda5ec2f2604e772f14e4d505a3c39cc0cea17a6add21ba1241cbeff05c9af41bdfa025d119d1d72b11b3c7fef7f
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,42 @@ 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
+ if options[:https]
204
+ puts "Using HTTPS to pull repo"
205
+ token = ENV['GITHUB_TOKEN']
206
+ url_with_token = url.sub('https://', "https://#{token}@")
207
+ `cd #{repo_name} && git -c http.extraHeader="Authorization: Bearer #{token}" pull #{url_with_token}`
208
+ else
209
+ puts "Using SSH to pull repo"
210
+ `cd #{repo_name} && git pull`
211
+ end
212
+ else
213
+ puts "Repository '#{repo_name}' isn't cloned locally. Skipping update."
214
+ end
194
215
  end
195
216
 
217
+ end
218
+
219
+
220
+ def checkout_repos(options)
221
+ repos = get_repos(options)
222
+
196
223
  # Clone each repository to a local directory
197
224
  repos.each do |repo|
198
225
  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.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Neighbors