Skip to content

Commit

Permalink
now with fetching refs
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Seitz committed Sep 21, 2023
1 parent 263a959 commit e8e2720
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tools/tests/systemtests/Systemtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,22 @@ def _get_git_ref(self, repository: Path, abbrev_ref=False) -> Optional[str]:
except Exception as e:
raise RuntimeError(f"An error occurred while getting the current Git ref: {e}") from e


def _fetch_ref(self, repository: Path, ref: str):
try:
result = subprocess.run([
"git",
"-C", os.fspath(repository.resolve()),
"fetch",
"origin",
ref
], check=True, timeout=60)
if result.returncode != 0:
raise RuntimeError(f"git command returned code {result.returncode}")

except Exception as e:
raise RuntimeError(f"An error occurred while fetching origin '{ref}': {e}")

def _checkout_ref_in_subfolder(self, repository: Path, subfolder: Path, ref: str):
try:
result = subprocess.run([
Expand All @@ -252,6 +268,7 @@ def __copy_tutorial_into_directory(self, run_directory: Path):
ref_requested = self.params_to_use.get("TUTORIALS_REF")
if ref_requested:
logging.debug(f"Checking out tutorials {ref_requested} before copying")
self._fetch_ref(PRECICE_TUTORIAL_DIR,ref_requested)
self._checkout_ref_in_subfolder(PRECICE_TUTORIAL_DIR, self.tutorial.path, ref_requested)

self.tutorial_folder = slugify(f'{self.tutorial.path.name}_{self.case_combination.cases}_{current_time_string}')
Expand Down

0 comments on commit e8e2720

Please sign in to comment.