当前位置: 首页 > news >正文

GIT | git提交注释自动添加信息头

GIT | git提交注释自动添加信息头


时间:2024年9月6日10:20:11

文章目录

  • GIT | git提交注释自动添加信息头
    • 1.操作
    • 2.commit-msg文件

1.操作

在这里插入图片描述


在这里插入图片描述

2.commit-msg文件

在这里插入图片描述

#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message.  The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit.  The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"# This example catches duplicate Signed-off-by lines.####test "" = "$(grep '^Signed-off-by: ' "$1" |
####     sort | uniq -c | sed -e '/^[   ]*1[    ]/d')" || {
####    echo >&2 Duplicate Signed-off-by lines.
####    exit 1
####}# 获取当前变更号(变更号存放在根目录version文件内,具体位置根据自己情况)
# 每个分支都有独立且固定的系统变更号,所以此处以文件格式存放在代码目录
# 合并的时候可能有冲突,处理一次就好
#version=$(head -n +1 version)
# 获取当前分支
line=$(head -n +1 .git/HEAD)
#branch=${line##*/}
branch=$(git rev-parse --abbrev-ref HEAD)# 获取当前提交的日期
date_time=$(date +%Y%m%d)
# 获取当前分支中的提交数
commit_count=$(git rev-list --count HEAD)
commit_count=$((commit_count + 1))# 设置用户名
#name=flyer
commit=[" "${branch}" "]" "#${date_time}-${commit_count}#" "$(cat $1)
echo "$commit" > "$1"
http://www.lryc.cn/news/432728.html

相关文章:

  • React 全屏问题解决方案
  • Java JVM 垃圾回收算法详解
  • hadoop dfs web页面访问增加鉴权
  • LCP 485. 最大连续 1 的个数[lleetcode -11]
  • 关于宏任务的说法已经过时
  • Java箱与泛型
  • QT如何判断一个文件是否存在
  • Vim笔记
  • 宝塔部署Vue项目解决跨域问题
  • C++智能指针简述
  • 龙芯+FreeRTOS+LVGL实战笔记(新)——05部署主按钮
  • Android Camera系列(二):TextureView+Camera
  • DFS算法专题(一)——二叉树中的深搜【回溯与剪枝的初步注入】
  • AWS SES服务 Golang接入教程(排坑版)
  • Vite + Vue3 +Vant4出现Toast is not a function
  • 【MATLAB】模拟退火算法
  • 什么是Kubernetes RBAC?
  • 在Spring Boot中通过自定义注解、反射以及AOP(面向切面编程)
  • 安防监控视频平台LntonAIServer视频智能分析平台新增视频质量诊断功能
  • vscode从本地安装插件
  • Superset二次开发之新增复选框Checkbox筛选器
  • PromQL 语法
  • 掌握Go语言中的时间与日期操作
  • 4G模块、WIFI模块、NBIOT模块通过AT指令连接华为云物联网服务器(MQTT协议)
  • spring数据校验Validation
  • Uniapp基于uni拦截器+Promise的请求函数封装
  • 【工具】使用 Jackson 实现优雅的 JSON 格式化输出
  • ApacheKafka中的设计
  • .NET 自定义过滤器 - ActionFilterAttribute
  • VMware Fusion Pro 13 for Mac虚拟机软件