Author Topic: Keeping track of all those other muds you follow  (Read 1732 times)

Offline quixadhal

  • BFF
  • ***
  • Posts: 619
    • View Profile
    • A Waste of Time
Keeping track of all those other muds you follow
« on: November 27, 2012, 02:43:16 AM »
So, I'm sure many of you don't JUST tinker with your own code in isolation, but tend to follow other people's stuff to see what they're doing too.  Many of us use a distribution library as a base, and so want to see what changes so we can (maybe) merge new bugfixes into our stuff.

It's a pain to keep track of where everything is, let alone keep it all up to date.

Sooooo, here's a tiny little perl script which I use.  If anyone has any codebases to add, please feel free to do so!

Code: [Select]
#!/usr/bin/perl -w

use strict;

my $repositories = {
    'dgd'       => {
        'dgd'                   => { 'type' => 'git', 'url' => 'https://github.com/dworkin/dgd' },
        'lpc-doc'               => { 'type' => 'git', 'url' => 'https://github.com/dworkin/lpc-doc.git' },
        'lpc-ext'               => { 'type' => 'git', 'url' => 'https://github.com/dworkin/lpc-ext' },
        'kernellib'             => { 'type' => 'git', 'url' => 'https://github.com/dworkin/kernellib.git' },
        'dgd-httpd'             => { 'type' => 'git', 'url' => 'https://github.com/dworkin/jorinde.git' },
        'gurbalib'              => { 'type' => 'git', 'url' => 'https://github.com/dworkin/gurbalib' },
        'kernellib-shentino'    => { 'type' => 'git', 'url' => 'https://github.com/shentino/kernellib.git' },
        'gurbalib-sirdude'      => { 'type' => 'git', 'url' => 'https://github.com/sirdude/gurbalib.git' },
        'cloud'                 => { 'type' => 'git', 'url' => 'https://github.com/dworkin/cloud-server.git' },
    },
    'fluffos'   => {
        'fluffos'               => { 'type' => 'git', 'url' => 'https://github.com/quixadhal/fluffos.git' },
        'ds'                    => { 'type' => 'git', 'url' => 'https://github.com/quixadhal/deadsouls.git' },
        'lima'                  => { 'type' => 'git', 'url' => 'https://github.com/quixadhal/lima.git' },
    },
    'diku'      => {
        'quix_smaug'            => { 'type' => 'git', 'url' => 'https://github.com/quixadhal/SmaugFUSS.git' },
        'smaug'                 => { 'type' => 'git', 'url' => 'https://github.com/InfiniteAxis/SmaugFUSS.git' },
    },
};

sub fetch_repository {
    my $style = shift or return 0;
    my $repo = shift or return 0;
    my $data = shift or return 0;
    my $type = $data->{'type'} or return 0;
    my $url = $data->{'url'} or return 0;

    mkdir $style if ! -d $style;
    chdir $style;
    if( $type eq 'git' ) {
        if( -d $repo ) {
            chdir $repo;
            print "==> Updating $style/$repo from $url\n";
            system("git pull");
            chdir '..';
        } else {
            print "==> Fetching $style/$repo from $url\n";
            system("git clone $url $repo");
        }
    } elsif( $type eq 'svn' ) {
        if( -d $repo ) {
            chdir $repo;
            print "==> Updating $style/$repo from $url\n";
            system("svn update");
            chdir '..';
        } else {
            print "==> Fetching $style/$repo from $url\n";
            system("svn checkout $url $repo");
        }
    }
    chdir '..';
    print "\n";
    return 1;
}

foreach my $style (keys %$repositories) {
    foreach my $repo (keys %{ $repositories->{$style} }) {
        fetch_repository($style, $repo, $repositories->{$style}->{$repo});
    }
}

NOTE: the subversion code is untested because I don't know of anyone who still uses it. :)