Sha256: f06a26430615040123d8226c0aa83eef16521df10180fbf3d8c00d1d19376b2a

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

module Braid
  module Commands
    class Add < Command
      def run(url, options = {})
        bail_on_local_changes!

        with_reset_on_error do
          mirror = config.add_from_options(url, options)

          branch_message = (mirror.type == "svn" || mirror.branch == "master") ? "" : " branch '#{mirror.branch}'"
          revision_message = options["revision"] ? " at #{display_revision(mirror, options["revision"])}" : ""
          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)
          
          if mirror.type == "git-clone"
            gitclone.add_gitignore(mirror.path)
            mirror.rspec_git.update mirror.branch
            commit_message = "added \'#{mirror.rspec_git.url}\' to path:\'#{mirror.path}\'"
          else
            mirror.fetch

            new_revision = validate_new_revision(mirror, options["revision"])
            target_revision = determine_target_revision(mirror, new_revision)

            unless mirror.squashed?
              git.merge_ours(target_revision)
            end
            git.read_tree_prefix(target_revision, mirror.path)

            mirror.revision = new_revision
            mirror.lock = new_revision if options["revision"]
            commit_message = "Added mirror '#{mirror.path}' at #{display_revision(mirror)}"
        end
          
          config.update(mirror)
          add_config_file


          git.commit(commit_message)
          msg commit_message
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dreamcat4-braid-0.533 lib/braid/commands/add.rb
dreamcat4-braid-0.534 lib/braid/commands/add.rb