From 0cbdd5c80224bbdcc984bf082d5cecc6132e8602 Mon Sep 17 00:00:00 2001 From: Jan Pecha Date: Fri, 19 Apr 2013 20:49:35 +0200 Subject: [PATCH] added method rename() Signed-off-by: Jan Pecha --- Git.php | 26 ++++++++++++++++++++++++++ IGit.php | 10 ++++++++++ 2 files changed, 36 insertions(+) diff --git a/Git.php b/Git.php index acb6933..d800625 100644 --- a/Git.php +++ b/Git.php @@ -165,6 +165,32 @@ public function add($file) + /** + * Renames file(s). + * @param string|string[] from: array('from' => 'to', ...) || (from, to) + * @param string|NULL + * @throws Cz\Git\GitException + * @return Cz\Git\Git + */ + public function rename($file, $to = NULL) + { + if(!is_array($file)) // rename(file, to); + { + $from[$file] = $to; + $file = $from; + unset($from); + } + + foreach($file as $from => $to) + { + $this->run('git mv', $from, $to); + } + + return $this; + } + + + /** * Commits changes * @param string diff --git a/IGit.php b/IGit.php index 5fbda64..20e1031 100644 --- a/IGit.php +++ b/IGit.php @@ -82,6 +82,16 @@ public function add($file); + /** + * Renames file(s). + * @param string|string[] from: array('from' => 'to', ...) || (from, to) + * @param string|NULL + * @throws Cz\Git\GitException + */ + public function rename($file, $to = NULL); + + + /** * Commits changes * @param string