作为一个自然健谈的灵魂,我的摘要行几乎总是超过50个字符。如何在标题行上强制执行50个字符的限制,仅针对提交消息和提交消息进行升级?有没有办法自定义设置?如何在Sublime中执行50个字符提交摘要行?
4
A
回答
2
像sublime-text-git一个插件将处以soft wrap on git commit message:
{
"rulers": [70]
}
但是,这适用于所有的行,不只是第一个。
你可以修改该插件来改变颜色,当你键入(但这将需要一些python编程);这是an editor like vim does:
请记住,以前冗长的消息,您可以用适当的长度,通过一个较低的选择查看。参见“How to wrap git commit comments?”。
否则,commented由larsks,一个commit-msg
hook like this one(从Addam Hardy,在python)就是真正执行该策略的唯一解决方案。
#!/usr/bin/python
import sys, os
from subprocess import call
print os.environ.get('EDITOR')
if os.environ.get('EDITOR') != 'none':
editor = os.environ['EDITOR']
else:
editor = "vim"
message_file = sys.argv[1]
def check_format_rules(lineno, line):
real_lineno = lineno + 1
if lineno == 0:
if len(line) > 50:
return "Error %d: First line should be less than 50 characters " \
"in length." % (real_lineno,)
if lineno == 1:
if line:
return "Error %d: Second line should be empty." % (real_lineno,)
if not line.startswith('#'):
if len(line) > 72:
return "Error %d: No line should be over 72 characters long." % (
real_lineno,)
return False
while True:
commit_msg = list()
errors = list()
with open(message_file) as commit_fd:
for lineno, line in enumerate(commit_fd):
stripped_line = line.strip()
commit_msg.append(line)
e = check_format_rules(lineno, stripped_line)
if e:
errors.append(e)
if errors:
with open(message_file, 'w') as commit_fd:
commit_fd.write('%s\n' % '# GIT COMMIT MESSAGE FORMAT ERRORS:')
for error in errors:
commit_fd.write('# %s\n' % (error,))
for line in commit_msg:
commit_fd.write(line)
re_edit = raw_input('Invalid git commit message format. Press y to edit and n to cancel the commit. [y/n]')
if re_edit.lower() in ('n','no'):
sys.exit(1)
call('%s %s' % (editor, message_file), shell=True)
continue
break
+0
检查消息的右钩是'commit-msg',而不是'pre-commit';这就是链接的博客帖子使用的内容。 – Nickolay
相关问题
- 1. IntelliJ提交50个字符的行长提醒
- 2. 如何在Selenium Grid中执行50/50并行测试
- 3. 如何在ajax提交中执行Html.ValidationSummary?
- 4. ng-repeater执行每个摘要周期
- 5. 执行中摘录
- 6. 开始......每隔50行提交一次
- 7. 如何在每行有来自textarea的50个字符时保留换行符?
- 8. 如何在Sublime Text 2(Windows)中执行/运行Ruby代码?
- 9. 如何在字符串中执行sql
- 10. 如何执行提交表单验证
- 11. 如何执行表单提交?
- 12. Python插入新行,如果行有超过50个字符
- 13. 如何让git合并包含每个提交的摘要?
- 14. 推迟angularjs后看执行$摘要(提高DOM事件)
- 15. 提交按钮,在CodeIgniter中执行PHP
- 16. 如何从Sublime Text在命令提示符下运行C++?
- 17. 如何在Tensorflow中编写多个运行摘要
- 18. 如何在Delphi/Pascal中执行多行逐字字符串
- 19. 如何为github PR提交强制执行提交消息?
- 20. Sublime/Git正在添加和删除提交中的空行
- 21. 为什么AngularJS在每个摘要循环上执行函数?
- 22. 如何在Java中执行两个命名为regex的字符类的交集?
- 23. 如何在fpdf中执行换行符
- 24. 在PHP中执行一个字符串
- 25. 如何使用动态绑定在AspxGridView中执行页脚摘要和组摘要?
- 26. 摘要SQL中的行
- 27. 哪个提交摘樱桃
- 28. 创建摘要行
- 29. 执行JavaScript之前提交
- 30. SVN提交后不执行
你可以创建一个after commit hook来强制执行它,但它真的值得吗? – phoet
A * pre * -commit hook似乎是要走的路。 after(* post * - )提交挂钩无法执行任何操作。 – larsks
祝贺你保持你的问题的文本简短:) – jtheletter