mirror of
https://github.com/odoo/runbot.git
synced 2025-03-30 23:05:44 +07:00
[IMP] forwardport: git commands logging
- When updating the local repo cache, always capture both stdout and stderr and log them out rather than having them in journalctl hard to relate to the main log. - In the git layer, capture stderr by default and log it automatically on command failure.
This commit is contained in:
parent
2aeecb68b9
commit
9c1585383a
@ -782,8 +782,13 @@ This PR targets %s and is part of the forward-port chain. Further PRs will be cr
|
|||||||
"""
|
"""
|
||||||
source = self._get_local_directory()
|
source = self._get_local_directory()
|
||||||
# update all the branches & PRs
|
# update all the branches & PRs
|
||||||
_logger.info("Update %s", source._directory)
|
r = source.with_params('gc.pruneExpire=1.day.ago')\
|
||||||
source.with_params('gc.pruneExpire=1.day.ago').fetch('-p', 'origin')
|
.with_config(
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT
|
||||||
|
)\
|
||||||
|
.fetch('-p', 'origin')
|
||||||
|
_logger.info("Updated %s:\n%s", source._directory, r.stdout.decode())
|
||||||
# FIXME: check that pr.head is pull/{number}'s head instead?
|
# FIXME: check that pr.head is pull/{number}'s head instead?
|
||||||
source.cat_file(e=self.head)
|
source.cat_file(e=self.head)
|
||||||
# create working copy
|
# create working copy
|
||||||
@ -1057,6 +1062,7 @@ def git(directory): return Repo(directory, check=True)
|
|||||||
class Repo:
|
class Repo:
|
||||||
def __init__(self, directory, **config):
|
def __init__(self, directory, **config):
|
||||||
self._directory = str(directory)
|
self._directory = str(directory)
|
||||||
|
config.setdefault('stderr', subprocess.PIPE)
|
||||||
self._config = config
|
self._config = config
|
||||||
self._params = ()
|
self._params = ()
|
||||||
self._opener = subprocess.run
|
self._opener = subprocess.run
|
||||||
@ -1066,12 +1072,14 @@ class Repo:
|
|||||||
|
|
||||||
def _run(self, *args, **kwargs):
|
def _run(self, *args, **kwargs):
|
||||||
opts = {**self._config, **kwargs}
|
opts = {**self._config, **kwargs}
|
||||||
return self._opener(
|
args = ('git', '-C', self._directory)\
|
||||||
('git', '-C', self._directory)
|
+ tuple(itertools.chain.from_iterable(('-c', p) for p in self._params))\
|
||||||
+ tuple(itertools.chain.from_iterable(('-c', p) for p in self._params))
|
+ args
|
||||||
+ args,
|
try:
|
||||||
**opts
|
return self._opener(args, **opts)
|
||||||
)
|
except subprocess.CalledProcessError as e:
|
||||||
|
_logger.error("git call error:\n%s", e.stderr.decode())
|
||||||
|
raise
|
||||||
|
|
||||||
def stdout(self, flag=True):
|
def stdout(self, flag=True):
|
||||||
if flag is True:
|
if flag is True:
|
||||||
|
Loading…
Reference in New Issue
Block a user