开发者

git log since yesterday for working days only

For my daily standups I like to output my commits for a refresher of what I was working on.

I have the foll开发者_JAVA技巧owing alias:

standup = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(green)<%an>%Creset' --abbrev-commit --date=relative --committer='me' --all --since='yesterday'

However this does not work for a Monday morning due to the weekend.

Does anyone know how to use git log --since for a set of working days such as Mon - Fri, or Tue - Sat?


Assuming a POSIX-y shell, in my case bash:

function yesterworkday() 
{ 
    if [[ "1" == "$(date +%u)" ]]
    then 
        echo "last friday"
    else
        echo "yesterday"
    fi
}

git log --since="$(yesterworkday)"

Again all credits go to the authors of git for making this insanely easy by accepting "last friday" as a valid date specification to begin with!

PS. to make this a git alias, you need to include bash shell in your alias, I'll edit with a sample in a minute

Edit Putting this logic directly into a git alias proves difficult (with all the quoting required). See here for ideas: .gitconfig alias function call

I fully recommend making a shell script of this, and you could alias the shell script directly like so:

standup = !$HOME/standuplog.sh

or add to one of your $PATH folders and name it git-standup.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜