mirror of
https://github.com/NixOS/nix
synced 2025-06-27 12:41:15 +02:00
Fix the parsing of the sourcehut refs file
Since a26be9f3b8
, the same parser is used
to parse the result of sourcehut’s `HEAD` endpoint (coming from [git
dumb protocol]) and the output of `git ls-remote`. However, they are very
slightly different (the former doesn’t specify the current reference
since it’s implied to be `HEAD`).
Unify both, and make the parser a bit more robust and understandable (by
making it more typed and adding tests for it)
[git dumb protocol]: https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols#_the_dumb_protocol
This commit is contained in:
parent
470e27ce80
commit
e68676e6c8
7 changed files with 116 additions and 63 deletions
|
@ -4,7 +4,7 @@
|
|||
#include "store-api.hh"
|
||||
#include "types.hh"
|
||||
#include "url-parts.hh"
|
||||
#include "git-utils.hh"
|
||||
#include "git.hh"
|
||||
#include "fetchers.hh"
|
||||
#include "fetch-settings.hh"
|
||||
|
||||
|
@ -383,11 +383,11 @@ struct SourceHutInputScheme : GitArchiveInputScheme
|
|||
std::string line;
|
||||
getline(is, line);
|
||||
|
||||
auto r = parseListReferenceHeadRef(line);
|
||||
if (!r) {
|
||||
auto remoteLine = git::parseLsRemoteLine(line);
|
||||
if (!remoteLine) {
|
||||
throw BadURL("in '%d', couldn't resolve HEAD ref '%d'", input.to_string(), ref);
|
||||
}
|
||||
ref_uri = *r;
|
||||
ref_uri = remoteLine->target;
|
||||
} else {
|
||||
ref_uri = fmt("refs/(heads|tags)/%s", ref);
|
||||
}
|
||||
|
@ -399,7 +399,9 @@ struct SourceHutInputScheme : GitArchiveInputScheme
|
|||
std::string line;
|
||||
std::optional<std::string> id;
|
||||
while(!id && getline(is, line)) {
|
||||
id = parseListReferenceForRev(ref_uri, line);
|
||||
auto parsedLine = git::parseLsRemoteLine(line);
|
||||
if (parsedLine && parsedLine->reference == ref_uri)
|
||||
id = parsedLine->target;
|
||||
}
|
||||
|
||||
if(!id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue