在Github中执行PEP-8'ish格式提交 [英] Enforcing PEP-8'ish formatting in Github commits

查看:192
本文介绍了在Github中执行PEP-8'ish格式提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有办法在本地签出时自动化这个过程(类似Bazaar可以推送的地方提交挂钩到客户端)?应该足够的是,当你签出一个repo时,它会附带安装的提交钩子,不需要进一步的工作/命令来运行。如果你的.py文件有一个tab,那么提交将会中止,并且一个droid被发送来打击开发者。 GitHub服务(请参阅 GitHub - 所有钩子 ,以及现有的第三方服务)。



但是你不能推钩(请参阅​​为什么它不可能添加git .git / hooks / my-hook Git remote / shared pre-commit hook



您可以编写脚本作为挂接版本,但每个客户端仍需要激活其预挂钩(带有指向该版本脚本的符号链接)。



这种版本化脚本(用于Python标准)的示例将在s 博客文章 a>,通过 Lorenzo Bolla ,并在 GitHub repo

它基于 PyLint PyFlake (另见 PyLint,PyChecker或PyFlakes?)。






OP在评论中提及 package vvv 0.1
$ b


一个用于软件源代码验证和分支的便利工具



VVV 是e asy验证和linting集成为您的软件项目。

使用单个命令验证所有文件,无论使用哪种编程语言,都在源树中针对您在简单配置文件中指定的策略。

VVV 可以防止在您的软件源代码控制中提交坏东西,或者使清理工作变得更容易。


Are there any premade solutions to enforce good Python standards in Git commit hooks?

Are there way to automamize this process in local checkouts (akin Bazaar where one can push commit hooks to clients)? It should be enough that when you checkout a repo it would come with commit hooks installed, no further work / commands to run.

E.g. if your .py file has a tab the commit would abort and a droid is send to spank the developer.

解决方案

You could add a service on GitHub side (see "GitHub - All the Hooks", and the existing third-party services).

But you cannot "push a hook" (see "why it is not possible to git add .git/hooks/my-hook" or "Git remote/shared pre-commit hook".

You can version the script which would serve as hook, but each client would still need to activate their pre-commit hook (with a symbolic link pointing to that versioned script).

An example of such a versioned script (for Python standards) would be visible in this blog post, by Lorenzo Bolla, and updated in this GitHub repo.
It is based on PyLint and PyFlake (see also "PyLint, PyChecker or PyFlakes?").


The OP mentions in the comments the package vvv 0.1

A convenience utility for software source code validation and linting

VVV is a tool for easy validation and linting integration for your software project.
With a single command validate all files, no matter in which programming language, in a source tree against a policy you specify in a simple configuration file.
VVV prevents bad stuff to be committed in your software source control or makes cleaning it up easier.

这篇关于在Github中执行PEP-8'ish格式提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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