Class: KuberKit::ArtifactsSync::Strategies::GitUpdater

Inherits:
Abstract show all
Defined in:
lib/kuber_kit/artifacts_sync/strategies/git_updater.rb

Instance Method Summary collapse

Instance Method Details

#cleanup(shell, artifact) ⇒ Object



28
29
30
# File 'lib/kuber_kit/artifacts_sync/strategies/git_updater.rb', line 28

def cleanup(shell, artifact)
  bash_commands.rm_rf(shell, artifact.cloned_path)
end

#update(shell, artifact) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kuber_kit/artifacts_sync/strategies/git_updater.rb', line 9

def update(shell, artifact)
  already_cloned = artifact_already_cloned?(
    shell:      shell,
    repo_path:  artifact.cloned_path,
    artifact:   artifact
  )

  if already_cloned
    git_commands.force_pull_repo(shell, 
      path: artifact.cloned_path, branch: artifact.branch
    )
  else
    git_commands.download_repo(shell, 
      remote_url: artifact.remote_url, path: artifact.cloned_path, branch: artifact.branch
    )
  end
end