From 282d6d7056bf8481d6f194e436dfb96ede6d559d Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Thu, 24 Jan 2013 07:59:11 -0500 Subject: Git: log output of GitPython commands --- src/lib/Bcfg2/Server/Plugins/Git.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/Bcfg2/Server/Plugins/Git.py b/src/lib/Bcfg2/Server/Plugins/Git.py index 8cc63a46f..e46c331b3 100644 --- a/src/lib/Bcfg2/Server/Plugins/Git.py +++ b/src/lib/Bcfg2/Server/Plugins/Git.py @@ -31,6 +31,11 @@ class Git(Bcfg2.Server.Plugin.Version): self.logger.debug("Initialized git plugin with git directory %s" % self.vcs_path) + def _log_git_cmd(self, output): + """ Send output from a GitPython command to the debug log """ + for line in output.strip().splitlines(): + self.debug_log("Git: %s" % line) + def get_revision(self): """Read git revision information for the Bcfg2 repository.""" try: @@ -60,7 +65,7 @@ class Git(Bcfg2.Server.Plugin.Version): self.debug_log("Git: Performing garbage collection on repo at %s" % self.vcs_root) try: - self.repo.git.gc('--auto') + self._log_git_cmd(self.repo.git.gc('--auto')) except git.GitCommandError: self.logger.warning("Git: Failed to perform garbage collection: %s" % sys.exc_info()[1]) @@ -68,7 +73,7 @@ class Git(Bcfg2.Server.Plugin.Version): if ref: self.debug_log("Git: Checking out %s" % ref) try: - self.repo.git.checkout('-f', ref) + self._log_git_cmd(self.repo.git.checkout('-f', ref)) except git.GitCommandError: err = sys.exc_info()[1] msg = "Git: Failed to checkout %s: %s" % (ref, err) @@ -87,7 +92,7 @@ class Git(Bcfg2.Server.Plugin.Version): self.debug_log("Git: %s is a tracking branch, pulling from %s" % (self.repo.head.ref.name, tracking)) try: - self.repo.git.pull("--rebase") + self._log_git_cmd(self.repo.git.pull("--rebase")) except: # pylint: disable=W0702 err = sys.exc_info()[1] msg = "Git: Failed to pull from upstream: %s" % err -- cgit v1.2.3-1-g7c22