Skip to content

Commit 562eaa0

Browse files
committed
squash: remove duplicate fmf_root validation
1 parent e0d0fe0 commit 562eaa0

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

tmt/steps/discover/shell.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,14 @@ def show(self, keys: Optional[list[str]] = None) -> None:
291291
if self.data.tests:
292292
click.echo(tmt.utils.format('tests', [test.name for test in self.data.tests]))
293293

294+
def checkout_ref(self) -> None:
295+
super().checkout_ref()
296+
297+
keep_git_metadata = True if self.data.dist_git_source else self.data.keep_git_metadata
298+
if not keep_git_metadata:
299+
# Remove .git so that it's not copied to the SUT
300+
shutil.rmtree(self.test_dir / '.git', ignore_errors=True)
301+
294302
def _fetch_local_repository(self) -> Optional[Path]:
295303
assert self.step.plan.worktree # narrow type
296304

@@ -325,24 +333,6 @@ def go(self, *, path: Optional[Path] = None, logger: Optional[tmt.log.Logger] =
325333

326334
self.log_import_plan_details()
327335

328-
# Git metadata are necessary for dist_git_source
329-
keep_git_metadata = True if self.data.dist_git_source else self.data.keep_git_metadata
330-
331-
if keep_git_metadata:
332-
if self.step.plan.fmf_root:
333-
# If exists, git_root can be only the same or parent of fmf_root
334-
git_root = tmt.utils.git.git_root(
335-
fmf_root=self.step.plan.fmf_root, logger=self._logger
336-
)
337-
if git_root and git_root != self.step.plan.fmf_root:
338-
raise tmt.utils.DiscoverError(
339-
"The 'keep-git-metadata' option can be "
340-
"used only when fmf root is the same as git root."
341-
)
342-
else:
343-
# Remove .git so that it's not copied to the SUT
344-
shutil.rmtree(self.test_dir / '.git', ignore_errors=True)
345-
346336
# Check and process each defined shell test
347337
for data in self.data.tests:
348338
# Create data copy (we want to keep original data for save()

0 commit comments

Comments
 (0)