]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Fix cache versioning when BLACK_CACHE_DIR is set (#3937)
authorShantanu <12621235+hauntsaninja@users.noreply.github.com>
Tue, 10 Oct 2023 01:44:36 +0000 (18:44 -0700)
committerGitHub <noreply@github.com>
Tue, 10 Oct 2023 01:44:36 +0000 (18:44 -0700)
CHANGES.md
src/black/cache.py
tests/test_black.py

index ffc63b3287dfd2cbf3c4cffbab0bbfdb0ba7be62..fe4b621a3e5781386b1d4841ae3e38d6e5f1db94 100644 (file)
@@ -24,6 +24,8 @@
 
 <!-- Changes to how Black can be configured -->
 
 
 <!-- Changes to how Black can be configured -->
 
+- Fix cache versioning logic when `BLACK_CACHE_DIR` is set (#3937)
+
 ### Packaging
 
 <!-- Changes to how Black is packaged, such as dependency requirements -->
 ### Packaging
 
 <!-- Changes to how Black is packaged, such as dependency requirements -->
index 77f66cc34a9132dff8fc0a898d1c3246fa00d4c4..f7dc64c0bca925e8969f4d97daed47040f98790a 100644 (file)
@@ -36,8 +36,9 @@ def get_cache_dir() -> Path:
     repeated calls.
     """
     # NOTE: Function mostly exists as a clean way to test getting the cache directory.
     repeated calls.
     """
     # NOTE: Function mostly exists as a clean way to test getting the cache directory.
-    default_cache_dir = user_cache_dir("black", version=__version__)
+    default_cache_dir = user_cache_dir("black")
     cache_dir = Path(os.environ.get("BLACK_CACHE_DIR", default_cache_dir))
     cache_dir = Path(os.environ.get("BLACK_CACHE_DIR", default_cache_dir))
+    cache_dir = cache_dir / __version__
     return cache_dir
 
 
     return cache_dir
 
 
index bb5cc1e08c75a3ddb677f920931ce0f93351a88a..537ca80d4320cdc5dfef82ee0b88f515083139a0 100644 (file)
@@ -1963,11 +1963,11 @@ class TestCaching:
         # If BLACK_CACHE_DIR is not set, use user_cache_dir
         monkeypatch.delenv("BLACK_CACHE_DIR", raising=False)
         with patch_user_cache_dir:
         # If BLACK_CACHE_DIR is not set, use user_cache_dir
         monkeypatch.delenv("BLACK_CACHE_DIR", raising=False)
         with patch_user_cache_dir:
-            assert get_cache_dir() == workspace1
+            assert get_cache_dir().parent == workspace1
 
         # If it is set, use the path provided in the env var.
         monkeypatch.setenv("BLACK_CACHE_DIR", str(workspace2))
 
         # If it is set, use the path provided in the env var.
         monkeypatch.setenv("BLACK_CACHE_DIR", str(workspace2))
-        assert get_cache_dir() == workspace2
+        assert get_cache_dir().parent == workspace2
 
     def test_cache_broken_file(self) -> None:
         mode = DEFAULT_MODE
 
     def test_cache_broken_file(self) -> None:
         mode = DEFAULT_MODE