Sha256: 7197e347d391d2f9d25d23bc218de0c22af423c131c3743cc24cc195b68a7ecd

Contents?: true

Size: 923 Bytes

Versions: 5

Compression:

Stored size: 923 Bytes

Contents

class KuberKit::Shell::Commands::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 get_version_hash(shell, git_repo_path)
    shell.exec! [
      "cd #{git_repo_path}",
      "git rev-parse --short HEAD",
    ].join(" && ")
  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 reset --hard '@{u}'",
      "git pull --force",
    ].join(" && ")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kuber_kit-1.2.0 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.1.1 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.0.1 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.0.0 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-0.9.9 lib/kuber_kit/shell/commands/git_commands.rb