git: changelog day by day

后端 未结 5 731
无人及你
无人及你 2020-12-23 22:23

How to generate changelog of commits groupped by date, in format:

[date today]
- commit message1
- commit message2
- commit message3
...
[date day+3]
- commi         


        
相关标签:
5条回答
  • 2020-12-23 22:35

    That would require most certainly some kind of script.
    A bit like this commandline-fu

    for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort -r
    

    (not exactly what you are after but can gives you an idea nonetheless)

    I know about GitStats which has also data organized by date (but not the commit messages)


    Note: the git branch part of this command is ill-fitted for scripting, as Jakub Narębski comments.
    git for-each-ref or git show-ref are natural candidate for scripting commands, being plumbing commands.

    0 讨论(0)
  • 2020-12-23 22:37

    I couldn't get the accepted answer to handle today's commits as my setup didn't handle the NEXT variable properly on the first iteration. Git's log parameters will accept a time too, which removes the need for a NEXT date:

    #!/bin/bash
    # Generates changelog day by day
    echo "CHANGELOG"
    echo ----------------------
    git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
        echo
        echo [$DATE]
        GIT_PAGER=cat git log --no-merges --format=" * %s" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
    done
    
    0 讨论(0)
  • 2020-12-23 22:38

    git log has --since and --until, it shouldn't be hard to wrap some stuff around that.

    0 讨论(0)
  • 2020-12-23 22:45

    I wrote a script in python to create a week-by-week git log.

    You could easily change it to days, months, etc by changing the timedelta

    https://gist.github.com/NahimNasser/4772132

    0 讨论(0)
  • 2020-12-23 22:49

    Here is dirty, but working version of the script I came up with:

    #!/bin/bash
    # Generates changelog day by day
    NEXT=$(date +%F)
    echo "CHANGELOG"
    echo ----------------------
    git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
        echo
        echo [$DATE]
        GIT_PAGER=cat git log --no-merges --format=" * %s" --since=$DATE --until=$NEXT
        NEXT=$DATE
    done
    
    0 讨论(0)
提交回复
热议问题