我想創建一個git的前提交鉤子,編輯我的.h和.m文件的頂部的評論。我想更改x代碼添加的標題註釋,以包含應用程序版本和許可證信息。這在更改爲新版本時會很有幫助。使用git鉤子來添加許可證和應用程序版本來評論在源文件的頂部
這是我創建的X代碼的文件,它會自動插入的文本:
//
// 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,然後它將使用新版本更新所有其他文件,並更改任何新文件以獲得正確的標題文本。這似乎可能是有用的。
爲什麼它需要成爲'git commit'的一部分,而不是作爲構建或其他腳本的一部分來完成的? – trojanfoe
好吧,我想如果使用構建腳本完成它會更好,因爲那樣它就可以使用應用程序設置中的應用程序版本。我沒有被綁在git鉤子上。我認爲一個鉤子可能會更好,所以它不會在我每次構建時都運行,只有當我承諾生產分支時纔會運行。我只是對劇本有不同的看法。 –
問題是,版本很少發生變化,當它發生時,需要由開發人員有意識地設置(例如,bugfix元素增加,次要版本增加或主要版本增加)。所以你可能想創建一個腳本並運行'set_version.sh X.Y.Z'作爲開發的一部分。 – trojanfoe