4

I am developing a script which requires me to get a list of all commits for a particular repository, as well as the date and time of commit. The Commit Class in the PyGithub API:

https://github.com/jacquev6/PyGithub/blob/master/doc/ReferenceOfClasses.md#class-commit

does not have any member for date-of-commit and time-of-commit. Any ideas on how to get the date and time of a commit using the API?

1
  • Is this a question? I don't think so. Commented Feb 16, 2013 at 10:09

3 Answers 3

4

A bit late to answer, but you can get the information from the GitAuthor of the GitCommit of the Commit. This will print the dates of all the commits:

for commit in commits:
    if commit.commit is not None:
        print commit.commit.author.date
Sign up to request clarification or add additional context in comments.

Comments

0

I think you need to call

commit.getStatuses()

and in each satsus there is attributes created_at and updated_at

from here: https://github.com/jacquev6/PyGithub/blob/master/doc/ReferenceOfClasses.md#class-commitstatus

Class CommitStatus

Attributes:

  • created_at: datetime.datetime
  • creator: NamedUser
  • description: string
  • id: integer
  • state: string
  • target_url: string
  • updated_at: datetime.datetime

2 Comments

I wondered about this, but why would there be more than one CommitStatus per commit?
@wrgrs Isn't that because you may amend commits and push changes again? (or even do a rebase)
0
   from github import Github

   gh = Github(base_url="", login_or_token="")

   repo = gh.get_repo(repo_name)

   #returned commits in a paginated list
   commits = repo.get_commits()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.