Sha256: d80acd52d7dc5cd405da3c56752c2274683ed9a730e7819e47b8371cfe1de331

Contents?: true

Size: 726 Bytes

Versions: 9

Compression:

Stored size: 726 Bytes

Contents

class KuberKit::Shell::GitCommands
  def get_remote_url(shell, git_repo_path, remote_name: "origin")
    shell.exec! [
      "cd #{git_repo_path}",
      "git config --get remote.#{remote_name}.url",
    ].join(" && ")
  rescue KuberKit::Shell::AbstractShell::ShellError
    return nil
  end

  def download_repo(shell, remote_url:, path:, branch:)
    shell.exec! [
      "rm -rf #{path}",
      "mkdir -p #{path}",
      "git clone -b #{branch} --depth 1 #{remote_url} #{path}",
    ].join(" && ")
  end

  def force_pull_repo(shell, path:, branch:)
    shell.exec! [
      "cd #{path}",
      "git add .",
      "git reset HEAD --hard",
      "git checkout #{branch}",
      "git pull --force",
    ].join(" && ")
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kuber_kit-0.1.8 lib/kuber_kit/shell/git_commands.rb
kuber_kit-0.1.7 lib/kuber_kit/shell/git_commands.rb
kuber_kit-0.1.6 lib/kuber_kit/shell/git_commands.rb
kuber_kit-0.1.5 lib/kuber_kit/shell/git_commands.rb
kuber_kit-0.1.4 lib/kuber_kit/shell/git_commands.rb
kuber_kit-0.1.3 lib/kuber_kit/shell/git_commands.rb
kuber_kit-0.1.2 lib/kuber_kit/shell/git_commands.rb
kuber_kit-0.1.1 lib/kuber_kit/shell/git_commands.rb
kuber_kit-0.1.0 lib/kuber_kit/shell/git_commands.rb