Sha256: 32c447870309d7f95793052b1d80ff7fbd22cbed164c8ea644a192f8a95aec22

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# typed: strict
module Braid
  module Commands
    class Remove < Command
      class Options < T::Struct
        prop :keep, T::Boolean
      end

      sig {params(path: String, options: Options).void}
      def initialize(path, options)
        @path = path
        @options = options
      end

      private

      sig {void}
      def run_internal
        mirror = config.get!(@path)

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

          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

          git.commit("Remove mirror '#{mirror.path}'")
          msg 'Removed mirror.' if verbose?
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
braid-1.1.10 lib/braid/commands/remove.rb