哪个着陆页网站,陕西建设官方网站,设计师培训有哪些课程,推广公司有哪些公司我写了一个C程序#xff0c;然后每次编译后#xff0c;记不得当时的版本是哪个源代码#xff0c;对于core dump复现调试很麻烦。
为此我想了一个办法#xff0c;首先在include/git_version.hpp 创建一个版本的文件
/** Description:* Author: jiangsheng* Date: 2024-01-…我写了一个C程序然后每次编译后记不得当时的版本是哪个源代码对于core dump复现调试很麻烦。
为此我想了一个办法首先在include/git_version.hpp 创建一个版本的文件
/** Description:* Author: jiangsheng* Date: 2024-01-11 10:59:53* LastEditors: jiangsheng* LastEditTime: 2024-01-11 20:07:28*/
#ifndef __JS_GIT_VERSION__H
#define __JS_GIT_VERSION__H
#include iostream
namespace JS_GIT_VERSION
{
const char *VERSION_STRING v1.5.1;
void cout_version()
{std::cout VERSION_STRING VERSION_STRING std::endl;
}
}; // namespace JS_GIT_VERSION
#endif然后在单例模式下上来就调用cout_version()函数这样一启动就有输出我就知道现在是哪个版本号。
然后我在master分支和develop分支之间 每次master发布版本号 都写上比当前tag大的版本号
例如最新tag是V1.5.1那么我下次就写V1.5.2 或者 V1.6什么的。
然后我在develop分支下 需要判断一下 最后push时候的HPP里头记录的TAG是否不等于git tag里头的TAG这样就可以保证自己不会忘记更新HPP文件里的TAG就直接push了。
然后master分支pull request develop的代码这样在发布新版本时候 只要指定的版本和刚刚代码HPP里头的版本一致就可以了
下面是pre-push的代码
#!/bin/bash
while read local_ref local_sha remote_ref remote_sha
doif [ $remote_ref refs/heads/develop ]; then# Get the latest version number from the git_version.hpp filecurrent_version$(grep -oP const char \*VERSION_STRING \K[^] include/git_version.hpp)echo hpp version : $current_version# Get the latest tag on the develop branchlatest_tag$(git tag -l --sort-v:refname | head -n 1)if [ $? -ne 0 ]; thenecho Error getting latest tag: $latest_tag# Continue with the push even if tag retrieval failscontinuefiecho git tag: $latest_tagif [ -n $latest_tag ] [ $latest_tag $current_version ]; thenecho 版本号未更新停止上传exit 1elseecho 保存的版本号与上传版本号不同允许上传fifi
done