mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
## What does this change do? Adds a small example of how to get at the date a commit took place. ### Changes #### doc/examples/Commit.rst Adds a block of code that demonstrates how to get at a commit's date. ## Motivation This example is in the spirit of #874. When I began using PyGithub it was not readily apparent to me where the commit date was being abstracted to. Being unfamiliar with Git's API, it took some convincing for me to be satisfied that the `Commit.commit.author/committer.date` path would get me the commit date. I would hope that this would save somebody a little bit of time in the future. ## How has this been tested? I've built the docs locally and made sure the HTML is generated as expected. ## Screenshots 
28 lines
671 B
ReStructuredText
28 lines
671 B
ReStructuredText
Commit
|
|
======
|
|
|
|
Create commit status check
|
|
--------------------------
|
|
|
|
.. code-block:: python
|
|
|
|
# sha -> commit on which the status check will be created
|
|
# For example, for a webhook payload
|
|
# sha = data["pull_request"]["head"]["sha"]
|
|
repo.get_commit(sha=sha).create_status(
|
|
state="pending",
|
|
target_url="https://FooCI.com",
|
|
description="FooCI is building",
|
|
context="ci/FooCI"
|
|
)
|
|
|
|
Get commit date
|
|
--------------------------
|
|
|
|
.. code-block:: python
|
|
|
|
>>> commit = repo.get_commit(sha=sha)
|
|
>>> print(commit.commit.author.date)
|
|
2018-10-11 03:04:52
|
|
>>> print(commit.commit.committer.date)
|
|
2018-10-11 03:04:52 |