diff options
author | Remi Collet <fedora@famillecollet.com> | 2017-03-27 14:24:50 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2017-03-27 14:24:50 +0200 |
commit | 44ecc6ffc42eca97f9ae71799ba9a866183d1120 (patch) | |
tree | a41aa789fbdd1477feeaa7b42a997162b7e66e15 | |
parent | ec1833347808facb0cbdfa17260b4dd9dc0e39c6 (diff) |
minor second
-rwxr-xr-x | git2rss | 41 |
1 files changed, 38 insertions, 3 deletions
@@ -1,6 +1,12 @@ #!/usr/bin/env php <?php +require __DIR__ . '/vendor/autoload.php'; + +use Suin\RSSWriter\Channel; +use Suin\RSSWriter\Feed; +use Suin\RSSWriter\Item; + if (file_exists(__DIR__ . '/git2rss.json')) { $json = file_get_contents(__DIR__ . '/git2rss.json'); $histo = json_decode($json, true); @@ -8,6 +14,35 @@ if (file_exists(__DIR__ . '/git2rss.json')) { $histo = array(); } -$log = exec("git log --pretty=format:%H,%ai,%an,%s -1"); -$log = explode(',', $log, 4); -var_dump($log); +$repo = basename(getcwd(), '.git'); +$head = basename($_SERVER['argv'][1] ?: 'master'); +$log = exec("git log --pretty=format:%H,%at,%an,%s -1"); +$log = list($hash,$time,$author,$comment)=explode(',', $log, 4); +$short = substr($hash, 0, 7); +$msg = "$author pushed to $repo ($head,$short): $comment"; + + +$feed = new Feed(); +$channel = new Channel(); +$channel + ->title("Remi's RPM git repostiories") + ->description('Change') + ->url('https://git.remirepo.net/cgit') + ->language('en-US') + ->copyright('Copyright 2005-2017, Remi Collet') + ->pubDate(time()) + ->lastBuildDate(time()) + ->ttl(60) + ->appendTo($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(); |