我正在尝试为 git 创建一个预提交挂钩,用于编辑每个 .h 和 .m 文件顶部的注释。我想更改 x-code 添加的标题注释以包含应用程序版本和许可证信息。这在更改为新版本时会很有帮助。
这是我在 x-code 中创建文件时自动插入的文本:
//
// myFile.h
// myApp
//
// Created by Developer on 11/13/12.
// Copyright (c) 2012 myCompany LLC. All rights reserved.
//
我想把钩子改成这样:
/*
myFile.h
myApp
Version: 1.0
myApp is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation,
either version 2 of the License, or (at your option) any later version.
myApp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with myApp.
If not, see <http://www.gnu.org/licenses/>
Copyright 2012 myCompany. All rights reserved.
This notice may not be removed from this file.
*/
我在想我会有一个文本文件,其中包含我想要更改的标题文本。或者检测应用程序版本号何时更改。当使用新版本号和 git 更新此文件时,我会执行 git commit,然后它将使用新版本更新所有其他文件并更改任何新文件以具有正确的标题文本。这似乎很有用。