From abb805147ef0528018ce7c9a66f0805f6607f1c7 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 27 Mar 2017 15:13:27 +0200 Subject: initial version --- .gitignore | 2 ++ git2rss | 54 ++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 7579f74..eabced1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ vendor composer.lock +git2rss.json +index.html diff --git a/git2rss b/git2rss index ab6be66..5a141d4 100755 --- a/git2rss +++ b/git2rss @@ -1,6 +1,11 @@ #!/usr/bin/env php substr(getcwd(), strlen(LOCAL)), + 'head' => basename($_SERVER['argv'][1] ?? 'master'), +]; +list($entry['hash'], $entry['time'], $entry['author'], $entry['comment']) = explode(',', $log, 4); +if (substr($entry['repo'], -4) != '.git') { + $entry['repo'] .= '.git'; +} +// 50 recent changes +$histo = array_merge([$entry], $histo); +while (count($histo) > 50) { + array_pop($histo); +} +file_put_contents(__DIR__ . '/git2rss.json', json_encode($histo, JSON_PRETTY_PRINT)); +// RSS $feed = new Feed(); $channel = new Channel(); $channel ->title("Remi's RPM git repostiories") ->description('Change') - ->url('https://git.remirepo.net/cgit') + ->url(REMOTE) ->language('en-US') ->copyright('Copyright 2005-2017, Remi Collet') ->pubDate(time()) @@ -35,14 +52,19 @@ $channel ->ttl(60) ->appendTo($feed); +foreach ($histo as $entry) { + $short = substr($entry['hash'], 0, 7); + $msg = "${entry['author']} pushed to ${entry['repo']} (${entry['head']},$short): ${entry['comment']}"; + + $item = new Item(); + $item + ->title($msg) + ->description($msg) + ->url(REMOTE . "${entry['repo']}/commit/?id=${entry['hash']}") + ->author($entry['author']) + ->pubDate($entry['time']) + ->guid("${entry['repo']}_${entry['hash']}", true) + ->appendTo($channel); +} +file_put_contents(__DIR__ . '/index.html', $feed); -$item = new Item(); -$item - ->title($msg) - ->description($msg) - ->url('https://git.remirepo.net/cgit') - ->author($author) - ->pubDate($time) - ->guid("${repo}_${hash}", true) - ->appendTo($channel); -echo $feed; // or echo $feed->render(); -- cgit