diff --git a/livesync/folder.py b/livesync/folder.py index d8bda3d..4d478e5 100644 --- a/livesync/folder.py +++ b/livesync/folder.py @@ -60,12 +60,15 @@ def _get_ignores(self) -> List[str]: def get_summary(self) -> str: summary = f'{self.source_path} --> {self.target}\n' try: + cmd = ['git', 'rev-parse', '--is-inside-work-tree'] + subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except subprocess.CalledProcessError: + pass # not a git repo, git is not installed, or something else + else: cmd = ['git', 'log', '--pretty=format:[%h]\n', '-n', '1'] summary += subprocess.check_output(cmd, cwd=self.source_path).decode() cmd = ['git', 'status', '--short', '--branch'] summary += subprocess.check_output(cmd, cwd=self.source_path).decode().strip() + '\n' - except Exception: - pass # not a git repo, git is not installed, or something else return summary async def watch(self) -> None: