潜艇钩

submarine-githooks的Python项目详细描述


#subseal githhooks
[tickle]使用的git钩子(https://tickleapp.com)



使用``pip install subseal githhooks```)



collaborators by``` seavel githhooks setup script``
此命令创建一个"setup githhooks",供协作者设置git hooks。

(install命令链接.git/hooks并为git hooks创建空间。
setup script生成的脚本只是链接事情是这样的,假设Git钩子的空间已经存在。)



创建检查器的最简单方法是:
``python
来自subseal githhooks.checker导入检查器请在下面的部分传入。

检查器设置

活动挂钩

`` python
@checker
@checker.active_挂钩('pre-commit')
def a_checker(*args):
pass


@checker
@checker.active_挂钩('pre-commit',"post merge")
通过注册活动钩子来定义另一个钩子(*args):
pass



@checker
@checker.active钩子('pre-commit')
@checker.active钩子('post-merge')
def third钩子('args):
pass

```

然后,checker将仅适用于该类型的git钩子。
(默认情况下,checker适用于所有类型的git钩子)

在上面的示例中,第一个checker仅适用于"pre commit"钩子,
以下两个选项同时适用于"预提交"和"后合并"。

reference:[git hooks types](https://www.digitalocean.com/community/tutorials/how to use git hooks to automation development and deployment tasks)。

扩展名

`` python
@checker
@checker.file_pattern(r'\.py$')
def a_checker(*args):
pass

@checker
@checker.file_extension('.json')
def另一个检查程序(*args):
pass
````

checker.


\checker实现


您可以制作如下检查程序:
``python
@checker
@checker.active_hooks('pre-commit')
@checker.file_extension('.json')
def pre_commit(git_repo,hook_name,文件路径:
json.loads(git回购文件内容(文件路径))

````

"pre commit"钩子以非零返回代码退出。然后"git commit"被中止。

注意,您应该使用"git_repo"对象来获取文件内容,但不能直接从磁盘读取,因为您应该检查的内容是添加到git索引中的内容。




checker

@checker
@checker.active_hooks('pre-commit')
def pre_commit(git_repo,hook_name,file_path):
"
:param git_repo:表示当前git repo的gitreo实例
:键入git_repo:taskr.contrib.git.gitreo
:param hook_name:正在执行的钩子
:键入hook_name:str
:param file_path:要提交的文件的路径
:键入file_path:str
"



@checker.active_hooks('commit-msg')
def commit_msg(git_repo,hook_name,commit_message_filepath:
"
:param git_repo:表示当前git repo的gitreo实例
:type git_repo:taskr.contrib.git.gitreo
:param hook_name:正在执行的钩子
:type hook_name:str
:param commit_message_filepath:的路径保存提交消息的文件
:键入commit_message_file path:str
"



@checker
@checker.active_hooks('post-merge')
def post_merge(git_repo,hook_name,file_path,source_commit,squash_merge):
"
:param git_repo:表示gitreo实例的gitreo实例当前git repo
:键入git repo:taskr.contrib.git.gitrep
:param hook_name:正在执行的挂钩
:键入hook_name:str
:param file_path:已合并文件的路径
:键入file_path:str
:param source_commit:合并的提交IDsource
:键入source_commit:str
:param squash_merge:一个标志,指示这是否是一个squash merge
:键入suqsh_merge:bool
"


@checker
@checker.active_hooks('post-checkout')
def post_checkout(git_repo,hook_name,file_path,source_commit_id,目标代码:
"
:param git_repo:表示当前git repo的gitreo实例
:type git_repo:taskr.contrib.git.gitreo
:param hook_name:正在执行的钩子
:type hook_name:str
:param file_path:文件的路径在签出期间更改
:键入file_path:str
:param source_commit_id:ref of the previous head
:键入source_commit_id:str
:param destination_commit id:ref of the new head
:键入destination_commit id:str
"


@checker.active_hooks('pre-push')
def pre_push(git_repo,hook_name,
remote_name,remote_url,
local_ref,local_commit_id,
remote_ref,remote_commit_id,
从本地删除的分支",
new_branch_to_remote:
"
:param git_repo:表示当前git repo的gitreo实例
:类型git_repo:taskr.contrib.git.gitreo
:param hook_name:正在执行的钩子
:类型hook_name:str
:param remote_name:远程推送到
:键入远程名称:str
:param remote_url:要推送到
的远程的url:键入远程URL:str
:param local_ref:要推送到的本地分支的ref
:键入local_ref:str
:param local_commit_id:要推送到的本地分支的sha
:type local_commit_id:str
:param remote_ref:ref to push to
:type remote_ref:str
:param remote_commit_id:sha of remote branch to push to
:type remote_commit_id:str
:param branch_deleted_from_local:表示本地分支已已删除
:type branch_deleted_from_local:bool
:param new_branch_to_remote:一个标志,指示这是要推送到remote的新分支
:type new_branch_to_remote:bool
"
````

u todo:配置_

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java MySQL准备的语句未从JavaFX文本字段读取   java在Karaf的OSGi包中使用jboss resteasy(客户端)   Diamond不编译Java 7   Java中的超类和子类   使用PL/Java和JPA或其他持久性库的postgresql   java由于大写而导致“无法识别的字段”   javascript客户端未接收来自Servlet的响应   java如何保持从url下载到imageview的图像的质量,并将其裁剪成圆形?   java如何在EditText更改时从ArrayAdapter中删除项?   java我应该怎么做?我不能使用jUnit等   java在int[]b;中查找对;?   java为什么我的HBase启动后没有任何日志?   java无法在发布模式下启动活动(使用proguard安卓optimize配置)   java在绘制绘图线后取消选择绘图线   java Android和Robotium编写自动化测试?