123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- require 'php-git/src/Git.php';
- $repository = __DIR__.'/../..';
- $number = 2000;
- $formatHTML = true;
- $showDate = false;
- $endCommit = false;
- $isMaxDate = false;
- if (!empty($argv[1])) {
- if ($argv[1] == '-t') {
- $showDate = true;
- } else if (substr($argv[1], 0, 4) == '-max') {
- $isMaxDate = true;
- $tempDate = substr($argv[1], 4);
- $y = substr($tempDate, 0, 4);
- $m = substr($tempDate, 4, 2);
- $d = substr($tempDate, 6, 2);
- $maxDate = new DateTime($y.'-'.$m.'-'.$d);
- } else {
- $endCommit = $argv[1];
- echo "An initial commit has been defined as ".$endCommit.PHP_EOL;
- }
- }
- $git = new \YWarnier\PHPGit\Git($repository);
- echo "Log from branch: ".$git->getCurrentBranch().PHP_EOL;
- $logs = $git->getRevisions('DESC', $number);
- $i = 0;
- foreach ($logs as $log) {
- $commitDate = $log['date']->format('Y-m-d');
- if ($showDate) {
- echo $commitDate.' '.substr($log['sha1'],0,8).PHP_EOL;
- }
- if ($isMaxDate) {
-
- if ($log['date'] < $maxDate) {
- continue;
- }
- }
-
- if (strncasecmp($log['message'], 'Minor', 5) === 0) {
-
- continue;
- }
-
- $langMsg = array(
- 'Update language terms',
- 'Update language vars',
- 'Update lang vars',
- 'Merge',
- 'merge',
- 'Scrutinizer Auto-Fixes',
- 'Update changelog',
- 'Fix PHP Warning'
- );
- foreach ($langMsg as $msg) {
- if (strpos($log['message'], $msg) === 0) {
- continue 2;
- }
- }
-
- $issueLink = '';
- $matches = array();
- if (preg_match_all('/((BT)?#(\d){2,5})/', $log['message'], $matches)) {
- $issue = $matches[0][0];
- if (substr($issue, 0, 1) == '#') {
-
- $num = substr($issue, 1);
- if ($num > 4000) {
-
- if ($formatHTML) {
- $issueLink = ' - <a href="https://support.chamilo.org/issues/' . $num . '">CT#' . $num . '</a>';
- } else {
- $issueLink = ' - ' . $num;
- }
- } else {
-
- if ($formatHTML) {
- $issueLink = ' - <a href="https://github.com/chamilo/chamilo-lms/issues/' . $num . '">GH#' . $num . '</a>';
- } else {
- $issueLink = ' - ' . $num;
- }
- }
- } else {
- $num = substr($issue, 3);
- if ($num != '7683') {
- if ($formatHTML) {
-
- $issueLink = ' - <a href="https://task.beeznest.com/issues/' . $num . '">BT#' . $num . '</a>';
- } else {
- $issueLink = ' - ' . $num;
- }
- }
- }
- if ($hasRefs = stripos($log['message'], ' see '.$issue)) {
- $log['message'] = substr($log['message'], 0, $hasRefs);
- }
- if ($hasRefs = stripos($log['message'], ' - ref')) {
- $log['message'] = substr($log['message'], 0, $hasRefs);
- }
- if ($hasRefs = stripos($log['message'], ' -refs ')) {
- $log['message'] = substr($log['message'], 0, $hasRefs);
- }
- }
- $commitLink = '';
- if ($formatHTML) {
- $log['message'] = ucfirst($log['message']);
- $commitLink = '<a href="https://github.com/chamilo/chamilo-lms/commit/' . $log['sha1'] . '">' .
- substr($log['sha1'], 0, 8) . '</a>';
- echo '<li>['.$commitDate.'] ('.$commitLink.$issueLink.') '.$log['message'].'</li>'.PHP_EOL;
- } else {
- $commitLink = substr($log['sha1'], 0, 8);
- echo '('.$commitLink.$issueLink.') '.$log['message'].''.PHP_EOL;
- }
-
- if ($endCommit) {
- $length = strlen($endCommit);
- if (substr($log['sha1'], 0, $length) == $endCommit) {
- echo "Found the end commit ".$endCommit.", exiting...".PHP_EOL;
- break;
- }
- }
- $i++;
- }
- echo "Printed $i commits of $number requested (others were minor)".PHP_EOL;
|