Sha256: be20a5df888b72e9cb7d020fb2fd8e29e75320ddbd6884de8a4bed9807ebec2c

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

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(" && "), merge_stderr: true)
  rescue KuberKit::Shell::AbstractShell::ShellError
    return nil
  end

  def get_branch_name(shell, git_repo_path, remote_name: "origin")
    shell.exec!([
      "cd #{git_repo_path}",
      "git rev-parse --abbrev-ref HEAD",
    ].join(" && "), merge_stderr: true)
  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(" && "), merge_stderr: true)
  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(" && "), merge_stderr: true)
  end

  def force_pull_repo(shell, path:, branch:)
    shell.exec!([
      "cd #{path}",
      "git add .",
      "git fetch origin #{branch}",
      "git reset --hard '@{u}'"
    ].join(" && "), merge_stderr: true)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kuber_kit-1.3.8 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.3.7 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.1.8 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.3.6 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.1.7 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.3.5 lib/kuber_kit/shell/commands/git_commands.rb