central 0.1.1 → 0.1.2

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/central.rb +21 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6144bb903e188d751c09636a68e90ed1e2596edc
4
- data.tar.gz: 0d4fa728e247794f61536f81ba80acf93156dd60
3
+ metadata.gz: 32c1b221cc555abfdf1fca8f3f39de5614767049
4
+ data.tar.gz: 68ed3f15a8d2733429f28b2ddd8d2fd8ff2b195f
5
5
  SHA512:
6
- metadata.gz: f078f4965f4ecca46af6cf4d7604b942bf92d113653545aa51f29250c6cb9e69539a3d03a6dd60f11ab9f873fc969d11ecfab9702a297d511b627dbea2ba1909
7
- data.tar.gz: b3178f8677d21b15a8e6416f3823a3d58431cfa73bd3b6bb33cab1cbfa149d022ff19243caa133796610d3f80581a1d4085b9d369a9f1885a45f500cc8b192df
6
+ metadata.gz: 851be63883d051ec8a528eb565ccd142f9c327677b1bb20f24b441ef2028ac33adaeb35ca96a0e9293bbee766e40262ee0244beb9ecc4dfef8753bbba3ab10a0
7
+ data.tar.gz: f17fe82282dd9e3f266cc7dc24c52b89d0a8f122dab02ec383c2ae7b5d00aa14c6fb32bf63693d3a49267c9920f46c89d4a18074983ebea521c3bc8e150019e8
data/lib/central.rb CHANGED
@@ -187,19 +187,37 @@ def symlink(from,to)
187
187
  end
188
188
 
189
189
  # git clone url into a path
190
- def git(url,path)
190
+ def git(url,path,branch=nil)
191
191
  path = abs(path)
192
192
  if dir_exists?(path) && dir_exists?("#{path}/.git")
193
193
  cwd = pwd()
194
194
  chdir path
195
- out = sudo('git pull')
195
+ out = nil
196
+ if branch
197
+ out = sudo('git fetch')
198
+ if out.size > 0
199
+ puts out
200
+ end
201
+ out = sudo("git checkout #{branch}")
202
+ unless out.downcase.include? 'is now at'
203
+ puts out
204
+ end
205
+ out = sudo("git pull origin #{branch}")
206
+ else
207
+ out = sudo('git pull')
208
+ end
196
209
  unless out.downcase.include? "already up-to-date"
197
210
  puts out
198
211
  puts "Git repository pulled: #{url} → #{path}"
199
212
  end
200
213
  chdir cwd
201
214
  else
202
- out = sudo("git clone #{url} \"#{path}\"")
215
+ if branch
216
+ branch = "-b #{branch} "
217
+ else
218
+ branch = ''
219
+ end
220
+ out = sudo("git clone #{branch}#{url} \"#{path}\"")
203
221
  puts out
204
222
  puts "Git repository cloned: #{url} → #{path}"
205
223
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: central
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Geurkov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-03 00:00:00.000000000 Z
11
+ date: 2018-01-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: central dotfile management system
14
14
  email: d.geurkov@gmail.com