diff options
author | 2023-01-11 14:26:50 -0800 | |
---|---|---|
committer | 2023-01-11 14:26:50 -0800 | |
commit | beb03c3c54c1fec4cdbec5440e0ab595351317f6 (patch) | |
tree | 536a1f8d1c451c3116814dd40dbf6f47a0a48a59 | |
parent | 8846ae2454775d9c9d0f8c541289147ffff96086 (diff) | |
download | bun-beb03c3c54c1fec4cdbec5440e0ab595351317f6.tar.gz bun-beb03c3c54c1fec4cdbec5440e0ab595351317f6.tar.zst bun-beb03c3c54c1fec4cdbec5440e0ab595351317f6.zip |
handle github prefix
-rw-r--r-- | src/install/install.zig | 6 | ||||
-rw-r--r-- | src/install/repository.zig | 14 |
2 files changed, 9 insertions, 11 deletions
diff --git a/src/install/install.zig b/src/install/install.zig index 2ae68e93b..c4248aca7 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -552,9 +552,6 @@ const Task = struct { const git_repo = this.request.git_clone.repository; - var owner = lockfile.str(git_repo.owner); - owner = if (strings.hasPrefixComptime(owner, "github:")) owner["github:".len..] else owner; - const repo_name = lockfile.str(git_repo.repo); var url_buf: [bun.MAX_PATH_BYTES]u8 = undefined; @@ -2501,8 +2498,7 @@ pub const PackageManager = struct { .git => { var cache_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined; - // TODO: need to remove "https://github.com/" prefix - const cache_path = try version.value.github.getCachePath(this, &cache_path_buf); + const cache_path = try version.value.git.getCachePath(this, &cache_path_buf); const res = FolderResolution.getOrPut(.{ .git_cache_folder = cache_path }, version, cache_path, this); diff --git a/src/install/repository.zig b/src/install/repository.zig index 875aec085..264efe43e 100644 --- a/src/install/repository.zig +++ b/src/install/repository.zig @@ -162,13 +162,15 @@ pub const Repository = extern struct { pub fn parseGitHub(input: *const SlicedString) !Repository { var repo = Repository{}; - if (strings.indexOfChar(input.slice, '/')) |i| { - repo.owner = String.init(input.buf, input.slice[0..i]); - if (strings.indexOfChar(input.slice[i + 1 ..], '#')) |j| { - repo.repo = String.init(input.buf, input.slice[i + 1 .. j]); - repo.committish = String.init(input.buf, input.slice[j + 1 ..]); + // ignore "github:" + const i: usize = if (strings.indexOfChar(input.slice, ':')) |j| j + 1 else 0; + if (strings.indexOfChar(input.slice, '/')) |j| { + repo.owner = String.init(input.buf, input.slice[i..j]); + if (strings.indexOfChar(input.slice[j + 1 ..], '#')) |k| { + repo.repo = String.init(input.buf, input.slice[j + 1 .. k]); + repo.committish = String.init(input.buf, input.slice[k + 1 ..]); } else { - repo.repo = String.init(input.buf, input.slice[i + 1 ..]); + repo.repo = String.init(input.buf, input.slice[j + 1 ..]); } } return repo; |