【问题标题】:Pycharm, django south migration files and git integrationPycharm、django南迁移文件和git集成
【发布时间】:2014-08-18 16:42:55
【问题描述】:

如你所知,django南迁移文件是通过下面的命令生成的;

# python manage.py schemamigration model_name --auto

有时,我忘记将迁移文件添加到项目存储库。

有没有办法在将其他项目文件提交到存储库之前,在pycharm中显示手动生成的迁移文件添加git repo的提醒?

【问题讨论】:

  • 我认为没有。 PyCharm 在“项目文件”列表中使用红色显示新文件。
  • 我知道它可以将新文件显示为红色,但迁移文件位于子文件夹下。我忘记了它们,因为如果没有展开子文件夹,我看不到它们。
  • 你可以编写预提交钩子来检查是否有一些未跟踪的文件,如果是 - 中止提交。 How to forbid git commit if there are untracked files?

标签: python git pycharm django-south


【解决方案1】:

根据 pancakes 的评论,我启用了 pre-commit 钩子并在下面追加行:

ud=`git status -u | grep '^Untracked files:$'`

if [ -n "$ud" ];
then 
        cat <<\EOF 
Warning: There are new files exists and not added to project repo.
EOF
        exit 1
fi

现在,git 在新文件可用时发出警告,并在提交前中断进程。这也适用于带有错误弹出窗口的 PyCharm。

【讨论】:

    猜你喜欢
    • 2017-10-17
    • 2011-09-28
    • 2011-04-03
    • 1970-01-01
    • 2012-06-05
    • 2019-02-14
    • 2014-05-02
    • 2014-06-22
    相关资源
    最近更新 更多