libgit-thin: pygit: Introduces README file
[git/libgit-gsoc.git] / libgit-thin / pygit / README
blobc612736d0f4e07fd68f4eceb8026c5bd77a58422
1                 PyGit: A GIT binding for python
2                 ===============================
4  [ Dedicated to the people who died in the worst Brazil's airplane accident,
5    at São Paulo's Congonhas airport on 2007/07/17 ]
8 1 Introduction
9 --------------
11 PyGit is a GIT binding for python. With it you'll be able to retrieve
12 information from GIT repositories using python.
14 Currently it's capable of retriving commit information, blob and tree
15 contents, and supports revision listing as well.
17 The 'demo.txt' file has some useful examples on how to use the module.
19 2 Compiling
20 -----------
22 Just type 'make' in the pygit's directory, note that it depends on
23 libgit-thin.
25 3 Using
26 -------
28 PyGit defines three new types:
30  o Git_Repo_Type: Describes a GIT repository
31  o Git_Commit_Type: Describes a GIT commit object
32  o Git_RevList_Type: Describes the rules for revision listing
34  Objects of the repository type are created by the open() method, and it's
35 a required operation to start working:
37 """
38 >>> import pygit
39 >>> repo = pygit.open('/tmp/simple-repo')
40 """
42  '/tmp/simple-repo' is what the name implies, it's a GIT repository and
43 now you can do some basic repository operations:
45 """
46 >>> repo.head_commit()
47 '86eb4867dc6983d11e8c8a691a3c62346d87e451'
48 >>> repo.read_blob('b45ef6fec89518d314f546fd6c3025367b721684')
49 'Hello, World!'
50 >>> 
51 """
53  Objects of the commit type are created by the repository type's commit_lookup()
54 method (and by the revision list object, keep reading!):
56 """
57 >>> commit = repo.lookup_commit('86eb4867dc6983d11e8c8a691a3c62346d87e451')
58 >>> commit.id()
59 '86eb4867dc6983d11e8c8a691a3c62346d87e451'
60 >>> commit.message()
61 'Introduces hello.txt\n'
62 >>> print commit.message()
63 Introduces hello.txt
65 >>> print commit.buffer()
66 tree 79321ed405490e585cd9a2b79f18a915d6d68a96
67 author Gjorg Berisha <gberisha@brokenapril.org> 1165971600 -0200
68 committer Charles Bukowski <buko@massa.com.br> 1165971600 -0200
70 Introduces hello.txt
72 >>> 
73 """
75  Objects of the revision list type are created by the repository type's
76 revlist() method:
78 """
79 >>> rv = repo.revlist()
80 """
82  But before of doing the revision listing, you need to do some setup:
84 """
85 >>> rv.include('8d9107e8c50e1c4ff43c91c8841805833f3ecfb9')
86 >>> rv.max_count(10)
87 >>> rv.show_merges()
88 """
90  It means: go over ten commits starting at
91 8d9107e8c50e1c4ff43c91c8841805833f3ecfb9 show merges as well.
93  Now you can transverse it:
95 """
96 >>> for commit in rv:
97 ...  print commit.id()
98 ... 
99 8d9107e8c50e1c4ff43c91c8841805833f3ecfb9
100 16cefa8c3863721fd40445a1b34dea18cd16ccfe
101 4fbef206daead133085fe33905f5e842d38fb8da
102 4fd885170bf13841ada921495b7b00c4b9971cf9
103 af09f1e4b3214569de93bc9309c35014e5c8a3d0
104 e030dbf91a87da7e8be3be3ca781558695bea683
105 12a22960549979c10a95cc97f8ec63b461c55692
106 31c4ab430a448cfb13fc88779d8a870c7af9f72b
107 8b69ad0e690eb5f38c23087247a12e5fde1baeff
108 aba2da66cfbf7790ad79d4dee95871127d5ddf5e
109 >>> 
112  That's it, 'commit' is an ordinary commit object.
114 Luiz Fernando N. Capitulino
115 <lcapitulino@gmail.com>