Simplify Git class in ansible-test.
This commit is contained in:
parent
cf7ee8eb12
commit
4403f866e3
3 changed files with 16 additions and 12 deletions
|
@ -304,7 +304,7 @@ def get_git_details(args):
|
|||
return git_details
|
||||
|
||||
|
||||
def get_merged_commit(args, commit):
|
||||
def get_merged_commit(args, commit): # pylint: disable=unused-argument
|
||||
"""
|
||||
:type args: CommonConfig
|
||||
:type commit: str
|
||||
|
@ -313,7 +313,7 @@ def get_merged_commit(args, commit):
|
|||
if not commit:
|
||||
return None
|
||||
|
||||
git = Git(args)
|
||||
git = Git()
|
||||
|
||||
try:
|
||||
show_commit = git.run_git(['show', '--no-patch', '--no-abbrev', commit])
|
||||
|
|
|
@ -1419,7 +1419,7 @@ def detect_changes_shippable(args):
|
|||
:type args: TestConfig
|
||||
:rtype: list[str] | None
|
||||
"""
|
||||
git = Git(args)
|
||||
git = Git()
|
||||
result = ShippableChanges(args, git)
|
||||
|
||||
if result.is_pr:
|
||||
|
@ -1442,7 +1442,7 @@ def detect_changes_local(args):
|
|||
:type args: TestConfig
|
||||
:rtype: list[str]
|
||||
"""
|
||||
git = Git(args)
|
||||
git = Git()
|
||||
result = LocalChanges(args, git)
|
||||
|
||||
display.info('Detected branch %s forked from %s at commit %s' % (
|
||||
|
|
|
@ -2,21 +2,25 @@
|
|||
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
try:
|
||||
# noinspection PyUnresolvedReferences
|
||||
from typing import (
|
||||
Optional,
|
||||
)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from lib.util import (
|
||||
CommonConfig,
|
||||
SubprocessError,
|
||||
run_command,
|
||||
raw_command,
|
||||
)
|
||||
|
||||
|
||||
class Git(object):
|
||||
"""Wrapper around git command-line tools."""
|
||||
def __init__(self, args):
|
||||
"""
|
||||
:type args: CommonConfig
|
||||
"""
|
||||
self.args = args
|
||||
def __init__(self, root=None): # type: (Optional[str]) -> None
|
||||
self.git = 'git'
|
||||
self.root = root
|
||||
|
||||
def get_diff(self, args, git_options=None):
|
||||
"""
|
||||
|
@ -117,4 +121,4 @@ class Git(object):
|
|||
:type str_errors: str
|
||||
:rtype: str
|
||||
"""
|
||||
return run_command(self.args, [self.git] + cmd, capture=True, always=True, str_errors=str_errors)[0]
|
||||
return raw_command([self.git] + cmd, cwd=self.root, capture=True, str_errors=str_errors)[0]
|
||||
|
|
Loading…
Reference in a new issue