* hydra: indentation and fixed duplicate key in cachedgitinputs bug

This commit is contained in:
Rob Vermaas 2010-02-24 08:09:58 +00:00
parent 63acc9fb1c
commit a1c7e359be

View file

@ -288,56 +288,56 @@ sub fetchInputGit {
} }
if (defined $cachedInput && isValidPath($cachedInput->storepath)) { if (defined $cachedInput && isValidPath($cachedInput->storepath)) {
$storePath = $cachedInput->storepath; $storePath = $cachedInput->storepath;
$sha256 = $cachedInput->sha256hash; $sha256 = $cachedInput->sha256hash;
$timestamp = $cachedInput->timestamp; $timestamp = $cachedInput->timestamp;
$revision = $cachedInput->revision; $revision = $cachedInput->revision;
} else { } else {
# Then download this revision into the store. # Then download this revision into the store.
print STDERR "checking out Git input from $uri"; print STDERR "checking out Git input from $uri";
$ENV{"NIX_HASH_ALGO"} = "sha256"; $ENV{"NIX_HASH_ALGO"} = "sha256";
$ENV{"PRINT_PATH"} = "1"; $ENV{"PRINT_PATH"} = "1";
# Checked out code often wants to be able to run `git # Checked out code often wants to be able to run `git
# describe', e.g., code that uses Gnulib's `git-version-gen' # describe', e.g., code that uses Gnulib's `git-version-gen'
# script. Thus, we leave `.git' in there. Same for # script. Thus, we leave `.git' in there. Same for
# Subversion (e.g., libgcrypt's build system uses that.) # Subversion (e.g., libgcrypt's build system uses that.)
$ENV{"NIX_PREFETCH_GIT_LEAVE_DOT_GIT"} = "1"; $ENV{"NIX_PREFETCH_GIT_LEAVE_DOT_GIT"} = "1";
$ENV{"NIX_PREFETCH_SVN_LEAVE_DOT_SVN"} = "1"; $ENV{"NIX_PREFETCH_SVN_LEAVE_DOT_SVN"} = "1";
# Ask for a "deep clone" to allow "git describe" and similar # Ask for a "deep clone" to allow "git describe" and similar
# tools to work. See # tools to work. See
# http://thread.gmane.org/gmane.linux.distributions.nixos/3569 # http://thread.gmane.org/gmane.linux.distributions.nixos/3569
# for a discussion. # for a discussion.
$ENV{"NIX_PREFETCH_GIT_DEEP_CLONE"} = "1"; $ENV{"NIX_PREFETCH_GIT_DEEP_CLONE"} = "1";
(my $res, $stdout, $stderr) = captureStdoutStderr( (my $res, $stdout, $stderr) = captureStdoutStderr(
"nix-prefetch-git", $uri, $revision); "nix-prefetch-git", $uri, $revision);
die "Cannot check out Git repository branch '$branch' at `$uri':\n$stderr" unless $res; die "Cannot check out Git repository branch '$branch' at `$uri':\n$stderr" unless $res;
($sha256, $storePath) = split ' ', $stdout; ($sha256, $storePath) = split ' ', $stdout;
($cachedInput) = $db->resultset('CachedGitInputs')->search( ($cachedInput) = $db->resultset('CachedGitInputs')->search(
{uri => $uri, branch => $branch, sha256hash => $sha256}); {uri => $uri, branch => $branch, sha256hash => $sha256});
if (!defined $cachedInput) { if (!defined $cachedInput) {
txn_do($db, sub { txn_do($db, sub {
$db->resultset('CachedGitInputs')->create( $db->resultset('CachedGitInputs')->update_or_create(
{ uri => $uri { uri => $uri
, branch => $branch , branch => $branch
, revision => $revision , revision => $revision
, timestamp => $timestamp , timestamp => $timestamp
, lastseen => $timestamp , lastseen => $timestamp
, sha256hash => $sha256 , sha256hash => $sha256
, storepath => $storePath , storepath => $storePath
}); });
}); });
} else { } else {
$timestamp = $cachedInput->timestamp; $timestamp = $cachedInput->timestamp;
txn_do($db, sub { txn_do($db, sub {
$cachedInput->update({lastseen => time}); $cachedInput->update({lastseen => time});
}); });
} }
} }
return return