From cb19750a9609e06bf135750c5b2f20a5db4e840c Mon Sep 17 00:00:00 2001 From: CalciteM Team Date: Sun, 18 Aug 2019 11:10:01 +0800 Subject: [PATCH] =?UTF-8?q?version:=20=E8=AE=A9=E5=8D=B3=E4=BE=BF=E4=B8=8D?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=20version.sh=20=E4=B9=9F=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 如何让已经纳入版本控制的 version.h 忽略脚本对其的修改? 参考: https://segmentfault.com/q/1010000000430426 --- NineChess/git_version.h.template | 1 - NineChess/include/.gitignore | 1 - NineChess/include/version.h | 16 ++++++++-------- NineChess/include/version.h.template | 12 ++++++++++++ NineChess/ninechess.pro | 4 +++- NineChess/ninechess.vcxproj | 2 +- NineChess/ninechess.vcxproj.filters | 2 +- NineChess/version.sh | 6 ++++-- 8 files changed, 29 insertions(+), 15 deletions(-) delete mode 100644 NineChess/git_version.h.template delete mode 100644 NineChess/include/.gitignore create mode 100644 NineChess/include/version.h.template diff --git a/NineChess/git_version.h.template b/NineChess/git_version.h.template deleted file mode 100644 index 0728327f..00000000 --- a/NineChess/git_version.h.template +++ /dev/null @@ -1 +0,0 @@ -static const char *versionNumber = "$FULL_VERSION"; \ No newline at end of file diff --git a/NineChess/include/.gitignore b/NineChess/include/.gitignore deleted file mode 100644 index 9b53678e..00000000 --- a/NineChess/include/.gitignore +++ /dev/null @@ -1 +0,0 @@ -git_version.h diff --git a/NineChess/include/version.h b/NineChess/include/version.h index 424c0db4..be00b1aa 100644 --- a/NineChess/include/version.h +++ b/NineChess/include/version.h @@ -1,8 +1,8 @@ -#ifndef VERSION_H -#define VERSION_H - -// Please generate git_version.h with version.sh - -#include "git_version.h" - -#endif // VERSION_H +#ifndef VERSION_H +#define VERSION_H + +// Please generate this file with version.sh + +static const char *versionNumber = "Unknown"; + +#endif /* VERSION_H */ \ No newline at end of file diff --git a/NineChess/include/version.h.template b/NineChess/include/version.h.template new file mode 100644 index 00000000..fb82353d --- /dev/null +++ b/NineChess/include/version.h.template @@ -0,0 +1,12 @@ +/**************************************************************************** + * Created by: version.sh + * + * WARNING! All changes made in this file will be lost! + ****************************************************************************/ + +#ifndef VERSION_H +#define VERSION_H + +static const char *versionNumber = "$FULL_VERSION"; + +#endif /* VERSION_H */ diff --git a/NineChess/ninechess.pro b/NineChess/ninechess.pro index f2ccd6b7..5b353df1 100644 --- a/NineChess/ninechess.pro +++ b/NineChess/ninechess.pro @@ -35,6 +35,7 @@ SOURCES += \ HEADERS += \ include/config.h \ include/version.h \ + include/version.h.template \ src/HashNode.h \ src/MemoryPool.h \ src/MemoryPool.tcc \ @@ -66,7 +67,8 @@ DISTFILES += \ ../Readme.md \ ../Sample.txt \ ../History.txt \ - ../Licence.txt + ../Licence.txt \ + version.sh RC_FILE += NineChess.rc diff --git a/NineChess/ninechess.vcxproj b/NineChess/ninechess.vcxproj index 03510890..94ad5ae4 100644 --- a/NineChess/ninechess.vcxproj +++ b/NineChess/ninechess.vcxproj @@ -536,7 +536,7 @@ - + diff --git a/NineChess/ninechess.vcxproj.filters b/NineChess/ninechess.vcxproj.filters index 92d744d1..6042b39f 100644 --- a/NineChess/ninechess.vcxproj.filters +++ b/NineChess/ninechess.vcxproj.filters @@ -272,7 +272,7 @@ Model - + Header Files diff --git a/NineChess/version.sh b/NineChess/version.sh index afb618dc..74930707 100644 --- a/NineChess/version.sh +++ b/NineChess/version.sh @@ -1,7 +1,7 @@ #!/bin/bash -VERSION_H=include/git_version.h -TEMPLATE_FILE=git_version.h.template +VERSION_H=include/version.h +TEMPLATE_FILE=include/version.h.template GIT_BRANCH=master rm -f $VERSION_H @@ -29,6 +29,8 @@ rm -f config.git-hash cat $TEMPLATE_FILE | sed "s/\$FULL_VERSION/$GIT_VERSION/g" > $VERSION_H +git update-index --assume-unchanged $VERSION_H + echo "Generated $VERSION_H" echo cat $VERSION_H