Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/GitRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}