Skip to content

Commit 93302a1

Browse files
committed
Add dulwich to Appendinx B: embedding
Signed-off-by: Alexander Bezzubov <[email protected]>
1 parent 96cb0a9 commit 93302a1

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

B-embedding-git-in-your-applications.asc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ include::book/B-embedding-git/sections/libgit2.asc[]
1515
include::book/B-embedding-git/sections/jgit.asc[]
1616

1717
include::book/B-embedding-git/sections/go-git.asc[]
18+
19+
include::book/B-embedding-git/sections/dulwich.asc[]
20+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
=== Dulwich
2+
3+
(((Dulwich)))((("Python")))
4+
There is also a pure-Python Git implementation - Dulwich.
5+
The project is hosted under https://www.dulwich.io/
6+
It aims to provide an interface to git repositories (both local and remote) that doesn't call out to git directly but instead uses pure Python.
7+
It has an optional C extensions though, that significantly improve the performance.
8+
9+
Dulwich follows git design and separate two basic levels of API: plumbing and porcelain.
10+
11+
Here is an example of using the lower level API to access the commit message of the last commit:
12+
13+
[source, python]
14+
-----
15+
from dulwich.repo import Repo
16+
r = Repo('.')
17+
r.head()
18+
# '57fbe010446356833a6ad1600059d80b1e731e15'
19+
20+
c = r[r.head()]
21+
c
22+
# <Commit 015fc1267258458901a94d228e39f0a378370466>
23+
24+
c.message
25+
# 'Add note about encoding.\n'
26+
-----
27+
28+
To print a commit log using high-level porcelain API, one can use:
29+
30+
[source, python]
31+
-----
32+
from dulwich import porcelain
33+
porcelain.log('.', max_entries=1)
34+
35+
#commit: 57fbe010446356833a6ad1600059d80b1e731e15
36+
#Author: Jelmer Vernooij <[email protected]>
37+
#Date: Sat Apr 29 2017 23:57:34 +0000
38+
-----
39+
40+
41+
==== Further Reading
42+
43+
* The official API documentation is available at https://www.dulwich.io/apidocs/dulwich.html[]
44+
* Official tutorial at https://www.dulwich.io/docs/tutorial[] has many examples of how to do specific tasks with Dulwich

0 commit comments

Comments
 (0)