diff --git a/src/GitRepository.php b/src/GitRepository.php index 66d67b2..3935ca6 100644 --- a/src/GitRepository.php +++ b/src/GitRepository.php @@ -996,5 +996,20 @@ public function getCommitData($commit) return $data; } + + /** + * Return history of commit for specific file + * `git log -p (-%number) -- %file` + * @param string file in repository + * @param int number of last commits + * @return string + */ + public function getFileHistory($file, $number_of_commits=FALSE) + { + $this->begin(); + exec('git log -p ' . ($number_of_commits?"-".$number_of_commits:"") . ' -- ' . $file . ' 2>&1', $message); + $this->end(); + return implode(PHP_EOL, $message); + } }