smdev 0.6.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smdev.rb +36 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6756e94f34ed4d1ec94eba484d664034bb59a90a508d36b1261c5744c8d9082f
|
4
|
+
data.tar.gz: 4b3c3a8f3478d71247c90a38226d9cd263fd47aba6ccebaa76a8d86a1e0dd502
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
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
|