From b7cd7d35651e3713684b426ce537587b1cedc9ba Mon Sep 17 00:00:00 2001 From: "Luiz Fernando N. Capitulino" Date: Wed, 18 Jul 2007 21:47:01 -0300 Subject: [PATCH] libgit-thin: pygit: Introduces README file Signed-off-by: Luiz Fernando N. Capitulino --- libgit-thin/pygit/README | 115 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 libgit-thin/pygit/README diff --git a/libgit-thin/pygit/README b/libgit-thin/pygit/README new file mode 100644 index 0000000000..c612736d0f --- /dev/null +++ b/libgit-thin/pygit/README @@ -0,0 +1,115 @@ + PyGit: A GIT binding for python + =============================== + + [ Dedicated to the people who died in the worst Brazil's airplane accident, + at São Paulo's Congonhas airport on 2007/07/17 ] + + +1 Introduction +-------------- + +PyGit is a GIT binding for python. With it you'll be able to retrieve +information from GIT repositories using python. + +Currently it's capable of retriving commit information, blob and tree +contents, and supports revision listing as well. + +The 'demo.txt' file has some useful examples on how to use the module. + +2 Compiling +----------- + +Just type 'make' in the pygit's directory, note that it depends on +libgit-thin. + +3 Using +------- + +PyGit defines three new types: + + o Git_Repo_Type: Describes a GIT repository + o Git_Commit_Type: Describes a GIT commit object + o Git_RevList_Type: Describes the rules for revision listing + + Objects of the repository type are created by the open() method, and it's +a required operation to start working: + +""" +>>> import pygit +>>> repo = pygit.open('/tmp/simple-repo') +""" + + '/tmp/simple-repo' is what the name implies, it's a GIT repository and +now you can do some basic repository operations: + +""" +>>> repo.head_commit() +'86eb4867dc6983d11e8c8a691a3c62346d87e451' +>>> repo.read_blob('b45ef6fec89518d314f546fd6c3025367b721684') +'Hello, World!' +>>> +""" + + Objects of the commit type are created by the repository type's commit_lookup() +method (and by the revision list object, keep reading!): + +""" +>>> commit = repo.lookup_commit('86eb4867dc6983d11e8c8a691a3c62346d87e451') +>>> commit.id() +'86eb4867dc6983d11e8c8a691a3c62346d87e451' +>>> commit.message() +'Introduces hello.txt\n' +>>> print commit.message() +Introduces hello.txt + +>>> print commit.buffer() +tree 79321ed405490e585cd9a2b79f18a915d6d68a96 +author Gjorg Berisha 1165971600 -0200 +committer Charles Bukowski 1165971600 -0200 + +Introduces hello.txt + +>>> +""" + + Objects of the revision list type are created by the repository type's +revlist() method: + +""" +>>> rv = repo.revlist() +""" + + But before of doing the revision listing, you need to do some setup: + +""" +>>> rv.include('8d9107e8c50e1c4ff43c91c8841805833f3ecfb9') +>>> rv.max_count(10) +>>> rv.show_merges() +""" + + It means: go over ten commits starting at +8d9107e8c50e1c4ff43c91c8841805833f3ecfb9 show merges as well. + + Now you can transverse it: + +""" +>>> for commit in rv: +... print commit.id() +... +8d9107e8c50e1c4ff43c91c8841805833f3ecfb9 +16cefa8c3863721fd40445a1b34dea18cd16ccfe +4fbef206daead133085fe33905f5e842d38fb8da +4fd885170bf13841ada921495b7b00c4b9971cf9 +af09f1e4b3214569de93bc9309c35014e5c8a3d0 +e030dbf91a87da7e8be3be3ca781558695bea683 +12a22960549979c10a95cc97f8ec63b461c55692 +31c4ab430a448cfb13fc88779d8a870c7af9f72b +8b69ad0e690eb5f38c23087247a12e5fde1baeff +aba2da66cfbf7790ad79d4dee95871127d5ddf5e +>>> +""" + + That's it, 'commit' is an ordinary commit object. + +Luiz Fernando N. Capitulino + -- 2.11.4.GIT