Skip to content

Commit

Permalink
g: Handle cases where not in a VCS directory
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Jun 8, 2024
1 parent 605bb4a commit da2e087
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/g/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
"""Package for g."""

import io
import logging
import os
import pathlib
import subprocess
Expand All @@ -12,6 +14,8 @@

vcspath_registry = {".git": "git", ".svn": "svn", ".hg": "hg"}

log = logging.getLogger(__name__)


def find_repo_type(path: t.Union[pathlib.Path, str]) -> t.Optional[str]:
for _path in [*list(pathlib.Path(path).parents), pathlib.Path(path)]:
Expand Down Expand Up @@ -45,6 +49,13 @@ def run(
if cmd_args is DEFAULT:
cmd_args = sys.argv[1:]

logging.basicConfig(level=logging.INFO, format="%(message)s")

if cmd is None:
msg = "No VCS found in current directory."
log.info(msg)
return None

assert isinstance(cmd_args, (tuple, list))
assert isinstance(cmd, (str, bytes, pathlib.Path))

Expand Down

0 comments on commit da2e087

Please sign in to comment.