Skip to content

Commit 0cb54a8

Browse files
committed
ENH: orchestrators: Make head_at() helper abort on submodule changes
head_at() already aborts with a dirty repository to avoid losing any changes. But, if a submodule changed between the current and target commit, the repository may become dirty after checking out the target. In that case, the submodule is carrying an undefined set of changes that could cause confusion (e.g., if the submodule change came in with a save).
1 parent 1fa72ca commit 0cb54a8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

reproman/support/jobs/orchestrators.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,13 @@ def head_at(dataset, commit):
895895
lgr.info("Checking out %s", commit)
896896
try:
897897
dataset.repo.checkout(commit)
898+
# Note: It's tempting try to use --recurse-submodules here, but
899+
# that will absorb submodule's .git/ directories, and DataLad
900+
# relies on plain .git/ directories.
901+
if dataset.repo.dirty:
902+
raise OrchestratorError(
903+
"Refusing to move HEAD due to submodule state change "
904+
"within {}".format(dataset.path))
898905
yield moved
899906
finally:
900907
lgr.info("Restoring checkout of %s", to_restore)

0 commit comments

Comments
 (0)