Skip to content

Commit 2a69aa2

Browse files
authored
fix(core): checkout template repository by revision (#2189)
* fix #2024 * add test for checking out project template with a specified commit sha
1 parent 06d4969 commit 2a69aa2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

renku/core/commands/init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,14 @@ def fetch_template_from_git(source, ref=None, tempdir=None):
354354
if ref:
355355
try:
356356
# fetch ref and set the HEAD
357-
template_repo.remotes.origin.fetch(ref)
357+
template_repo.remotes.origin.fetch()
358358
try:
359359
template_repo.head.reset(template_repo.commit(ref))
360360
except git.exc.BadName:
361361
ref = "origin/{0}".format(ref)
362362
template_repo.head.reset(template_repo.commit(ref))
363363
git_repo = git.Git(str(tempdir))
364-
except git.exc.GitCommandError as e:
364+
except (git.exc.GitCommandError, git.exc.BadName) as e:
365365
raise errors.GitError("Cannot fetch and checkout reference {0}".format(ref)) from e
366366
else:
367367
template_repo.remotes.origin.fetch()

tests/core/commands/test_init.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def test_fetch_template_from_git(template):
5050
# ? REF: https://docs.pytest.org/en/stable/proposals/parametrize_with_fixtures.html
5151
parametrize = [
5252
{"url": template["url"], "ref": template["ref"], "error": None},
53+
{"url": template["url"], "ref": "817b03c", "error": None},
5354
{"url": "fake", "ref": template["ref"], "error": errors.GitError},
5455
{"url": template["url"], "ref": "fake", "error": errors.GitError},
5556
]

0 commit comments

Comments
 (0)