From 17a425ec99e210e7e614e43a3900c17760793f85 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Wed, 24 Nov 2010 10:32:49 -0500 Subject: [PATCH] Helper methods for getting the number of added and deleted lines on a patchset without having to know the internals of the patchset object. --- framework/Vcs/lib/Horde/Vcs/Log.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/framework/Vcs/lib/Horde/Vcs/Log.php b/framework/Vcs/lib/Horde/Vcs/Log.php index 6645db71f..139070166 100644 --- a/framework/Vcs/lib/Horde/Vcs/Log.php +++ b/framework/Vcs/lib/Horde/Vcs/Log.php @@ -152,4 +152,28 @@ abstract class Horde_Vcs_Log ? $this->_files : (isset($this->_files[$file]) ? $this->_files[$file] : array()); } + + public function getAddedLines() + { + $this->_ensureInitialized(); + $lines = 0; + foreach ($this->_files as $file) { + if (isset($file['added'])) { + $lines += $file['added']; + } + } + return $lines; + } + + public function getDeletedLines() + { + $this->_ensureInitialized(); + $lines = 0; + foreach ($this->_files as $file) { + if (isset($file['deleted'])) { + $lines += $file['deleted']; + } + } + return $lines; + } } -- 2.11.0