Ver Fonte

Deprecate Commit.extra.

Jelmer Vernooij há 2 anos atrás
pai
commit
1f3a66994f
2 ficheiros alterados com 13 adições e 0 exclusões
  1. 9 0
      NEWS
  2. 4 0
      dulwich/objects.py

+ 9 - 0
NEWS

@@ -3,6 +3,15 @@
  * Add support for ``worktreeconfig`` extension.
    (Jelmer Vernooij)
 
+ * Deprecate ``Commit.extra``; the Git project specifically
+   discourages adding custom lines, and the contents of
+   ``Commit.extra`` are unpredictable as contents
+   may be different between different versions of Dulwich
+   with support for different headers.
+
+   ``Commit._extra`` still exists.
+   (Jelmer Vernooij)
+
 0.21.2	2023-01-18
 
  * Fix early file close bug in ``dulwich.pack.extend_pack``.

+ 4 - 0
dulwich/objects.py

@@ -36,6 +36,7 @@ from typing import (
     Iterator,
     List,
 )
+import warnings
 import zlib
 from _hashlib import HASH
 from hashlib import sha1
@@ -1567,6 +1568,9 @@ class Commit(ShaFile):
 
     def _get_extra(self):
         """Return extra settings of this commit."""
+        warnings.warn(
+            'Commit.extra is deprecated. Use Commit._extra instead.',
+            DeprecationWarning)
         return self._extra
 
     extra = property(