Skip to content

Commit

Permalink
Move post-clone checkout of particular version prior to git-annex-init
Browse files Browse the repository at this point in the history
This fixes datalad/datalad#6964 and suppossedly
makes everything less complex and faster.

However,
datalad/datalad@1d9315e
made this exact move in the opposite direction!

The test supplied in that change nevertheless continues to pass. It may
be that git-annex has learned to cope better with the original
complication.
  • Loading branch information
mih committed Sep 7, 2022
1 parent ce2ebed commit 1ad7658
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions datalad_next/patches/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ def _post_gitclone_processing_(
reckless=reckless,
)

if checkout_gitsha and dest_repo.get_hexsha() != checkout_gitsha:
try:
# TODO now that this is guaranteed to run prior to git-annex-init
# the implementation of this helper could be simplified
postclone_checkout_commit(dest_repo, checkout_gitsha,
remote=remote)
except Exception:
# We were supposed to clone a particular version but failed to.
# This is particularly pointless in case of subdatasets and
# potentially fatal with current implementation of recursion.
# see gh-5387
lgr.debug(
"Failed to checkout %s, removing this clone attempt at %s",
checkout_gitsha, destds.path)
raise

if knows_annex(destds.path):
# init annex when traces of a remote annex can be detected
yield from _pre_annex_init_processing_(
Expand All @@ -200,22 +216,6 @@ def _post_gitclone_processing_(
reckless=reckless,
)

if checkout_gitsha and \
dest_repo.get_hexsha(
dest_repo.get_corresponding_branch()) != checkout_gitsha:
try:
postclone_checkout_commit(dest_repo, checkout_gitsha,
remote=remote)
except Exception:
# We were supposed to clone a particular version but failed to.
# This is particularly pointless in case of subdatasets and
# potentially fatal with current implementation of recursion.
# see gh-5387
lgr.debug(
"Failed to checkout %s, removing this clone attempt at %s",
checkout_gitsha, destds.path)
raise

yield from _pre_final_processing_(
destds=destds,
cfg=cfg,
Expand Down

0 comments on commit 1ad7658

Please sign in to comment.