https://github.com/genome/genome
Tip revision: b84fdb29e5179b380486ed50d89e412a923bfb80 authored by Eddie Belter on 24 October 2012, 16:30:16 UTC
Solexa: update gettign default results
Solexa: update gettign default results
Tip revision: b84fdb2
update-submodules
#!/usr/bin/env genome-perl
use strict;
use warnings;
use LWP::UserAgent;
my %project = (
'workflow' => 'Workflow_Tests',
'ur' => 'UR_Tests',
'jenkins' => 'Jenkins_Tests',
'graphite' => 'Graphite_Tests',
'getopt-complete' => 'Getopt_Complete_Tests',
);
for my $submodule (keys %project) {
my $project = $project{$submodule};
my $current_submodule_revision = current_submodule_revision($submodule);
unless ($current_submodule_revision) {
die "Unable to determine current_submodule_revision for $submodule";
}
my $last_stable_revision = last_stable_revision($project);
unless ($last_stable_revision) {
die "Unable to determine last_stable_revision for $project";
}
if ($current_submodule_revision ne $last_stable_revision) {
update_submodule($submodule, $last_stable_revision);
print "$submodule: updated to $last_stable_revision\n";
} else {
print "$submodule: current submodule revision matches last stable revision\n";
}
}
unless (system("git fetch") == 0) {
die "Failed to fetch";
}
unless (system("git rebase origin/master") == 0) {
die "Failed to rebase on origin/master";
}
my @log = qx(git log -p origin/master..HEAD);
if (@log) {
print @log;
unless (system("git push origin master") == 0) {
die "Failed to push changes";
}
} else {
print "No changes to push.\n";
}
sub update_submodule {
my $submodule = shift || die;
my $revision = shift || die;
my $short_revision = (length($revision) > 7 ? substr($revision, 0, 7) : $revision);
unless (system("git submodule update --init $submodule && cd $submodule && git fetch && git checkout -f $revision") == 0) {
die "Failed to checkout $submodule to $revision";
}
unless (system("git commit $submodule -m 'updated $submodule submodule to $short_revision'") == 0) {
die "Failed to commit $submodule update to $revision";
}
}
sub last_stable_revision {
my $project = shift || die;
my $url_f = 'https://apipe-ci.gsc.wustl.edu/view/Genome%%20Submodules/job/%s/lastStableBuild/api/xml?xpath=/freeStyleBuild/action/lastBuiltRevision/SHA1';
my $url = sprintf($url_f, $project);
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
$ua->agent("UpdateSubmodules/1.0");
my $req = HTTP::Request->new(GET => $url);
my $res = $ua->request($req);
if ($res->is_success) {
my ($sha1) = $res->content =~ />(.*)</;
return $sha1;
} else {
print STDERR $res->status_line . "\n";
return;
}
}
sub current_submodule_revision {
my $submodule = shift || die;
my $cmd = "git ls-tree HEAD $submodule";
# official: <mode> SP <type> SP <object> TAB <file>
my ($mode, $type, $object, $file) = qx($cmd) =~ /^(\S+) (\S+) (\S+)\t(.*)$/;
my $exit_code = $?;
if ($exit_code == 0) {
return $object;
} else {
return;
}
}