有没有一种方法使用预提交挂钩时获得git的承诺--verbose显示更新的差异?

问题描述 投票:2回答:1

所以我目前正在设立一个Git pre-commit钩子来lint以iSort我的Python文件,蟒蛇黑,我跑入的问题是,当我使用git commit --verbose的差异,在提交编辑器显示了没有实际上采取的修改上演文件考虑在内。

例如,可以说我有一个Python文件,看起来像这样:

import re

from os import path

def x():
    v = re.compile(r"1")
    print(3, v)

def y(v=3):
    z = path.join("a", "b")
    thing = "a string"
    print(thing, z)

基于该iSort和黑色的设置我已经配置了,我的预提交脚本将改变这个文件,看起来像这样:

import re
from os import path


def x():
    v = re.compile(r"1")
    print(3, v)


def y(v=3):
    z = path.join("a", "b")
    thing = "a string"
    print(thing, z)

不幸的是在git的承诺编辑它仍然显示未改性的差异。有没有办法让编辑器有正确的输出?

理论上,我想这并不重要,但它会很高兴地看到什么差异实际上是。

python git commit verbose python-black
1个回答
0
投票

取而代之的是pre-commit钩子的,而不是尝试一个内容过滤驱动程序,用涂抹/洁净脚本里面:

  • 结账使你的脚本的一种方式
  • 在提交(或git的差异),使你的脚本的其他方式

看到example here(for clean) here

https://i.stack.imgur.com/tumAc.png (图像从"Customizing Git - Git Attributes"从 “Pro Git book”))

© www.soinside.com 2019 - 2024. All rights reserved.