Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions renku/core/commands/providers/renku.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def find_record(self, uri, client=None):

self._prepare_authentication(client, uri)

initial_identifier, kg_urls = self._get_dataset_info(uri)
same_as, initial_identifier, kg_urls = self._get_dataset_info(uri)

project_url = None
failed_urls = []
Expand All @@ -77,7 +77,14 @@ def find_record(self, uri, client=None):

datasets = self._query_knowledge_graph(project_datasets_kg_url)

dataset_name = next(ds["name"] for ds in datasets if ds["versions"].get("initial") == initial_identifier)
dataset_name = next(
(ds["name"] for ds in datasets if ds["versions"].get("initial") == initial_identifier), None
)
if not dataset_name and same_as:
dataset_name = next((ds["name"] for ds in datasets if ds.get("sameAs") == same_as), None)

if not dataset_name:
continue

# Check if we can clone the project
for url in (ssh_url, https_url):
Expand Down Expand Up @@ -144,6 +151,7 @@ def _get_dataset_info(self, uri):

response = self._query_knowledge_graph(kg_url)
initial_identifier = response.get("versions", {}).get("initial")
same_as = response.get("sameAs")

if project_id:
kg_path = f"/knowledge-graph/{project_id.strip('/')}"
Expand All @@ -160,7 +168,7 @@ def get_project_link(project):
kg_urls = [get_project_link(p) for p in projects]
kg_urls = [u for u in kg_urls if u]

return initial_identifier, kg_urls
return same_as, initial_identifier, kg_urls

@staticmethod
def _extract_project_and_dataset_ids(parsed_url):
Expand Down
6 changes: 4 additions & 2 deletions renku/core/management/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ def _add_from_git(self, url, sources, destination, ref):
if remote_client._is_external_file(src):
operation = (src.resolve(), dst, "symlink")
else:
operation = (src, dst, "copy")
operation = (src, dst, "move")

results.append(
{
Expand Down Expand Up @@ -1237,6 +1237,7 @@ def checkout(repo, ref):
except GitCommandError:
raise errors.ParameterError('Cannot find reference "{}" in Git repository: {}'.format(ref, url))

depth = 1 if not ref else None
ref = ref or renku_branch
u = GitURL.parse(url)
path = u.pathname
Expand All @@ -1251,6 +1252,7 @@ def checkout(repo, ref):
repo = Repo(str(repo_path))
if repo.remotes.origin.url == url:
try:
repo.git.checkout(".")
repo.git.fetch(all=True)
repo.git.checkout(ref)
try:
Expand All @@ -1269,7 +1271,7 @@ def checkout(repo, ref):
except PermissionError:
raise errors.InvalidFileOperation("Cannot delete files in {}: Permission denied".format(repo_path))

repo, _ = clone(url, path=str(repo_path), install_githooks=False)
repo, _ = clone(url, path=str(repo_path), install_githooks=False, depth=depth)

# Because the name of the default branch is not always 'master', we
# create an alias of the default branch when cloning the repo. It
Expand Down