aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/install/dependency.zig25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/install/dependency.zig b/src/install/dependency.zig
index 9c7bcf479..01c1ecd86 100644
--- a/src/install/dependency.zig
+++ b/src/install/dependency.zig
@@ -221,6 +221,26 @@ pub inline fn isGitHubRepoPath(dependency: string) bool {
return hash_index != dependency.len - 1 and first_slash_index > 0 and first_slash_index != dependency.len - 1;
}
+// Github allows for the following format of URL:
+// https://github.com/<org>/<repo>/tarball/<ref>
+// This is a legacy (but still supported) method of retrieving a tarball of an
+// entire source tree at some git reference. (ref = branch, tag, etc. Note: branch
+// can have arbitrary number of slashes)
+pub inline fn isGitHubTarballPath(dependency: string) bool {
+ var parts = strings.split(dependency, "/");
+
+ var n_parts: usize = 0;
+
+ while (parts.next()) |part| {
+ n_parts += 1;
+ if (n_parts == 3) {
+ return strings.eql(part, "tarball");
+ }
+ }
+
+ return false;
+}
+
// This won't work for query string params, but I'll let someone file an issue
// before I add that.
pub inline fn isTarball(dependency: string) bool {
@@ -494,8 +514,11 @@ pub const Version = struct {
else => {},
}
if (strings.hasPrefixComptime(url, "github.com/")) {
- if (isGitHubRepoPath(url["github.com/".len..])) return .github;
+ const path = url["github.com/".len..];
+ if (isGitHubTarballPath(path)) return .tarball;
+ if (isGitHubRepoPath(path)) return .github;
}
+ return .tarball;
}
}
},