forked from lix-project/hydra
Pass additional attributes for Git inputs
The ‘revCount’ attribute is the number of commits in the history of the revision. This is useful if you need a monotonically increasing version number. The ‘gitTag’ attribute is the output of ‘git describe’, e.g. ‘v1.0.4-14-g2414721’ to indicate that the current revision is 14 commits after the tag ‘v1.0.4’.
This commit is contained in:
parent
9032c55aa6
commit
e9c88783ce
|
@ -400,11 +400,21 @@ sub fetchInputGit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# For convenience in producing readable version names, pass the
|
||||||
|
# number of commits in the history of this revision (‘revCount‘)
|
||||||
|
# and the output of git-describe (‘gitTag’).
|
||||||
|
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;
|
||||||
|
|
||||||
return
|
return
|
||||||
{ uri => $uri
|
{ uri => $uri
|
||||||
, storePath => $storePath
|
, storePath => $storePath
|
||||||
, sha256hash => $sha256
|
, sha256hash => $sha256
|
||||||
, revision => $revision
|
, revision => $revision
|
||||||
|
, revCount => int($revCount)
|
||||||
|
, gitTag => $gitTag
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,6 +629,8 @@ sub inputsToArgs {
|
||||||
push @res, "--arg", $input, (
|
push @res, "--arg", $input, (
|
||||||
"{ outPath = builtins.storePath " . $alt->{storePath} . "" .
|
"{ outPath = builtins.storePath " . $alt->{storePath} . "" .
|
||||||
(defined $alt->{revision} ? "; rev = \"" . $alt->{revision} . "\"" : "") .
|
(defined $alt->{revision} ? "; rev = \"" . $alt->{revision} . "\"" : "") .
|
||||||
|
(defined $alt->{revCount} ? "; revCount = " . $alt->{revCount} . "" : "") .
|
||||||
|
(defined $alt->{gitTag} ? "; gitTag = \"" . $alt->{gitTag} . "\"" : "") .
|
||||||
(defined $alt->{version} ? "; version = \"" . $alt->{version} . "\"" : "") .
|
(defined $alt->{version} ? "; version = \"" . $alt->{version} . "\"" : "") .
|
||||||
";}"
|
";}"
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue