git - 如何在网络核心解决方案中设置常规提交?
问题描述
我使用(带有 husky 包的常规提交,以确保提交名称在我的 Angular 前端应用程序中遵循正确的格式。我如何在 microsoft net core 解决方案中设置它,基于我需要 package.json 才能工作?
解决方案
您可以直接从命令行使用 dotnet 工具,并通过 NuGet 包添加到项目中。
..或者为 pre-commit 或 post-commit 钩子设置触发器,在你自己的 hidden.git/hooks
中,你可以创建自己的 commit-msg 以使用正则表达式强制执行常规提交消息。
这可能是提交消息文件中的 bash 脚本:
#!/usr/bin/env bash
if ! head -1 "$1" | grep -qE "^(feat|fix|ci|chore|docs|test|style|refactor)(\(.+?\))?: .{1,}$"; then
echo "Aborting commit. Your commit message is invalid." >&2
exit 1
fi
if ! head -1 "$1" | grep -qE "^.{1,50}$"; then
echo "Aborting commit. Your commit message is too long." >&2
exit 1
fi
您可以在 MSBuild 项目复制任务上自动执行消息提交的副本。
<Target Name="CopyCustomContent" AfterTargets="AfterBuild">
<ItemGroup>
<_CustomFiles Include="..\automation\commit-msg" />
</ItemGroup>
<Copy SourceFiles="@(_CustomFiles)" DestinationFolder="./../.git/hooks" />
</Target>
推荐阅读
- haskell - 传递可选构建参数时,从 GitHub 构建 Haskell nix 表达式失败
- vue.js - Vuetify v-carousel 多个组件
- r - 用ggplot制作条形图但不显示条形
- python - 使用过滤器绘制值 - Matplotlib 不支持生成器作为输入
- node.js - 数据库客户端抽象
- c# - 无法将新脚本添加到 Unity3d 中的对象
- python-3.x - 单击时如何打印从列表创建的标签中的文本
- snowflake-cloud-data-platform - 无法使用 EC2 上新创建的 Airflow 环境连接到 Snowflake
- javascript - 如何根据 textContent 值更改每个标签的 CSS 类
- angular - Angular中的bulma scss变量自定义