diff options
| -rwxr-xr-x | git2rss | 12 | 
1 files changed, 6 insertions, 6 deletions
| @@ -12,8 +12,10 @@  if (PHP_SAPI != 'cli') die ("CLI only"); +// Configuration  define('LOCAL', dirname(__DIR__) . '/');  define('REMOTE', 'https://git.remirepo.net/cgit/'); +define('FEEDSIZE', 50);  require __DIR__ . '/vendor/autoload.php'; @@ -21,6 +23,7 @@ use Suin\RSSWriter\Channel;  use Suin\RSSWriter\Feed;  use Suin\RSSWriter\Item; +// Load previous changes  if (file_exists(__DIR__ . '/git2rss.json')) {  	$json = file_get_contents(__DIR__ . '/git2rss.json');  	$histo = json_decode($json, true); @@ -28,7 +31,6 @@ if (file_exists(__DIR__ . '/git2rss.json')) {  	$histo = array();  } -  // Current change  $log = exec("git log --pretty=format:%H,%at,%an,%s -1");  $entry = [ @@ -39,14 +41,12 @@ list($entry['hash'], $entry['time'], $entry['author'], $entry['comment']) = expl  if (substr($entry['repo'], -4) != '.git') {  	$entry['repo'] .= '.git';  } -// print_r($entry);  $short = substr($entry['hash'], 0, 7); -echo "RSS ENTRY: ${entry['author']} pushed to ${entry['repo']} (${entry['head']},$short): ${entry['comment']}"; - +echo "\nRSS ENTRY: ${entry['author']} pushed to ${entry['repo']} (${entry['head']},$short): ${entry['comment']}\n"; -// 50 recent changes +// 50 recent changes, and save  $histo = array_merge([$entry], $histo); -while (count($histo) > 50) { +while (count($histo) > FEEDSIZE) {  	array_pop($histo);  }  file_put_contents(__DIR__ . '/git2rss.json', json_encode($histo, JSON_PRETTY_PRINT)); | 
