Update readme file
This commit is contained in:
14
README.md
14
README.md
@@ -45,8 +45,8 @@ Index read:
|
|||||||
|
|
||||||
>>> index = repo.index
|
>>> index = repo.index
|
||||||
>>> index.read()
|
>>> index.read()
|
||||||
>>> sha = index['path/to/file'].sha # from path to sha
|
>>> oid = index['path/to/file'].oid # from path to object id
|
||||||
>>> blob = repo[sha] # from sha to blob
|
>>> blob = repo[oid] # from object id to object
|
||||||
|
|
||||||
Inspect the status of the repository:
|
Inspect the status of the repository:
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ Inspect the status of the repository:
|
|||||||
Iterate over all entries of the index:
|
Iterate over all entries of the index:
|
||||||
|
|
||||||
>>> for entry in index:
|
>>> for entry in index:
|
||||||
... print entry.path, entry.sha
|
... print entry.path, entry.hex
|
||||||
|
|
||||||
Index write:
|
Index write:
|
||||||
|
|
||||||
@@ -70,20 +70,20 @@ Index write:
|
|||||||
Revision walking:
|
Revision walking:
|
||||||
|
|
||||||
>>> from pygit2 import GIT_SORT_TIME
|
>>> from pygit2 import GIT_SORT_TIME
|
||||||
>>> for commit in repo.walk(sha, GIT_SORT_TIME):
|
>>> for commit in repo.walk(oid, GIT_SORT_TIME):
|
||||||
... print commit.sha
|
... print commit.hex
|
||||||
|
|
||||||
Read commit information:
|
Read commit information:
|
||||||
|
|
||||||
>>> master_ref = repo.lookup_reference("refs/heads/master") # Getting the Reference object
|
>>> master_ref = repo.lookup_reference("refs/heads/master") # Getting the Reference object
|
||||||
>>> commit = repo[master_ref.sha]
|
>>> commit = repo[master_ref.oid]
|
||||||
>>> [name, email, timestamp, tz_offset] = commit.author # Read the commit authored infos
|
>>> [name, email, timestamp, tz_offset] = commit.author # Read the commit authored infos
|
||||||
>>> tree = commit.tree # Access the tree of the commit
|
>>> tree = commit.tree # Access the tree of the commit
|
||||||
|
|
||||||
Iterate over all entries of the tree:
|
Iterate over all entries of the tree:
|
||||||
|
|
||||||
>>> for entry in tree:
|
>>> for entry in tree:
|
||||||
... print entry.name, entry.sha, entry.attributes
|
... print entry.name, entry.hex, entry.attributes
|
||||||
|
|
||||||
|
|
||||||
CONTRIBUTING
|
CONTRIBUTING
|
||||||
|
Reference in New Issue
Block a user