[英]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.对于我的日常站立会议,我喜欢 output 我的提交,以更新我正在做的事情。
I have the following 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?有谁知道如何使用
git log --since
为一组工作日,例如周一 - 周五或周二 - 周六?
Assuming a POSIX-y shell, in my case bash:假设一个 POSIX-y shell,在我的例子中是 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!再次将 go 归功于
git
的作者,因为他们通过接受“上周五”作为开始的有效日期规范使这变得非常容易!
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
要使其成为 git 别名,您需要在别名中包含 bash shell ,我将在一分钟内使用示例进行编辑
Edit Putting this logic directly into a git alias proves difficult (with all the quoting required).编辑将此逻辑直接放入 git 别名证明很困难(需要所有引用)。 See here for ideas: .gitconfig alias function call
见这里的想法: .gitconfig 别名 function 调用
I fully recommend making a shell script of this, and you could alias the shell script directly like so:我完全建议为此创建一个 shell 脚本,您可以像这样直接为 shell 脚本命名:
standup = !$HOME/standuplog.sh
or add to one of your $PATH
folders and name it git-standup
.或添加到您的
$PATH
文件夹之一并将其命名为git-standup
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.