From 1ea957198f60f99c7a271ebf8c9026d520c8ceaf Mon Sep 17 00:00:00 2001 From: Anton Tetov Date: Sun, 2 Mar 2025 20:35:02 +0100 Subject: [PATCH 1/3] fetchFromBitbucket: add test, repro need for url escape Looking into #29733 --- pkgs/build-support/fetchbitbucket/default.nix | 1 + pkgs/build-support/fetchbitbucket/tests.nix | 18 ++++++++++++++++++ pkgs/test/default.nix | 1 + pkgs/top-level/all-packages.nix | 4 +++- 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 pkgs/build-support/fetchbitbucket/tests.nix diff --git a/pkgs/build-support/fetchbitbucket/default.nix b/pkgs/build-support/fetchbitbucket/default.nix index 9e64954bebff..17c4020719cf 100644 --- a/pkgs/build-support/fetchbitbucket/default.nix +++ b/pkgs/build-support/fetchbitbucket/default.nix @@ -12,6 +12,7 @@ lib.makeOverridable ( { inherit name; url = "https://bitbucket.org/${owner}/${repo}/get/${rev}.tar.gz"; + # url = "https://bitbucket.org/${owner}/${repo}/get/${lib.strings.escapeURL rev}.tar.gz"; meta.homepage = "https://bitbucket.org/${owner}/${repo}/"; } // removeAttrs args [ diff --git a/pkgs/build-support/fetchbitbucket/tests.nix b/pkgs/build-support/fetchbitbucket/tests.nix new file mode 100644 index 000000000000..4e9b97b7e709 --- /dev/null +++ b/pkgs/build-support/fetchbitbucket/tests.nix @@ -0,0 +1,18 @@ +{ testers, fetchFromBitbucket, ... }: +{ + withEncodedWhitespace = testers.invalidateFetcherByDrvHash fetchFromBitbucket { + name = "withWhitespace"; + owner = "tetov"; + repo = "fetchbitbucket_tester"; + rev = "tag%20with%20encoded%20spaces"; + sha256 = "sha256-Nf1Cvbx7Sbab8EeSSBU5baLBiuFYiQtITED+f4tfjC0="; + }; + + withoutWhitespace = testers.invalidateFetcherByDrvHash fetchFromBitbucket { + name = "withoutWhitespace"; + owner = "tetov"; + repo = "fetchbitbucket_tester"; + rev = "main"; + sha256 = "sha256-eTd773gE1z4+Fl2YPBbbsrADD4Dr7sFGoOWgphXUhtE="; + }; +} diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 7804ea23b06e..ece627b900e6 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -129,6 +129,7 @@ with pkgs; fetchDebianPatch = recurseIntoAttrs (callPackages ../build-support/fetchdebianpatch/tests.nix { }); fetchzip = recurseIntoAttrs (callPackages ../build-support/fetchzip/tests.nix { }); fetchgit = recurseIntoAttrs (callPackages ../build-support/fetchgit/tests.nix { }); + fetchFromBitbucket = recurseIntoAttrs (callPackages ../build-support/fetchbitbucket/tests.nix { }); fetchFirefoxAddon = recurseIntoAttrs ( callPackages ../build-support/fetchfirefoxaddon/tests.nix { } ); diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 330e39efac2c..31d3df739075 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -701,7 +701,9 @@ with pkgs; fetchFromGitHub = callPackage ../build-support/fetchgithub { }; - fetchFromBitbucket = callPackage ../build-support/fetchbitbucket { }; + fetchFromBitbucket = callPackage ../build-support/fetchbitbucket { } // { + tests = pkgs.tests.fetchFromBitbucket; + }; fetchFromSavannah = callPackage ../build-support/fetchsavannah { }; From 81e797802040ede04319ae7ef3845b8a1bf97177 Mon Sep 17 00:00:00 2001 From: Anton Tetov Date: Sun, 2 Mar 2025 21:28:24 +0100 Subject: [PATCH 2/3] fetchFromBitbucket: url escape rev attr To make sure revision with spaces in them (most likely from repos that were used with mercurial) as well as revisions with names containing url encoded characters ("branch%20with%20encoded%spaces"). --- pkgs/build-support/fetchbitbucket/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/build-support/fetchbitbucket/default.nix b/pkgs/build-support/fetchbitbucket/default.nix index 17c4020719cf..80c47f13c8c2 100644 --- a/pkgs/build-support/fetchbitbucket/default.nix +++ b/pkgs/build-support/fetchbitbucket/default.nix @@ -11,8 +11,7 @@ lib.makeOverridable ( fetchzip ( { inherit name; - url = "https://bitbucket.org/${owner}/${repo}/get/${rev}.tar.gz"; - # url = "https://bitbucket.org/${owner}/${repo}/get/${lib.strings.escapeURL rev}.tar.gz"; + url = "https://bitbucket.org/${owner}/${repo}/get/${lib.strings.escapeURL rev}.tar.gz"; meta.homepage = "https://bitbucket.org/${owner}/${repo}/"; } // removeAttrs args [ From c9767c2b52c3bf27f82d9749bd9da71cb9db8be4 Mon Sep 17 00:00:00 2001 From: Anton Tetov Date: Wed, 6 Aug 2025 15:26:38 +0200 Subject: [PATCH 3/3] fetchFromBitbucket: fix callPackage call Co-authored-by: Philip Taron --- pkgs/top-level/all-packages.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 31d3df739075..330e39efac2c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -701,9 +701,7 @@ with pkgs; fetchFromGitHub = callPackage ../build-support/fetchgithub { }; - fetchFromBitbucket = callPackage ../build-support/fetchbitbucket { } // { - tests = pkgs.tests.fetchFromBitbucket; - }; + fetchFromBitbucket = callPackage ../build-support/fetchbitbucket { }; fetchFromSavannah = callPackage ../build-support/fetchsavannah { };