Fix applyOverride() for github

This commit is contained in:
Eelco Dolstra 2020-06-09 13:45:07 +02:00
parent 1205b41849
commit 6cfc2db494
3 changed files with 7 additions and 4 deletions

View file

@ -91,6 +91,7 @@ bool Input::operator ==(const Input & other) const
bool Input::contains(const Input & other) const bool Input::contains(const Input & other) const
{ {
if (*this == other) return true;
auto other2(other); auto other2(other);
other2.attrs.erase("ref"); other2.attrs.erase("ref");
other2.attrs.erase("rev"); other2.attrs.erase("rev");

View file

@ -59,7 +59,7 @@ struct GitArchiveInputScheme : InputScheme
} }
if (ref && rev) if (ref && rev)
throw BadURL("URL '%s' contains both a commit hash and a branch/tag name", url.url); throw BadURL("URL '%s' contains both a commit hash and a branch/tag name %s %s", url.url, *ref, rev->gitRev());
Input input; Input input;
input.attrs.insert_or_assign("type", type()); input.attrs.insert_or_assign("type", type());
@ -115,14 +115,16 @@ struct GitArchiveInputScheme : InputScheme
std::optional<Hash> rev) override std::optional<Hash> rev) override
{ {
auto input(_input); auto input(_input);
if (rev && ref)
throw BadURL("cannot apply both a commit hash (%s) and a branch/tag name ('%s') to input '%s'",
rev->gitRev(), *ref, input.to_string());
if (rev) { if (rev) {
input.attrs.insert_or_assign("rev", rev->gitRev()); input.attrs.insert_or_assign("rev", rev->gitRev());
input.attrs.erase("ref"); input.attrs.erase("ref");
} }
if (ref) { if (ref) {
if (input.getRev())
throw BadURL("input '%s' contains both a commit hash and a branch/tag name", input.to_string());
input.attrs.insert_or_assign("ref", *ref); input.attrs.insert_or_assign("ref", *ref);
input.attrs.erase("rev");
} }
return input; return input;
} }