GitInput.pm: Don't do a chdir to the Git clone
[?]
Aug 12, 2013, 3:25 PM
3BTJRSU3VWCTVRL7Y2SARN2BZMECUIIVFAJPCPBRIRYCGLXHCBJQCDependencies
- [2]
NB2VOKIRInclude names of committers in HipChat notifications - [3]
BDSD2JLV* Speed up manifest generation. - [4]
JAH3UPWASupport revision control systems via plugins - [5]
6ZB4CIW6Security: Improve checking of build products - [*]
2GK5DOU7* Downloading closures. - [*]
AFTXA575* $HYDRA_DATA environment variable.
Change contents
- replacement in src/lib/Hydra/Helper/Nix.pm at line 23
captureStdoutStderr);captureStdoutStderr run grab); - edit in src/lib/Hydra/Helper/Nix.pm at line 471
}}sub run {my (%args) = @_;my $res = { stdout => "", stderr => "" };my $stdin = "";eval {local $SIG{ALRM} = sub { die "timeout\n" }; # NB: \n requiredalarm $args{timeout} if defined $args{timeout};my @x = ($args{cmd}, \$stdin, \$res->{stdout});push @x, \$res->{stderr} if $args{grabStderr} // 1;IPC::Run::run(@x,init => sub { chdir $args{dir} or die "changing to $args{dir}" if defined $args{dir}; });alarm 0;};if ($@) {die unless $@ eq "timeout\n"; # propagate unexpected errors$res->{status} = -1;$res->{stderr} = "timeout\n";} else {$res->{status} = $?;chomp $res->{stdout} if $args{chomp} // 0; - edit in src/lib/Hydra/Helper/Nix.pm at line 498
return $res; - edit in src/lib/Hydra/Helper/Nix.pm at line 503[3.2133][8.850]
sub grab {my (%args) = @_;my $res = run(%args, grabStderr => 0);die "command `@{$args{cmd}}' failed with exit status $res->{status}" if $res->{status};return $res->{stdout};} - replacement in src/lib/Hydra/Plugin/GitInput.pm at line 23
my $stdout = ""; my $stderr = ""; my $res;my $res; - replacement in src/lib/Hydra/Plugin/GitInput.pm at line 27
($res, $stdout, $stderr) = captureStdoutStderr(600, "git", "clone", "--branch", $branch, $uri, $clonePath);die "error cloning git repo at `$uri':\n$stderr" if $res;$res = run(cmd => ["git", "clone", "--branch", $branch, $uri, $clonePath], timeout => 600);die "error cloning git repo at `$uri':\n$res->{stderr}" if $res->{status}; - edit in src/lib/Hydra/Plugin/GitInput.pm at line 30
chdir $clonePath or die $!; # !!! urgh, shouldn't do a chdir - replacement in src/lib/Hydra/Plugin/GitInput.pm at line 34
($res, $stdout, $stderr) = captureStdoutStderr(600,"git", "fetch", "-fu", "origin", "+$branch:$branch");($res, $stdout, $stderr) = captureStdoutStderr(600,"git", "fetch", "-fu", "origin") if $res;die "error fetching latest change from git repo at `$uri':\n$stderr" if $res;$res = run(cmd => ["git", "fetch", "-fu", "origin", "+$branch:$branch"], dir => $clonePath, timeout => 600);$res = run(cmd => ["git", "fetch", "-fu", "origin"], dir => $clonePath, timeout => 600) if $res->{status};die "error fetching latest change from git repo at `$uri':\n$res->{stderr}" if $res->{status}; - replacement in src/lib/Hydra/Plugin/GitInput.pm at line 43
($res, $stdout, $stderr) = captureStdoutStderr(600, "git", "checkout", "$branch");die "error checking out Git branch '$branch' at `$uri':\n$stderr" if $res;$res = run(cmd => ["git", "checkout", "$branch"], dir => $clonePath);die "error checking out Git branch '$branch' at `$uri':\n$res->{stderr}" if $res->{status}; - replacement in src/lib/Hydra/Plugin/GitInput.pm at line 49
($res, $stdout, $stderr) = captureStdoutStderr(600,"tg", "remote", "--populate", "origin");print STDERR "warning: `tg remote --populate origin' failed:\n$stderr" if $res;$res = run(cmd => ["tg", "remote", "--populate", "origin"], dir => $clonePath, timeout => 600);print STDERR "warning: `tg remote --populate origin' failed:\n$res->{stderr}" if $res->{status}; - edit in src/lib/Hydra/Plugin/GitInput.pm at line 62
- edit in src/lib/Hydra/Plugin/GitInput.pm at line 76
my ($res, $stdout, $stderr) = captureStdoutStderr(600,("git", "rev-parse", "$branch"));die "error getting revision number of Git branch '$branch' at `$uri':\n$stderr" if $res; - replacement in src/lib/Hydra/Plugin/GitInput.pm at line 77
my ($revision) = split /\n/, $stdout;die "error getting a well-formated revision number of Git branch '$branch' at `$uri':\n$stdout"my $revision = grab(cmd => ["git", "rev-parse", "$branch"], dir => $clonePath, chomp => 1);die "did not get a well-formated revision number of Git branch '$branch' at `$uri'" - edit in src/lib/Hydra/Plugin/GitInput.pm at line 80
my $ref = "refs/heads/$branch"; - replacement in src/lib/Hydra/Plugin/GitInput.pm at line 83
my $cachedInput ;my $cachedInput; - replacement in src/lib/Hydra/Plugin/GitInput.pm at line 114
($res, $stdout, $stderr) = captureStdoutStderr(600, "nix-prefetch-git", $clonePath, $revision);die "cannot check out Git repository branch '$branch' at `$uri':\n$stderr" if $res;($sha256, $storePath) = split ' ', $stdout;($sha256, $storePath) = split ' ', grab(cmd => ["nix-prefetch-git", $clonePath, $revision], chomp => 1); - replacement in src/lib/Hydra/Plugin/GitInput.pm at line 131
my $revCount = `git rev-list $revision | wc -l`; chomp $revCount;die "git rev-list failed" if $? != 0;my $gitTag = `git describe --always $revision`; chomp $gitTag;die "git describe failed" if $? != 0;my $shortRev = `git rev-parse --short $revision`; chomp $shortRev;die "git rev-parse failed" if $? != 0;my $revCount = scalar(split '\n', grab(cmd => ["git", "rev-list", "$revision"], dir => $clonePath));my $gitTag = grab(cmd => ["git", "describe", "--always", "$revision"], dir => $clonePath, chomp => 1);my $shortRev = grab(cmd => ["git", "rev-parse", "--short", "$revision"], dir => $clonePath, chomp => 1); - replacement in src/lib/Hydra/Plugin/GitInput.pm at line 157
my $out;IPC::Run::run(["git", "log", "--pretty=format:%H%x09%an%x09%ae%x09%at", "$rev1..$rev2"], \undef, \$out)or die "cannot get git logs: $?";my $out = grab(cmd => ["git", "log", "--pretty=format:%H%x09%an%x09%ae%x09%at", "$rev1..$rev2"], dir => $clonePath);