python - 手动对 python 目录进行排序,然后无法推送到远程存储库

标签 python python-3.x pre-commit-hook pre-commit.com isort

我正在尝试将 isortblackflake8 添加到我的项目的 pre-commit Hook 中,它当我编辑一个文件时工作正常。

我想要实现的是通过isort -rc .isort项目的一个目录并将更改推送到远程存储库,但它给了我一切都起来-to-date 但当我检查 git status 时,它会显示所有修改。

有人可以帮我看看我做错了什么吗?下面我发布屏幕截图和代码片段。谢谢!

enter image description here •100% ➜ git 状态 在分支上 2020-01-29-测试预提交 您的分支已更新为“origin/2020-01-29-test-pre-commit”。

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
    modified:   athlete_report/algorithm/yazs/cc_calculation_copy.py
    modified:   athlete_report/algorithm/yazs/dto/session_event.py
    modified:   athlete_report/algorithm/yazs/formula/flow_processor.py
    modified:   athlete_report/algorithm/yazs/input/flow_input_processor.py
    modified:   athlete_report/algorithm/yazs/input/single_source_handler.py
    modified:   athlete_report/algorithm/yazs/input/two_sources_handler.py
    modified:   athlete_report/algorithm/yazs/vertical_jump/vert_jump.py
    modified:   athlete_report/algorithm/yazs/yazs_calculation.py
    modified:   athlete_report/pdf_generator/athlete_report_builder.py

(mbp37)
src on  2020-01-29-test-pre-commit [+] via 🅒 mbp37
•100% ➜ git add .
(mbp37)
src on  2020-01-29-test-pre-commit [+] via 🅒 mbp37
•100% ➜ git commit -am "add modifications to athlete report"
seed isort known_third_party.............................................Passed
isort....................................................................Failed
- hook id: isort
- files were modified by this hook

Fixing /Users/hzhang/Work/yana-motion-lab/report-engine/src/athlete_report/pdf_generator/athlete_report_builder.py

black....................................................................Failed
- hook id: black
- files were modified by this hook

reformatted /Users/hzhang/Work/yana-motion-lab/report-engine/src/athlete_report/pdf_generator/athlete_report_builder.py
All done! ✨ 🍰 ✨
1 file reformatted, 8 files left unchanged.

Flake8...................................................................Passed
(mbp37)
src on  2020-01-29-test-pre-commit [+] via 🅒 mbp37 took 3s
•100% ➜ git diff
(mbp37)
src on  2020-01-29-test-pre-commit [+] via 🅒 mbp37
•100% ➜ git push
Everything up-to-date
(mbp37)
src on  2020-01-29-test-pre-commit [+] via 🅒 mbp37 took 2s
•100% ➜ git diff

最佳答案

由于预提交进行了更改,因此提交被取消(因为提交的内容不正确)

您需要查看所做的更改(git status/git diff),如果工具所做的自动更改看起来正确,您将git add -u 并重新运行您的 git commit 命令(^R + git commit 在这里可能会有所帮助)

没有提交要推送,因为提交已取消

关于python - 手动对 python 目录进行排序,然后无法推送到远程存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59991093/

相关文章:

python - 将 python 代码的标准输出重定向到文件而不让 python 保持锁定

python ,Seaborn : Plotting frequencies with zero-values

python-3.x - TKinter 打开文件对话框有替代方案吗?

java - 在 java 中编写 GIT 预提交 Hook ?

python - 使用 NEOS 作为 Pyomo 求解器

python - 如何使用 Python 通过 SSL 连接到远程 PostgreSQL 数据库

python - 在 Pandas GroupBy 中查找组之间的重复值

python - 我在为模板渲染动态数据时遇到问题

svn - Subversion 工作流 : force update, 构建,提交前测试

api - 如何在 Mercurial 进程内 Hook 中访问提交消息?