Sha256: 106ee3b38ecf129f25a8d9e93b8e16d82d03392b637257ab5675ff9af21860b5

Contents?: true

Size: 936 Bytes

Versions: 95

Compression:

Stored size: 936 Bytes

Contents

class KuberKit::ArtifactsSync::GitArtifactResolver < KuberKit::ArtifactsSync::AbstractArtifactResolver

  include KuberKit::Import[
    "shell.git_commands",
  ]

  Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Artifacts::Git => Any
  def resolve(shell, artifact)
    already_cloned = artifact_already_cloned?(
      shell:       shell,
      target_path: artifact.cloned_path,
      remote_url:  artifact.remote_url,
    )

    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

  private
    def artifact_already_cloned?(shell:, target_path:, remote_url:)
      target_remote_url = git_commands.get_remote_url(shell, target_path)
      target_remote_url == remote_url
    end
end

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
kuber_kit-1.3.2 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.1.5 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.3.1 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.3.0 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.1.4 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.2.7 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.2.6 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.2.5 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.2.4 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.2.2 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.1.2 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.2.1 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.2.0 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.1.1 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.0.1 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-1.0.0 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-0.9.9 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-0.9.8 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-0.9.7 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
kuber_kit-0.9.6 lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb