gitpython-2.7git-plumbing

Git: list tags and date/time for all commits in a branch


For my Python project, i need to fetch data from a git repository.

At the moment i'm using:

git rev-list --pretty [branch]

to list all commits in the branch with date, time and commit message.

But since the repository i'm working with relies on tagging, i need to read the tags for each commit as well.

This git log command shows me the tags, but for all branches plus i cant use it in my script, since its a porcelain command.

git log --tags --decorate

Does Anybody know a command i could use?


Solution

  • You can specify pretty formats to rev-list too,

    git rev-list --first-parent --pretty=%d $branch
    

    or to match your current,

    format=Author:%x09%an
    format+=%x0aDate:%x09%ad
    format+=%x0aRefs:%x09%d
    format+=%x0a%x0a'%w(,4)%s'
    format+=%x0a%x0a'%w(,4,4)%b'
    
    git rev-list --pretty="$format" $branch