Sha256: f346cf3cc99daa06a9739e428dd549e91d73406cb46a57321452dabc23940764

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

module Braid
  module Commands
    class Remove < Command
      def run(path, options = {})
        mirror = config.get!(path)

        bail_on_local_changes!

        with_reset_on_error do
          msg "Removing mirror from '#{mirror.path}'."

          if mirror.type == "git-clone"
            gitclone.remove_gitignore(mirror.path)
            FileUtils.rm_rf(mirror.path)
            config.remove(mirror)
            add_config_file
            commit_message = "Removed clone repository '#{mirror.path}'"
          else
            git.rm_r(mirror.path)

            config.remove(mirror)
            add_config_file

            if options[:keep]
              msg "Not removing remote '#{mirror.remote}'" if verbose?
            elsif git.remote_url(mirror.remote)
              msg "Removed remote '#{mirror.path}'" if verbose?
              git.remote_rm mirror.remote
            else
              msg "Remote '#{mirror.remote}' not found, nothing to cleanup" if verbose?
            end
            commit_message = "Removed mirror '#{mirror.path}'"
          end

          git.commit(commit_message)
          msg commit_message
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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