From de139943d8272773b5f19ed824d687b0232b9ba3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 11 Mar 2023 09:03:03 +0100 Subject: Adding upstream version 0.19.1. Signed-off-by: Daniel Baumann --- gitlint-core/gitlint/git.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'gitlint-core/gitlint/git.py') diff --git a/gitlint-core/gitlint/git.py b/gitlint-core/gitlint/git.py index 4b292f0..6612a7d 100644 --- a/gitlint-core/gitlint/git.py +++ b/gitlint-core/gitlint/git.py @@ -5,13 +5,12 @@ from pathlib import Path import arrow from gitlint import shell as sh +from gitlint.cache import PropertyCache, cache +from gitlint.exception import GitlintError # import exceptions separately, this makes it a little easier to mock them out in the unit tests from gitlint.shell import CommandNotFound, ErrorReturnCode -from gitlint.cache import PropertyCache, cache -from gitlint.exception import GitlintError - # For now, the git date format we use is fixed, but technically this format is determined by `git config log.date` # We should fix this at some point :-) GIT_TIMEFORMAT = "YYYY-MM-DD HH:mm:ss Z" @@ -22,8 +21,6 @@ LOG = logging.getLogger(__name__) class GitContextError(GitlintError): """Exception indicating there is an issue with the git context""" - pass - class GitNotInstalledError(GitContextError): def __init__(self): @@ -46,7 +43,7 @@ def _git(*command_parts, **kwargs): git_kwargs.update(kwargs) try: LOG.debug(command_parts) - result = sh.git(*command_parts, **git_kwargs) # pylint: disable=unexpected-keyword-arg + result = sh.git(*command_parts, **git_kwargs) # If we reach this point and the result has an exit_code that is larger than 0, this means that we didn't # get an exception (which is the default sh behavior for non-zero exit codes) and so the user is expecting # a non-zero exit code -> just return the entire result @@ -80,7 +77,7 @@ def git_commentchar(repository_path=None): """Shortcut for retrieving comment char from git config""" commentchar = _git("config", "--get", "core.commentchar", _cwd=repository_path, _ok_code=[0, 1]) # git will return an exit code of 1 if it can't find a config value, in this case we fall-back to # as commentchar - if hasattr(commentchar, "exit_code") and commentchar.exit_code == 1: # pylint: disable=no-member + if hasattr(commentchar, "exit_code") and commentchar.exit_code == 1: commentchar = "#" return commentchar.replace("\n", "") @@ -174,11 +171,6 @@ class GitChangedFileStats: def __str__(self) -> str: return f"{self.filepath}: {self.additions} additions, {self.deletions} deletions" - def __repr__(self) -> str: - return ( - f'GitChangedFileStats(filepath="{self.filepath}", additions={self.additions}, deletions={self.deletions})' - ) - class GitCommit: """Class representing a git commit. @@ -193,7 +185,7 @@ class GitCommit: message, sha=None, date=None, - author_name=None, # pylint: disable=too-many-arguments + author_name=None, author_email=None, parents=None, changed_files_stats=None, @@ -289,7 +281,7 @@ class LocalGitCommit(GitCommit, PropertyCache): startup time and reduces gitlint's memory footprint. """ - def __init__(self, context, sha): # pylint: disable=super-init-not-called + def __init__(self, context, sha): PropertyCache.__init__(self) self.context = context self.sha = sha @@ -382,7 +374,7 @@ class StagedLocalGitCommit(GitCommit, PropertyCache): information. """ - def __init__(self, context, commit_message): # pylint: disable=super-init-not-called + def __init__(self, context, commit_message): PropertyCache.__init__(self) self.context = context self.message = commit_message -- cgit v1.2.3