【问题标题】:Checking comments in code for messages before committing with Git在使用 Git 提交之前检查代码中的注释以获取消息
【发布时间】:2015-02-07 09:52:03
【问题描述】:

如果在本地开发时经常发现自己在代码中写出有用的信息。看这段代码 sn-p 作为一个简单的例子:

# Public API
namespace :api do
  namespace :v1 do
    # REMOVE THE FIRST LINE WHEN DONE TESTING
    get :delivery_report, to: 'delivery_report#index'
    post :delivery_report, to: 'delivery_report#index'
  end
end

这里的重点是,当我完成并且我觉得我终于可以提交我的工作时,我需要记住我必须删除 get :delivery_report, to: 'delivery_report#index' 这一行

是否有可能在接受提交之前或暂存之前告诉 git,它应该警告我代码中包含某些内容的行?在这种情况下,这将是我的评论或任何其他预定义的行。

【问题讨论】:

    标签: linux macos git git-commit pre-commit


    【解决方案1】:

    Git 支持“预提交挂钩”,您可以在其中测试用户建议提交的内容,并在某些条件适用时强制提交失败。

    git pre-commit hook code formatting with partial commit?How do I properly git stash/pop in pre-commit hooks to get a clean working tree for tests?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-24
      • 2013-11-02
      • 1970-01-01
      • 2013-08-18
      • 2012-05-04
      • 2012-04-07
      • 2011-07-20
      • 2013-05-08
      相关资源
      最近更新 更多