Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[logs] Add new log messages #137

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions perceval/backends/core/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,21 @@ def fetch(self, from_date=DEFAULT_DATETIME, branches=None):

def __fetch_and_parse_log(self, from_date, branches):
if os.path.isfile(self.gitpath):
logger.info("Fetching commits from the given log file %s", self.gitpath)
return self.parse_git_log_from_file(self.gitpath)
else:
logger.info("Log file not specified, retrieving from repository.")
repo = self.__create_and_update_git_repository()
gitlog = repo.log(from_date, branches)
return self.parse_git_log_from_iter(gitlog)

def __create_and_update_git_repository(self):
if not os.path.exists(self.gitpath):
logger.info("Git repository not found in %s", self.gitpath)
repo = GitRepository.clone(self.uri, self.gitpath)
elif os.path.isdir(self.gitpath):
logger.info("Found Git repository in %s", self.gitpath)
repo = GitRepository(self.uri, self.gitpath)

try:
repo.pull()
except EmptyRepositoryError:
Expand Down Expand Up @@ -664,11 +667,11 @@ def clone(cls, uri, dirpath):
:raises RepositoryError: when an error occurs cloning the given
repository
"""
logger.info("Cloning repository %s", uri)
cmd = ['git', 'clone', uri, dirpath]
cls._exec(cmd, env={'LANG': 'C'})

logger.debug("Git %s repository cloned into %s",
uri, dirpath)
logger.info("Git repository %s cloned into %s",
uri, dirpath)

return cls(uri, dirpath)

Expand Down