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
Methods included from Operations::VersionControl
#git, #git_cache, #git_svn, #svn
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 |
# File 'lib/braid/commands/add.rb', line 4 def run(url, = {}) bail_on_local_changes! with_reset_on_error do mirror = config.(url, ) = (mirror.type == "svn" || mirror.branch == "master") ? "" : " branch '#{mirror.branch}'" = ["revision"] ? " at #{display_revision(mirror)}" : "" msg "Adding #{mirror.type} mirror of '#{mirror.url}'#{branch_message}#{revision_message}." # these commands are explained in the subtree merge guide # http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html setup_remote(mirror) mirror.fetch new_revision = validate_new_revision(mirror, ["revision"]) target_hash = determine_target_commit(mirror, new_revision) unless mirror.squashed? git.merge_ours(target_hash) end git.read_tree(target_hash, mirror.path) mirror.revision = new_revision mirror.lock = new_revision if ["revision"] config.update(mirror) add_config_file = "Add mirror '#{mirror.path}/'#{revision_message}" git.commit() end end |