防止在Git中结帐 [英] Prevent a checkout in Git

查看:175
本文介绍了防止在Git中结帐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在考虑使用Git从OpenInsight应用程序管理源代码。由于OI代码存储在数据库表中,因此需要进行一定量的手动工作才能将源文件导出到文本中,反之亦然。

到目前为止,我设法自动化很多这样的工作使用Git钩子,但缺少预检查钩子给了我一个问题。



当用户切换分支时,我有一个结账后挂钩来区分旧的和新的分行,并存储更改后的程序列表。当用户下一次启动OI时,所做的更改将从文本文件中拉出并进行编译..到目前为止这么好..但是,如果用户要切换分支,比如说从A到B,然后再次切换到C而不启动OI,那么OI的源代码将用于分支A,但差异将在B和C之间。

为了解决这个问题,我希望能够使用pre- checkout挂钩来检查是否存在包含未编译更改列表的文件,并停止用户切换分支,直到它们被编译为止。是否有任何其他建议停止结帐?

解决方案

我最近也在研究这个问题,并且发现了一个线程,讨论当前(well ... 2010)状态 githooks



http://git.661346.n2.nabble.com/Why-there-is-no-pre-checkout-hook-td5638042.html



来自线索:


ÓscarFuentes写道:

...

因为你可以使用脚本代替git checkout。

您是否考虑编写一个脚本,开发人员可以将其作为其开发工作流程的一部分?这样你可以检查是否存在未编译的更改列表。这基本上是我们最终做的,它确实帮助我们简化/标准化了我们的工作流程。


I'm currently looking into managing source code from an OpenInsight application using Git. Because OI code is stored in a database table there is a certain amount of manual work to export the source to text and visa-versa.

So far I have managed to automate a lot of this work using Git hooks, but the lack of a 'pre-checkout' hook has given me a problem..

When a user switches branches I have a post-checkout hook to diff the old and new branches and store a list of the changed procedures. When the user next starts OI the changes are pulled in from the text files and compiled.. so far so good.. However, if a user was to switch branches, let say from A to B, and then switch again to C without starting OI then the source in OI will be for branch A but the diff will be between B and C.

To get around this I hoped to be able to use a pre-checkout hook to check for the existence of a file containing a list of un-compiled changes and stop the user switching branches until they were compiled in. Are there any other suggestions of ways of halting a checkout?

解决方案

I was also looking into this recently and found a thread discussing the current (well... 2010) state of githooks

http://git.661346.n2.nabble.com/Why-there-is-no-pre-checkout-hook-td5638042.html

From the thread:

Óscar Fuentes wrote:
...
Because you can use your script in place of "git checkout".

Have you considered writing a script that developers can as part of their development workflow? That way you can check for the existence of the un-compiled changes list. This is basically what we ended up doing and it really helped us to simplify/standardize our workflow.

这篇关于防止在Git中结帐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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