Sha256: 297a2df7017eda6754153256be160b45d44a2fca39e0e4d88cef22a1c0c37da5

Contents?: true

Size: 1007 Bytes

Versions: 12

Compression:

Stored size: 1007 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(" && "), 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 reset HEAD --hard",
      "git checkout #{branch}",
      "git reset --hard '@{u}'",
      "git pull --force",
    ].join(" && "), merge_stderr: true)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
kuber_kit-1.3.2 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.1.5 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.3.1 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.3.0 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.1.4 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.2.7 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.2.6 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.2.5 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.2.4 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.2.2 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.1.2 lib/kuber_kit/shell/commands/git_commands.rb
kuber_kit-1.2.1 lib/kuber_kit/shell/commands/git_commands.rb