Magit:在编辑提交日志之前如何看到预提交钩子? [英] Magit : how to see pre-commit hooks before editing commit log?

查看:212
本文介绍了Magit:在编辑提交日志之前如何看到预提交钩子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在命令行上使用 git ,在输入提交日志消息之前,可以看到预提交钩子的结果。如果你的预提交钩子使提交失败,你是保卫的,不要写任何东西。

With git on the command line, you see the result of your pre-commit hooks before entering the commit's log message. If your pre-commit hook makes the commit fail, you are warnt and don't write anything.

但是,使用 magit 要输入您的日志注释,然后它将评估您的挂钩,如果失败,您不会看到为什么。您只是阅读:

But with magit, you are asked to enter your log comment and then it evaluates your hook, and if it fails you don't see why. You just read :

git异常退出代码1。
我明白这是正常的,因为它当您完成编辑magit运行git命令的日志消息时。

git exited abnormally with code 1. I understand this is normal because it is when you are finished editing the log message that magit runs the git command.

那么,在请求日志之前,如何让magit来评估你的钩子? ?
如何让magit显示钩子的结果?

So, how would you make magit to evaluate your hook before asking for the log ? How can you make magit display the result of the hook ?

相关的问题是,你如何提供参数给你提前挂钩我只能使用预提交钩子来检查是否没有忘记调试文件,而不是存储库中的所有文件?

And a related question would be, how do you give arguments to you pre-commit hook in order to run it for the stashed files only, instead of all the files in the repository ?

东西,像剩下的'ipdb'和一些个人痕迹。

I use pre-commit hooks mainly to check if I didn't forget debugging stuff, like a remaining 'ipdb', and some personal traces.

谢谢!

推荐答案

在打开日志消息缓冲区之前,我已经编写了运行钩子的代码:

I've wrote code for running the hook before opening the log-message buffer:

https://github.com/vanicat/magit/commit/87ec17c46b156c8508a47aa6c9ba982ef8a61b4c

你可以测试它,它错过了忽略钩子的可能性,现在不要像预先提交一样运行别人的钩子。

You could test it, it miss the possibility to ignore the hook, and don't run others hook than pre-commit for now.

这篇关于Magit:在编辑提交日志之前如何看到预提交钩子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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