CONTRIBUTING.rst 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. All functionality should be available in pure Python. Optional Rust
  2. implementations may be written for performance reasons, but should never
  3. replace the Python implementation.
  4. Where possible include updates to NEWS along with your improvements.
  5. New functionality and bug fixes should be accompanied by matching unit tests.
  6. Coding style
  7. ------------
  8. Where possible, please follow PEP8 with regard to coding style. Run ruff.
  9. Furthermore, triple-quotes should always be """, single quotes are ' unless
  10. using " would result in less escaping within the string.
  11. Public methods, functions and classes should all have doc strings. Please use
  12. Google style docstrings to document parameters and return values.
  13. You can generate the documentation by running "make doc".
  14. String Types
  15. ~~~~~~~~~~~~
  16. Like Linux, Git treats filenames as arbitrary bytestrings. There is no prescribed
  17. encoding for these strings, and although it is fairly common to use UTF-8, any
  18. raw byte strings are supported.
  19. For this reason, the lower levels in Dulwich treat git-based filenames as
  20. bytestrings. It is up to the Dulwich API user to encode and decode them if
  21. necessary. The porcelain may accept unicode strings and convert them to
  22. bytestrings as necessary on the fly (using 'utf-8').
  23. * on-disk filenames: regular strings, or ideally, pathlib.Path instances
  24. * git-repository related filenames: bytes
  25. * object sha1 digests (20 bytes long): bytes
  26. * object sha1 hexdigests (40 bytes long): str (bytestrings on python2, strings
  27. on python3)
  28. Exceptions
  29. ~~~~~~~~~~
  30. When catching exceptions, please catch the specific exception type rather than
  31. a more generic type (like OSError, IOError, Exception, etc.). This will
  32. ensure that you do not accidentally catch unrelated exceptions.
  33. The only exception is when you are reraising an exception, e.g. when
  34. re-raising an exception after logging it.
  35. Do not catch bare except, although ruff will warn you about this.
  36. Keep the code within a try/except block as small as possible, so
  37. that you do not accidentally catch unrelated exceptions.
  38. Deprecating functionality
  39. ~~~~~~~~~~~~~~~~~~~~~~~~~
  40. Dulwich uses the `dissolve` package to manage deprecations. If you want to deprecate
  41. functionality, please use the `@replace_me` decorator from the root of the
  42. dulwich package. This will ensure that the deprecation is handled correctly:
  43. * It will be logged as a warning
  44. * When the version of Dulwich is bumped, the deprecation will be removed
  45. * Users can use `dissolve migrate` to automatically replace deprecated
  46. functionality in their code
  47. Running the tests
  48. -----------------
  49. To run the testsuite, you should be able to simply run "make check". This
  50. will run the tests using unittest.
  51. ::
  52. $ make check
  53. The compatibility tests that verify Dulwich behaves in a way that is compatible
  54. with C Git are the slowest, so you may want to avoid them while developing:
  55. ::
  56. $ make check-nocompat
  57. testr and tox configuration is also present.
  58. Merge requests
  59. --------------
  60. Please either send pull requests to the maintainer (jelmer@jelmer.uk) or create
  61. new pull requests on GitHub.
  62. Licensing
  63. ---------
  64. All contributions should be made under the same license that Dulwich itself
  65. comes under: both Apache License, version 2.0 or later and GNU General Public
  66. License, version 2.0 or later.