aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers/github.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2022-03-25 19:25:08 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-03-25 19:25:08 +0000
commit0dc2974930df57cac6673c02e9bc6eb6fd16ba48 (patch)
treec10e6db3dec20bffa8a27b5ce89852bb8f5ea43c /src/libfetchers/github.cc
parent8ba089597fa19bfd49ba5f22a5e821740ca4eb5d (diff)
parent1844172dd16cab611a0148be9381ab856bf241df (diff)
Merge remote-tracking branch 'upstream/master' into path-info
Diffstat (limited to 'src/libfetchers/github.cc')
-rw-r--r--src/libfetchers/github.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc
index a1430f087..58b6e7c04 100644
--- a/src/libfetchers/github.cc
+++ b/src/libfetchers/github.cc
@@ -390,7 +390,7 @@ struct SourceHutInputScheme : GitArchiveInputScheme
ref_uri = line.substr(ref_index+5, line.length()-1);
} else
- ref_uri = fmt("refs/heads/%s", ref);
+ ref_uri = fmt("refs/(heads|tags)/%s", ref);
auto file = store->toRealPath(
downloadFile(store, fmt("%s/info/refs", base_url), "source", false, headers).storePath);
@@ -399,9 +399,11 @@ struct SourceHutInputScheme : GitArchiveInputScheme
std::string line;
std::string id;
while(getline(is, line)) {
- auto index = line.find(ref_uri);
- if (index != std::string::npos) {
- id = line.substr(0, index-1);
+ // Append $ to avoid partial name matches
+ std::regex pattern(fmt("%s$", ref_uri));
+
+ if (std::regex_search(line, pattern)) {
+ id = line.substr(0, line.find('\t'));
break;
}
}