Skip to content

Commit

Permalink
explicitly check if we are inside a git repo (fixes #24)
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Mar 11, 2024
1 parent d39c191 commit 202adea
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions livesync/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 202adea

Please sign in to comment.