File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
book/B-embedding-git/sections Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -15,3 +15,6 @@ include::book/B-embedding-git/sections/libgit2.asc[]
15
15
include::book/B-embedding-git/sections/jgit.asc[]
16
16
17
17
include::book/B-embedding-git/sections/go-git.asc[]
18
+
19
+ include::book/B-embedding-git/sections/dulwich.asc[]
20
+
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments