def _is_dir_git_repo(self) -> bool: # This information is always computed given that it can change over the time # (i.e. when replacing URL repo from local to git and vice versa) return run_bash( f"git -C {self.dir} rev-parse --is-inside-work-tree", capture_stdout=True, capture_stderr=True, check=False ).stdout.strip() == "true"
def test_run_bash(script, input, expected_stdout, expected_status): result = run_bash(script, input=input, capture_stdout=True, check=False, capture_stderr=True) assert result.stdout == expected_stdout assert result.returncode == expected_status
def _dir_url(self) -> str: """ This function allows to understand whether a package URL has changed over the time. There are two URLs: - The "package URL" - is loaded by looking at the pearl configuration file (pearl.conf) - The "package directory URL" - is retrieved by looking at the package directory content using "git config" command. Returns ------- If the package is not local (a git repo), the function return the "package directory URL" using "git config" command. Raises ------ If package is not a git repo the git command will fail. """ # This information is always computed given that it can change over the time # (i.e. when replacing URL repo from local to git and vice versa) package_dir_url = run_bash( f"git -C {self.dir} config remote.origin.url", check=False, capture_stdout=True ).stdout.strip() return package_dir_url