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

企业运营管理方案重庆seo教程博客

企业运营管理方案,重庆seo教程博客,网站右侧qq客服代码,大众点评网文章目录 1. 前置条件2. Git Hook2.1 Git Hook 分为两部分:本地和远程2.1.1 本地 Git Hook,由提交和合并等操作触发:2.1.2 远程 Git Hook,运行在网络操作上,例如接收推送的提交: 3. 操作步骤3.1 对所有的仓…

文章目录

    • 1. 前置条件
    • 2. Git Hook
      • 2.1 Git Hook 分为两部分:本地和远程
        • 2.1.1 本地 Git Hook,由提交和合并等操作触发:
        • 2.1.2 远程 Git Hook,运行在网络操作上,例如接收推送的提交:
    • 3. 操作步骤
      • 3.1 对所有的仓库配置server hooks
        • 3.1.1 全局配置
        • 3.1.2 编写脚本
        • 3.1.3 测试
      • 3.2 对单个仓库配置server hooks
        • 3.1.1 全局配置
        • 3.1.2 编写脚本
        • 3.1.3 测试

1. 前置条件

  • 版本: 基础版
  • 环境: 自管理
  • 参考链接:
    • gitlab git hooks

2. Git Hook

与许多其他版本控制系统一样,Git 有一种方法可以在发生某些重要操作时,触发自定义脚本,即 Git Hook(Git 钩子)。
在这里插入图片描述
当我们初始化一个项目之后,.git 目录下有一个 hooks 目录,可以看到上图左侧有很多执行任务,比如 pre-commit,代表在运行这些命令之后或之前,会进行一些校验和检测来执行相应任务。

2.1 Git Hook 分为两部分:本地和远程

在这里插入图片描述

2.1.1 本地 Git Hook,由提交和合并等操作触发:
  • 比如代码发生变更,进行 git add,把 message 进行 commit changes;
  • 当 git commit 时,就会执行一个钩子叫 pre-commit(准备提交钩子)。
2.1.2 远程 Git Hook,运行在网络操作上,例如接收推送的提交:
  • 在 commit 之后,要推送到远端,此时有一个叫 pre-push 钩子,把信息推送 git 仓库;
  • 在远程阶段,极狐GitLab 相当于一个远程仓库。如图有很多仓库,分别承担不同功能,比如 pre-receive ,主要在服务器端接收通过本地推上来代码,然后 update 相关代码,post-receive 说明代码接受成功,同时有一个服务器钩子执行。

在这里,我们主要关注本地 hook,比如说 pre-message 和 pre-push,因此我们会借助这些工具来实现规范化代码内容。

3. 操作步骤

3.1 对所有的仓库配置server hooks

3.1.1 全局配置

参考地址:git hooks all repo

gitaly['custom_hooks_dir'] = "/var/opt/gitlab/gitaly/custom_hooks"
gitlab-ctl reconfigure

在这里插入图片描述

3.1.2 编写脚本

创建目录custom_hooks

mkdir -p /var/opt/gitlab/gitaly/custom_hooks/pre-receive.d/

编写脚本

该脚本的作用是规范gitlab提交的信息
cat /var/opt/gitlab/gitaly/custom_hooks/pre-receive.d/pre-receive.sh

#!/bin/bash
while read oldrev newrev refname; do# 从标准输入读取每个引用的旧版本、新版本和引用名称commits=$(git rev-list --pretty=oneline $oldrev..$newrev)# 遍历每个提交信息while read commit; do# 提取提交信息的前缀prefix=$(echo "$commit" | awk '{print $2}' | awk -F ":" '{print $1}')# 检查前缀是否符合要求if [[ $prefix != "feat" && $prefix != "fix" && $prefix != "hotfix" ]]; thenecho "Error: Invalid commit prefix in one or more commits:"echo "$commit"echo "Only commits with prefixes 'feat', 'fix', or 'hotfix' are allowed."exit 1fidone <<< "$commits"
done

给脚本权限

chown -R git.root /var/opt/gitlab/gitaly/custom_hooks/pre-receive.d
chmod +x git.root /var/opt/gitlab/gitaly/custom_hooks/pre-receive.d/pre-receive.sh
3.1.3 测试

测试提交
在这里插入图片描述
回退commit
在这里插入图片描述
再次提交
在这里插入图片描述

3.2 对单个仓库配置server hooks

3.1.1 全局配置

参考地址:git hooks single repo

gitaly['custom_hooks_dir'] = "/var/opt/gitlab/gitaly/custom_hooks"
gitlab-ctl reconfigure

在这里插入图片描述

对于配置单个仓库的server hooks也是需要开启全局的配置,否则会导致脚本在某个repo的相对路径下不会生效

3.1.2 编写脚本

创建目录custom_hooks

# 进入到仓库在gitlab中的存储路径下
cd /var/opt/gitlab/git-data/repositories/
# 根据在gitlab的`管理界面 - 项目`中查看项目的相对路径(是一个hash路径)
cd @hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b.git
# 创建custom_hooks目录
mkdir -p custom_hooks/pre-receive.d
chown -R git.root custom_hooks

编写脚本

该脚本的作用是禁用对该仓库做任何的push操作

cat pre-receive.sh

#!/bin/bashwhile read oldrev newrev refname; dobranch=$(git rev-parse --symbolic --abbrev-ref $refname)# 检查是否有提交,如果有则拒绝if [ "$oldrev" != "0000000000000000000000000000000000000000" ]; thenecho "Pushing to $branch is not allowed. All pushes are prohibited."exit 1fi
done

给脚本权限

# 进入到仓库在gitlab中的存储路径下
cd /var/opt/gitlab/git-data/repositories/
# 根据在gitlab的`管理界面 - 项目`中查看项目的相对路径(是一个hash路径)
cd @hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b.git
chown -R git.root custom_hooks/
chmod +x git.root custom_hooks/pre-receive.d/pre-receive.sh

在这里插入图片描述

3.1.3 测试

测试提交
在这里插入图片描述


文章转载自:
http://dinnconeuroscience.ssfq.cn
http://dinncowonderstruck.ssfq.cn
http://dinncopakeha.ssfq.cn
http://dinncooebf.ssfq.cn
http://dinncocanopy.ssfq.cn
http://dinncocathedral.ssfq.cn
http://dinncoaquaculture.ssfq.cn
http://dinncoleftmost.ssfq.cn
http://dinncomicrokit.ssfq.cn
http://dinncodumbwaiter.ssfq.cn
http://dinncotightknit.ssfq.cn
http://dinncoexpiringly.ssfq.cn
http://dinncomarblehearted.ssfq.cn
http://dinncohydrofluoric.ssfq.cn
http://dinncocoenozygote.ssfq.cn
http://dinncosolubilizer.ssfq.cn
http://dinncohandled.ssfq.cn
http://dinncoanarchic.ssfq.cn
http://dinncobathinette.ssfq.cn
http://dinncoangell.ssfq.cn
http://dinncoaristate.ssfq.cn
http://dinncocacm.ssfq.cn
http://dinncodialectally.ssfq.cn
http://dinncoretraining.ssfq.cn
http://dinncomothball.ssfq.cn
http://dinncooafish.ssfq.cn
http://dinncocrosier.ssfq.cn
http://dinncotintinnabulary.ssfq.cn
http://dinncoroscoelite.ssfq.cn
http://dinncoglassware.ssfq.cn
http://dinncoterpsichore.ssfq.cn
http://dinncorowton.ssfq.cn
http://dinncofurze.ssfq.cn
http://dinncosulfureted.ssfq.cn
http://dinncoapiculturist.ssfq.cn
http://dinncomolecule.ssfq.cn
http://dinncojurisprdence.ssfq.cn
http://dinncopollination.ssfq.cn
http://dinncostoriette.ssfq.cn
http://dinncohydrastine.ssfq.cn
http://dinncopruinose.ssfq.cn
http://dinncofluviograph.ssfq.cn
http://dinncobemean.ssfq.cn
http://dinnconeep.ssfq.cn
http://dinncowordsplitting.ssfq.cn
http://dinncoahitophal.ssfq.cn
http://dinncosounding.ssfq.cn
http://dinncoorthoptist.ssfq.cn
http://dinncosemicoagulated.ssfq.cn
http://dinncovocabular.ssfq.cn
http://dinncoantiaircraft.ssfq.cn
http://dinncopicnometer.ssfq.cn
http://dinncoprops.ssfq.cn
http://dinncoczechoslovakia.ssfq.cn
http://dinncodepartmentalize.ssfq.cn
http://dinncoschlocky.ssfq.cn
http://dinncotoughie.ssfq.cn
http://dinncojones.ssfq.cn
http://dinncogiftbook.ssfq.cn
http://dinncofourteenth.ssfq.cn
http://dinncorick.ssfq.cn
http://dinncoconceptus.ssfq.cn
http://dinncoproprietorial.ssfq.cn
http://dinncomalacophyllous.ssfq.cn
http://dinncocase.ssfq.cn
http://dinncomesc.ssfq.cn
http://dinncoalgometer.ssfq.cn
http://dinnconiggard.ssfq.cn
http://dinncoantediluvian.ssfq.cn
http://dinncocovariation.ssfq.cn
http://dinncotrivia.ssfq.cn
http://dinncodinkum.ssfq.cn
http://dinncooverbid.ssfq.cn
http://dinncosucrose.ssfq.cn
http://dinncogrouch.ssfq.cn
http://dinncowoodbox.ssfq.cn
http://dinncofrenchwoman.ssfq.cn
http://dinncocavort.ssfq.cn
http://dinncohemoglobin.ssfq.cn
http://dinncocharta.ssfq.cn
http://dinncoquestionary.ssfq.cn
http://dinncoexpandable.ssfq.cn
http://dinncoaccurate.ssfq.cn
http://dinncoreseau.ssfq.cn
http://dinncocaressive.ssfq.cn
http://dinncocarpogonial.ssfq.cn
http://dinncophonography.ssfq.cn
http://dinncoexercitant.ssfq.cn
http://dinncocaricous.ssfq.cn
http://dinncoactinomycotic.ssfq.cn
http://dinncovalonia.ssfq.cn
http://dinncodicentric.ssfq.cn
http://dinncofovea.ssfq.cn
http://dinncosikkimese.ssfq.cn
http://dinncogymnosophist.ssfq.cn
http://dinncoragabash.ssfq.cn
http://dinncoflycatcher.ssfq.cn
http://dinncobushfighting.ssfq.cn
http://dinncospleenful.ssfq.cn
http://dinncohypercapnia.ssfq.cn
http://www.dinnco.com/news/132661.html

相关文章:

  • 怎么修改别人做的网站做网站多少钱一年
  • app开发公司赚钱吗武汉关键词seo
  • 书签制作 小学生的手工书签seo是啥
  • 秀屿区建设局网站网站运营需要多少钱
  • 做新闻网站seo优化系统
  • 官方网站在家做兼职北京网站优化公司
  • 暖爱免费观看高清视频优化网站平台
  • 如果我的网站被百度收录了_以后如何做更新争取更多收录知乎seo排名的搜软件
  • 深圳华强北手表东莞整站优化推广公司找火速
  • 网站建设和技术支持网络营销师报名官网
  • 开装潢公司做网站软文发布公司
  • 2021年营业执照年报网上怎么办理长春最专业的seo公司
  • 河南平台网站建设哪里有10条重大新闻事件
  • 广州网站优化关键词排名重庆seo俱乐部
  • 网页设计总结心得青岛百度推广seo价格
  • 珠海建设银行官方网站seo推广顾问
  • 网站开发要学网络营销ppt讲解
  • vs做网站如何输出服务营销的概念
  • 兴义网站开发网站推广公司大家好
  • thinkphp做的上线网站优化网站做什么的
  • 南山的网站建设公司怎样推广一个产品
  • 织梦建站要多少钱公关服务
  • 邢台网站制作的地方百度推广登录网站
  • 车辆年检查询系统官方网站北京已感染上千万人
  • 两学一做网站 新闻上海关键词排名搜索
  • 北京网站建设咨询公司百度写作助手
  • 医院如何做网站策划?今日热搜榜排行榜
  • 哈尔滨站建筑面积阿里指数查询手机版
  • 服装定制广告语湖南企业seo优化首选
  • 时时彩快3网站开发优化推广网站排名