obazoud-git-external 0.4.0 → 0.5.1

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.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/LICENSE.txt ADDED
@@ -0,0 +1,39 @@
1
+ Copyright (c) 2012 Olivier Bazoud
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
21
+ Copyright (c) 2010 Daniel Cestari
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining a copy
24
+ of this software and associated documentation files (the "Software"), to deal
25
+ in the Software without restriction, including without limitation the rights
26
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
+ copies of the Software, and to permit persons to whom the Software is
28
+ furnished to do so, subject to the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be included in
31
+ all copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
39
+ THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,75 @@
1
+ # git-external
2
+
3
+ Intends to provide an alternative to git-submodules but without being
4
+ attach to an specific commit
5
+
6
+ ## Requiments
7
+
8
+ * ruby 1.8.7
9
+ * gem
10
+ * git
11
+
12
+ ## Dependencies
13
+
14
+ * gem install rubygems
15
+
16
+ ## Usage
17
+
18
+ Setup a new git repository:
19
+ <pre class="terminal">
20
+ git init
21
+ </pre>
22
+
23
+ Help git external:
24
+ <pre class="terminal">
25
+ git external
26
+ </pre>
27
+
28
+ Setup a new "external" repository:
29
+ <pre class="terminal">
30
+ git external add <repository> <path> <branch>
31
+ </pre>
32
+
33
+ Initialize external repositories:
34
+ <pre class="terminal">
35
+ git external init
36
+ </pre>
37
+
38
+ Update existing repositories to the latest version:
39
+ <pre class="terminal">
40
+ git external update
41
+ </pre>
42
+
43
+ Status of your repository:
44
+ <pre class="terminal">
45
+ git external status
46
+ </pre>
47
+
48
+ Configuration of your repository:
49
+ <pre class="terminal">
50
+ git external list
51
+ </pre>
52
+
53
+ Execute a command over "external" repository:
54
+ <pre class="terminal">
55
+ git external cmd 'git status'
56
+ git external cmd 'git pull --rebase'
57
+ git external cmd 'git fetch'
58
+ </pre>
59
+
60
+ Remove an external repository:
61
+ <pre class="terminal">
62
+ git external rm <path>
63
+ </pre>
64
+
65
+ ## Installation from source
66
+
67
+ <pre class="terminal">
68
+ git clone git://github.com/obazoud/git-external.git
69
+ cd git-external
70
+ git checkout develop
71
+ gem build obazoud-git-external.gemspec && gem install obazoud-git-external-0.5.1.gem
72
+ </pre>
73
+
74
+ And voilà!
75
+
data/bin/git-external CHANGED
@@ -2,6 +2,8 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  require 'rbconfig'
5
+ require 'rubygems'
6
+ require 'optparse'
5
7
 
6
8
  module OS
7
9
  class << self
@@ -54,15 +56,7 @@ else
54
56
  end
55
57
 
56
58
  $configurations = {}
57
-
58
- def usage
59
- puts "Usage: git external add <repository-url> <path> [<branch>]"
60
- puts " or: git external status"
61
- puts " or: git external init [--] [<path>...]"
62
- puts " or: git external update [--] [<path>...]"
63
- puts " or: git external cmd '<command>'"
64
- puts " or: git external list"
65
- end
59
+ $options = {}
66
60
 
67
61
  # Load .gitexternals
68
62
  def load_configuration(file)
@@ -254,6 +248,12 @@ def command_list
254
248
  print_configuration
255
249
  end
256
250
 
251
+ def message(message)
252
+ if $options[:verbose]
253
+ puts message
254
+ end
255
+ end
256
+
257
257
  #########
258
258
  def normalize_url(url)
259
259
  url
@@ -286,18 +286,147 @@ def escape(s)
286
286
  end
287
287
  #########
288
288
 
289
- load_configuration $externals_file
289
+ def parse(args)
290
+ args = {}
291
+ subtext = "
292
+ Commands are:
293
+ add : setup a new 'external' repository
294
+ cmd : execute a command over 'external' repository
295
+ init : initialize (aka git clone) external repositories
296
+ list : dump configuration of your repository
297
+ rm : remove an external repository
298
+ status : status of your repository
299
+ update : update (aka git pull) existing repositories to the latest version
300
+
301
+ See 'git external COMMAND --help' for more information on a specific command."
302
+
303
+ global = OptionParser.new do |opts|
304
+ opts.banner = "
305
+ Usage: git external [options] [subcommand [options]]
306
+ #{subtext}
307
+ "
308
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |verbose|
309
+ $options[:verbose] = verbose
310
+ end
311
+ opts.on("--version", "Show version") do |version|
312
+ $options[:version] = version
313
+ end
314
+ opts.on_tail("-h","--help","help") do
315
+ puts opts
316
+ exit
317
+ end
318
+ end
319
+
320
+ subcommands = {
321
+ 'add' => OptionParser.new do |opts|
322
+ opts.banner = "Usage: add repository-url path [branch]"
323
+ opts.separator ""
324
+ args['add'] = 2
325
+ end,
326
+ 'cmd' => OptionParser.new do |opts|
327
+ opts.banner = "Usage: cmd command"
328
+ opts.separator ""
329
+ args['cmd'] = 1
330
+ end,
331
+ 'init' => OptionParser.new do |opts|
332
+ opts.banner = "Usage: init"
333
+ opts.separator ""
334
+ args['init'] = 0
335
+ end,
336
+ 'list' => OptionParser.new do |opts|
337
+ opts.banner = "Usage: list"
338
+ opts.separator ""
339
+ args['list'] = 0
340
+ end,
341
+ 'rm' => OptionParser.new do |opts|
342
+ opts.banner = "Usage: rm path"
343
+ opts.separator ""
344
+ args['rm'] = 1
345
+ end,
346
+ 'status' => OptionParser.new do |opts|
347
+ opts.banner = "Usage: status"
348
+ opts.separator ""
349
+ args['status'] = 0
350
+ end,
351
+ 'update' => OptionParser.new do |opts|
352
+ opts.banner = "Usage: update"
353
+ opts.separator ""
354
+ args['update'] = 0
355
+ end
356
+ }
357
+
358
+ if ARGV.empty?
359
+ puts global
360
+ exit -1
361
+ end
362
+
363
+ begin
364
+ global.order!
365
+ rescue OptionParser::InvalidOption => e
366
+ puts e.message
367
+ puts global
368
+ exit 1
369
+ end
370
+
371
+ if $options[:version]
372
+ gemspecFile = File.expand_path File.join(File.dirname(__FILE__), "..", "obazoud-git-external.gemspec")
373
+ message "- Reading #{gemspecFile}"
374
+ spec = Gem::Specification::load(gemspecFile)
375
+ puts "git external #{spec.version}"
376
+ message "For more information, please visit #{spec.homepage}"
377
+ exit 0
378
+ end
290
379
 
291
- command=ARGV[0]
292
-
293
- case command
294
- when "status" then command_status
295
- when "add" then command_add ARGV[1], ARGV[2], ARGV[3] || "origin/master"
296
- when "rm" then command_rm ARGV[1]
297
- when "init" then command_init
298
- when "update" then command_update
299
- when "cmd" then command_cmd ARGV[1]
300
- when "list" then command_list
301
- else usage
380
+ command = ARGV.shift
381
+
382
+ if command.nil?
383
+ puts global
384
+ puts subtext
385
+ exit 1
386
+ end
387
+
388
+ if subcommands[command].nil?
389
+ puts "Invalid subcommand"
390
+ puts global
391
+ exit 1
392
+ end
393
+
394
+ begin
395
+ subcommands[command].order!
396
+ rescue OptionParser::InvalidOption => e
397
+ puts e.message
398
+ puts global
399
+ exit 1
400
+ end
401
+
402
+ if ($options[:verbose])
403
+ puts "Command: #{command} "
404
+ p $options
405
+ puts "ARGV:"
406
+ p ARGV
407
+ subcommands.inspect
408
+ end
409
+
410
+ if ARGV.length < args[command]
411
+ puts "Wrong argument, expected #{args[command]} but was #{ARGV.length}"
412
+ puts subcommands[command]
413
+ else
414
+ begin
415
+ if ARGV.empty?
416
+ send "command_#{command}"
417
+ else
418
+ send "command_#{command}", *ARGV
419
+ end
420
+ rescue ArgumentError => e
421
+ puts e.message
422
+ puts global
423
+ exit 1
424
+ end
425
+ end
302
426
  end
303
427
 
428
+ #########
429
+
430
+ load_configuration $externals_file
431
+
432
+ parse(ARGV)
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |s|
3
+ s.name = 'obazoud-git-external'
4
+ s.version = '0.5.1'
5
+ s.platform = Gem::Platform::RUBY
6
+ s.authors = ['Daniel Cestari', 'Olivier Bazoud', 'Alastair Harrison']
7
+ s.email = ["olivier.bazoud@gmail.com"]
8
+ s.homepage = "http://github.com/obazoud/git-external"
9
+ s.summary = "Git version of an svn:external, an alternative to Git Submodule"
10
+ s.description = "Extension for git which adds a command providing similar functionality to git submodules but without attaching each module to a single version"
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.executables = `git ls-files`.split("\n").map{|f| f[/^bin\/(.*)/, 1]}.compact
14
+
15
+ s.required_ruby_version = '~> 1.8.7'
16
+
17
+ end
18
+
data/unittest.sh ADDED
@@ -0,0 +1,43 @@
1
+ #!/bin/sh
2
+ set -e
3
+ set -x
4
+
5
+ rm -rf .git .git* projects
6
+
7
+ git init
8
+
9
+ git external
10
+
11
+ git external list
12
+
13
+ git external add git://github.com/obazoud/statusdashboard.git projects/statusdashboard origin/master
14
+ cat .gitignore
15
+ cat .gitexternals
16
+ git external add git://github.com/obazoud/statusdashboard-client.git projects/statusdashboard-client origin/master
17
+ cat .gitignore
18
+ cat .gitexternals
19
+ git external add git://github.com/obazoud/statusdashboard-chrome.git projects/statusdashboard-chrome origin/master
20
+ cat .gitignore
21
+ cat .gitexternals
22
+
23
+ git external list
24
+
25
+ git external init
26
+ git external update
27
+ git external status
28
+
29
+ git external cmd 'git fetch'
30
+
31
+ git external rm projects/statusdashboard
32
+ cat .gitignore
33
+ cat .gitexternals
34
+ git external rm projects/statusdashboard-client
35
+ cat .gitignore
36
+ cat .gitexternals
37
+ git external rm projects/statusdashboard-chrome
38
+ cat .gitignore
39
+ cat .gitexternals
40
+
41
+ git external list
42
+
43
+ #rm -rf .git .git*
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obazoud-git-external
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 0
10
- version: 0.4.0
8
+ - 5
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Cestari
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-11-02 00:00:00 Z
20
+ date: 2012-11-13 00:00:00 Z
21
21
  dependencies: []
22
22
 
23
23
  description: Extension for git which adds a command providing similar functionality to git submodules but without attaching each module to a single version
@@ -30,7 +30,12 @@ extensions: []
30
30
  extra_rdoc_files: []
31
31
 
32
32
  files:
33
+ - .gitignore
34
+ - LICENSE.txt
35
+ - README.markdown
33
36
  - bin/git-external
37
+ - obazoud-git-external.gemspec
38
+ - unittest.sh
34
39
  homepage: http://github.com/obazoud/git-external
35
40
  licenses: []
36
41