Skip to content

Commit

Permalink
Add support for .tbz file extension in repository_ctx.download_and_ex…
Browse files Browse the repository at this point in the history
…tract

The `download_and_extract` function supported `.tar.bz2` files, but did
not recognize `.tbz` as a valid file extension for those. This commit
simply adds support for this, in the code, in the test and in the doc.
  • Loading branch information
benji-sb committed Mar 27, 2023
1 parent 952438d commit ba3d741
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ static Decompressor getDecompressor(Path archivePath) throws RepositoryFunctionE
return TarXzFunction.INSTANCE;
} else if (baseName.endsWith(".tar.zst") || baseName.endsWith(".tzst")) {
return TarZstFunction.INSTANCE;
} else if (baseName.endsWith(".tar.bz2")) {
} else if (baseName.endsWith(".tar.bz2") || baseName.endsWith(".tbz")) {
return TarBz2Function.INSTANCE;
} else if (baseName.endsWith(".ar") || baseName.endsWith(".deb")) {
return ArFunction.INSTANCE;
} else {
throw new RepositoryFunctionException(
Starlark.errorf(
"Expected a file with a .zip, .jar, .war, .aar, .tar, .tar.gz, .tgz, .tar.xz, .txz,"
+ " .tar.zst, .tzst, .tar.bz2, .ar or .deb suffix (got %s)",
+ " .tar.zst, .tzst, .tar.bz2, .tbz, .ar or .deb suffix (got %s)",
archivePath),
Transience.PERSISTENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ public StructImpl download(
+ " the URL."
+ " If the file has no extension, you can explicitly specify either \"zip\","
+ " \"jar\", \"war\", \"aar\", \"tar\", \"tar.gz\", \"tgz\", \"tar.xz\","
+ " \"txz\", \".tar.zst\", \".tzst\", \"tar.bz2\", \".ar\", or \".deb\""
+ " \"txz\", \".tar.zst\", \".tzst\", \"tar.bz2\", \".tbz\", \".ar\", or \".deb\""
+ " here."),
@Param(
name = "stripPrefix",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public void testKnownFileExtensionsDoNotThrow() throws Exception {
unused = DecompressorValue.getDecompressor(path);
path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.tar.bz2");
unused = DecompressorValue.getDecompressor(path);
path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.tbz");
unused = DecompressorValue.getDecompressor(path);
path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.ar");
unused = DecompressorValue.getDecompressor(path);
path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.deb");
Expand Down

0 comments on commit ba3d741

Please sign in to comment.