summaryrefslogtreecommitdiffstats
path: root/git2rss
blob: ab6be6695973757ee75938e0e978e9ad4564d199 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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);
} else {
	$histo = array();
}

$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();