Browse Source

Deprecate Commit.extra.

Jelmer Vernooij 2 years ago
parent
commit
1f3a66994f
2 changed files with 13 additions and 0 deletions
  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(