gpt4 book ai didi

git - 使用 git hook 添加许可证和应用程序版本以在源文件顶部注释

转载 作者:太空狗 更新时间:2023-10-29 13:15:19 25 4
gpt4 key购买 nike

我正在尝试为 git 创建一个预提交 Hook ,用于编辑我的每个 .h 和 .m 文件顶部的注释。我想更改 x-code 添加的标题注释以包含应用程序版本和许可证信息。这在更改为新版本时会很有帮助。

这是我在 x-code 中创建文件时自动插入的文本:

//
// myFile.h
// myApp
//
// Created by Developer on 11/13/12.
// Copyright (c) 2012 myCompany LLC. All rights reserved.
//

我希望钩子(Hook)将其更改为:

/*

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 时,它将使用新版本更新所有其他文件并更改所有新文件以具有正确的标题文本。这似乎很有用。

最佳答案

使用smudge/clean filters (整章,最仔细地链接“关键字扩展”)?

关于git - 使用 git hook 添加许可证和应用程序版本以在源文件顶部注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14419517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com