summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgit2rss41
1 files changed, 38 insertions, 3 deletions
diff --git a/git2rss b/git2rss
index a494ea1..ab6be66 100755
--- a/git2rss
+++ b/git2rss
@@ -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();