summaryrefslogtreecommitdiffstats
path: root/papis/git.py
diff options
context:
space:
mode:
Diffstat (limited to 'papis/git.py')
-rw-r--r--papis/git.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/papis/git.py b/papis/git.py
index 1590e8a7..faf82767 100644
--- a/papis/git.py
+++ b/papis/git.py
@@ -1,11 +1,9 @@
"""This module serves as an lightweight interface for git related functions.
"""
-import subprocess
import os
-import shlex
import logging
-LOGGER = logging.getLogger("papis.git")
+logger = logging.getLogger("git")
def _issue_git_command(path: str, cmd: str) -> None:
@@ -21,9 +19,13 @@ def _issue_git_command(path: str, cmd: str) -> None:
assert isinstance(cmd, str)
path = os.path.expanduser(path)
assert os.path.exists(path)
+
+ import shlex
split_cmd = shlex.split(cmd)
+ logger.debug(split_cmd)
+
+ import subprocess
os.chdir(path)
- LOGGER.debug(split_cmd)
subprocess.call(split_cmd)
@@ -37,7 +39,7 @@ def commit(path: str, message: str) -> None:
:returns: None
"""
- LOGGER.info('Commiting %s with message %s', path, message)
+ logger.info("Committing '%s' with message '%s'", path, message)
cmd = 'git commit -m "{0}"'.format(message)
_issue_git_command(path, cmd)
@@ -52,7 +54,7 @@ def add(path: str, resource: str) -> None:
:returns: None
"""
- LOGGER.info('Adding %s', path)
+ logger.info("Adding '%s'", path)
cmd = 'git add "{0}"'.format(resource)
_issue_git_command(path, cmd)
@@ -67,7 +69,7 @@ def remove(path: str, resource: str, recursive: bool = False) -> None:
:returns: None
"""
- LOGGER.info('Removing %s', path)
+ logger.info("Removing '%s'", path)
# force removal always
cmd = 'git rm -f {r} "{0}"'.format(resource, r="-r" if recursive else "")
_issue_git_command(path, cmd)