smdev 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/smdev.rb +26 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68f87bb98d072e7bc59c529f581a7c8ae96c4d66b3793f9357a99a8a0ac30f87
4
- data.tar.gz: e7cf6b40abd1062104800ac076f31400841f9571e3c257374609fd3f60eb4c53
3
+ metadata.gz: fd3bd438e2a171908e6227b3361cfa8d851a04d8a7e72c76eb1b7fbf53f52b48
4
+ data.tar.gz: 9b45204d34f2b68fa9c8f693290e0fc67b9ca61d2d07831cf44e3f9a760cfb6b
5
5
  SHA512:
6
- metadata.gz: c2fd59b0dbfb6ff0f1c3ca50c02212531da7a81c1d50f50e91fbc752ef7332f858ee1a6c20569cf0d2195c149664127c9ac3a5269deba2d5e29cc2a63994317c
7
- data.tar.gz: 53be714003b7f14f90fdd46a8c167c9f35d3cd1dbcc96db3f10a5818ece89135b9787554374d072c36d0fea5c68fb03dbed52a8deb7143249c15ec0c84841e41
6
+ metadata.gz: 3eaf68d9b2d3c6e8cb85255d59df6415b6255db21328f1835442340dd7efe47601421efc348277282013f3256265647d4a2afe99d983fab16efb0f1c38c9acf5
7
+ data.tar.gz: 2f2ad3110f162fc18abe33e1c59d2633169a8cd3dd2aee8c5f45fd393fce5be9fadc8c149777180860ea84430a66849aec9c2985d35b55fc95cd4015ea21e0c4
data/lib/smdev.rb CHANGED
@@ -146,13 +146,16 @@ module Smdev
146
146
  end
147
147
 
148
148
  def get_repos(options)
149
- token = ENV['GITHUB_TOKEN']
150
- if token.nil?
151
- # Prompt the user for their GitHub personal access token
152
- print "GitHub personal access token: "
153
- token = STDIN.noecho(&:gets).chomp
154
- puts ""
149
+ if options[:https]
150
+ token = ENV['GITHUB_TOKEN']
151
+ if token.nil?
152
+ # Prompt the user for their GitHub personal access token
153
+ print "GitHub personal access token: "
154
+ token = STDIN.noecho(&:gets).chomp
155
+ puts ""
156
+ end
155
157
  end
158
+
156
159
  # Authenticate with the GitHub API using the user's credentials
157
160
  client = Octokit::Client.new(access_token: token)
158
161
 
@@ -200,7 +203,15 @@ module Smdev
200
203
 
201
204
  if Dir.exist?(repo_name)
202
205
  puts "Checking for updates to '#{repo_name}'"
203
- `cd #{repo_name} && git pull`
206
+ if options[:https]
207
+ puts "Using HTTPS to pull repo"
208
+ token = ENV['GITHUB_TOKEN']
209
+ url_with_token = url.sub('https://', "https://#{token}@")
210
+ `cd #{repo_name} && git -c http.extraHeader="Authorization: Bearer #{token}" pull #{url_with_token}`
211
+ else
212
+ puts "Using SSH to pull repo"
213
+ `cd #{repo_name} && git pull`
214
+ end
204
215
  else
205
216
  puts "Repository '#{repo_name}' isn't cloned locally. Skipping update."
206
217
  end
@@ -212,6 +223,14 @@ module Smdev
212
223
  def checkout_repos(options)
213
224
  repos = get_repos(options)
214
225
 
226
+ unless options[:https]
227
+ puts "*************************************************************************"
228
+ puts "* You must use https to get private repositories. *"
229
+ puts "* If you have not setup your github token, you will be prompted for it. *"
230
+ puts "* Use smdev -s to use https. *"
231
+ puts "*************************************************************************"
232
+ end
233
+
215
234
  # Clone each repository to a local directory
216
235
  repos.each do |repo|
217
236
  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.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Neighbors