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

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.kler.cn/news/293466.html

相关文章:

  • echarts动态切换数据渲染(vue3 + echarts)
  • 5G移动网络运维实验(训)室解决方案
  • 逻辑回归与线性回归的目标函数和应用场景比较
  • 坐牢第三十六天(QT)
  • iOS——Block与内存管理
  • Kafka 实战演练:创建、配置与测试 Kafka全面教程
  • 《Python爬虫逆向实战》加密方法远程调用(RPC)
  • TRIZ在充电桩安全中的应用探究
  • Java 入门指南:Java 并发编程 —— Fork/Join 框架 实现任务的拆分与合并
  • 探索PDF的奥秘:pdfrw库的神奇之旅
  • 2024,中国服务器操作系统迎云智主升浪
  • 鸿蒙开发5.0【高级图表实现】 解决方案
  • c++的类和对象
  • vue-seamless-scroll(二)点击事件
  • 为什么深度学习用GPU而不是CPU
  • electron 客户端 windows linux(麒麟V10)多系统离线打包 最新版 <二>
  • FPGA开发:Verilog基础语法
  • 如何进行不同数据库的集群操作?--从部署谈起,今天来看MySQL和NoSql数据库Redis的集群
  • FFMPEG -- 音频开发
  • 初识命名空间
  • S7-PLC
  • 安装win7鼠标键盘不能动原因分析及解决办法
  • 【AI学习】聊两句深度学习的目标函数
  • 计算机网络27——Linux1
  • 黑马JavaWeb开发笔记14——Tomcat(介绍、安装与卸载、启动与关闭)、入门程序解析(起步依赖、SpringBoot父工程、内嵌Tomcat)
  • EmguCV学习笔记 VB.Net 10.2 人脸识别 FaceRecgnizer类
  • 基于C++实现一个房贷计算小程序(含代码)
  • C++---由优先级队列认识仿函数
  • 《OpenCV计算机视觉》—— 图像形态学(腐蚀、膨胀等)
  • OpenGL GLFW OIT 实现