-
-
Notifications
You must be signed in to change notification settings - Fork 394
Guidelines
-
public libgit2 structs should be python objects (classes)
Example:
git_repository
=>Repository()
-
naming convention: strip git_
struct_name
_*Example:
git_repository_config()
=>Repository.config()
-
iterations should be implemented as a generator, if this is not possible we need to change libgit2 (other bindings will benefit from this as well)
-
every method should map to one libgit2 function (exceptions are iterations)
-
return values of methods
- no lists use generators instead
- no dictionaries use tuples or objects instead
- no instantiation of objects use strings instead (important for generators) like sha1-hash for objects or names for references. The high-level API can instance them if necessary.
-
As it's easier, errorless, painless and faster to implement stuff in python we use
Repository()
as a our high level pythonic class. Here you should add every pythonic sugar likeRepository.create_reference()
. -
We try to implement everything in the c extension as simple as possible. Therefore please do not put too much abstraction into the c extension layer. Use the
Repository
class for abstraction.Example: Implement several methods for each type/use case like for Diff:
- Tree.diff_to_tree(),
- Tree.diff_to_workdir()
- Tree.diff_to_index()
To have a user friendly api, you can now implement a high-level method in python to abstract these methods like
Repository.diff()
-
no return value restrictions