Skip to main content
added 107 characters in body
Source Link
Andi
  • 161
  • 2

You actually can access the commit_id with GitPython methods via the hexsha attribute. Short example:

import git

def main():
    repo = git.Repo('.')
    for commit in repo.iter_commits('master'):        
        # do something with the commit, for example:
        # repo.git.diff(commit.parents[0].hexsha, commit.hexsha)  
        # commit.committed_datetime.strftime("%a %d. %b %Y")
        # commit.message.rstrip() 
     
        # see http://gitpython.readthedocs.io/en/stable/tutorial.html#the-commit-object for more information on the available attributes/methods of the commit object
if __name__ == "__main__":
    main()
import git

def main():
    repo = git.Repo('.')
    for commit in repo.iter_commits('master'):        
        # do something with the commit, for example:
        # repo.git.diff(commit.parents[0].hexsha, commit.hexsha)  
        # commit.committed_datetime.strftime("%a %d. %b %Y")
        # commit.message.rstrip() 
     
        # see http://gitpython.readthedocs.io/en/stable/tutorial.html#the-commit-object for more information on the available attributes/methods of the commit object
if __name__ == "__main__":
    main()

You actually can access the commit_id with GitPython methods via the hexsha attribute. Short example:

import git

def main():
    repo = git.Repo('.')
    for commit in repo.iter_commits('master'):        
        # do something with the commit, for example:
        repo.git.diff(commit.parents[0].hexsha, commit.hexsha)  
        # commit.committed_datetime.strftime("%a %d. %b %Y")
        # commit.message.rstrip() 
     
        # see http://gitpython.readthedocs.io/en/stable/tutorial.html#the-commit-object for more information on the available attributes/methods of the commit object
if __name__ == "__main__":
    main()
Source Link
Andi
  • 161
  • 2

import git

def main():
    repo = git.Repo('.')
    for commit in repo.iter_commits('master'):        
        # do something with the commit, for example:
        # repo.git.diff(commit.parents[0].hexsha, commit.hexsha)  
        # commit.committed_datetime.strftime("%a %d. %b %Y")
        # commit.message.rstrip() 
     
        # see http://gitpython.readthedocs.io/en/stable/tutorial.html#the-commit-object for more information on the available attributes/methods of the commit object
if __name__ == "__main__":
    main()