Class: Git::Commands::Mv Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/mv.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

arguments block audited against https://git-scm.com/docs/git-mv/2.53.0

Implements git mv to move or rename a file, a directory, or a symlink

The index is updated after successful completion, but the change must still be committed.

Examples:

Move a single file

mv = Git::Commands::Mv.new(execution_context)
mv.call('old_name.rb', 'new_name.rb')

Move multiple files to a directory

mv = Git::Commands::Mv.new(execution_context)
mv.call('file1.rb', 'file2.rb', 'destination_dir/')

Force overwrite if destination exists

mv = Git::Commands::Mv.new(execution_context)
mv.call('source.rb', 'dest.rb', force: true)

See Also:

Instance Method Summary collapse

Methods inherited from Base

allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation

Constructor Details

This class inherits a constructor from Git::Commands::Base

Instance Method Details

#call(*source, destination, **options) ⇒ Git::CommandLineResult

Execute the git mv command

Parameters:

  • source (Array<String>)

    one or more source file(s) or directories to move

  • destination (String)

    the destination file or directory

  • options (Hash)

    command options

Options Hash (**options):

  • :verbose (Boolean, nil) — default: nil

    report the names of files as they are moved

    Alias: :v

  • :force (Boolean, nil) — default: nil

    force renaming or moving even if the destination exists

    Alias: :f

  • :dry_run (Boolean, nil) — default: nil

    do nothing; only show what would happen

    Alias: :n

  • :k (Boolean, nil) — default: nil

    skip move or rename actions which would lead to an error

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/mv.rb', line 44