Переглянути джерело

Merge pull request #1136 from jelmer/deprecate-extra

Deprecate Commit.extra
Jelmer Vernooij 2 роки тому
батько
коміт
60549c54bc
2 змінених файлів з 13 додано та 0 видалено
  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(