在提交之前保存修改后的日志 [英] save a modified log right before a commit

查看:58
本文介绍了在提交之前保存修改后的日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个文件,该文件列出已修改项目中的所有文件.

I'm trying to set up a file that list all of the files in a project that was modified.

我希望每次提交时都自动完成此操作.我尝试使用所有git log命令,但还是没有运气.

I want this to be done automatically whenever I commit. I tried playing around with all of the git log commands but still no luck.

我这样做是为了通知服务器,在服务器对存储库进行检出之后,哪些文件需要重新缩小.

I'm doing this to signal to the server which files need re-minification after the server does a checkout on the repo.

到目前为止,这是我的脚本:

This is my script so far:

FILES="$(find /home/qwertymk/public_html -type f -name '*.js')"
CHANGED="git whatchanged -n 1 --pretty=format:"
for f in $FILES
do
 if [[ $f =~ /home/torah/public_html/ignore-folder/ ]]; then continue; fi
 if [[ $f =~ $CHANGED ]]; then continue; fi  # What do I do here?
  echo "processing - $f"
  php /home/qwertymk/jsmin/curl.php $f
done

推荐答案

您可以使用

Instead of saving the list of modified files in the commit message, you can query git directly for this information using git-whatchanged. To get a list of changes for the latest commit you can do:

git whatchanged -n 1

要获取两次命名提交之间的更改列表,可以执行以下操作:

To get a list of changes between two named commits, you can do:

git whatchanged <since>..<until>

您还可以像这样从 git-log 获取此信息,包括任何其他您想要的git-log选项:

You can also get this info from git-log like this, including whatever other git-log options you want:

git log --name-status <options>

按照注释中的注释进行操作,这可能会为您提供所需的信息,这些信息几乎精简为所需的内容:

Following the notes in the comments, this probably gets you the information you need distilled down to nearly only what you need:

git log --name-status --pretty=format: -n 1

(将-n 1替换为指定提交所需的任何内容)

(Replace -n 1 with whatever you need to specify the commits)

这篇关于在提交之前保存修改后的日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆