Class: Braid::Commands::Add
- Inherits:
-
Braid::Command
- Object
- Braid::Command
- Braid::Commands::Add
- Defined in:
- lib/braid/commands/add.rb
Instance Method Summary collapse
Methods inherited from Braid::Command
#config, #force?, msg, #msg, run, #verbose?
Methods included from Operations::VersionControl
Instance Method Details
#run(url, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/braid/commands/add.rb', line 4 def run(url, = {}) with_reset_on_error do mirror = config.(url, ) add_config_file mirror.branch = nil if ['revision'] raise BraidError, 'Can not add mirror specifying both a revision and a tag' if ['revision'] && mirror.tag = (mirror.branch.nil? || mirror.branch == 'master') ? '' : " branch '#{mirror.branch}'" = mirror.tag.nil? ? '' : " tag '#{mirror.tag}'" = ['revision'] ? " at #{display_revision(mirror, ['revision'])}" : '' msg "Adding mirror of '#{mirror.url}'#{}#{}#{}." # these commands are explained in the subtree merge guide # http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html config.update(mirror) setup_remote(mirror) mirror.fetch new_revision = validate_new_revision(mirror, ['revision']) target_item = mirror.upstream_item_for_revision(new_revision) git.add_item_to_index(target_item, mirror.path, true) mirror.revision = new_revision config.update(mirror) add_config_file git.commit("Add mirror '#{mirror.path}' at #{display_revision(mirror)}") msg "Added mirror at #{display_revision(mirror)}." clear_remote(mirror, ) end end |