#!/usr/bin/env php
<?php declare(strict_types=1);
$repositories = [
    'bebbo/amiga-gcc',
    'bebbo/amiga-netinclude',
    'bebbo/binutils-gdb',
    'bebbo/clib2',
    'bebbo/fd2pragma',
    'cahirwpz/fd2sfd',
    'bebbo/gcc',
    'bebbo/ira',
    'bebbo/ixemul',
    'jca02266/lha',
    'bebbo/libdebug',
    'bebbo/libnix',
    'AmigaPorts/libSDL12',
    'bebbo/newlib-cygwin',
    'adtools/sfdc',
    'leffmann/vasm',
    'bebbo/vbcc',
    'leffmann/vlink',
    'bebbo/aros-stuff',
];

foreach ($repositories as $repository) {
    $file = __DIR__ . '/.revisions/' . $repository;
    $old  = trim(file_get_contents($file)); 

    $new = trim(
        shell_exec(
            'git ls-remote https://github.com/' . $repository . '.git | grep HEAD | awk \'{ print $1}\''
        )
    );

    if ($old !== $new) {
        print $repository . ' has new commits' . PHP_EOL;

        file_put_contents($file, $new);
    }
}

