Skip to main content

ihub-git-hooks

Henry...About 2 min

ihub-git-hooks

plugin information

  • ihub-git-hooksPlugins are used to configure GitHooks, available forgitoperations to configure hook commands like:to check code when submitting code.
  • Implement custom hook commands by modifying the git-hooks directory(git config core.hooksPath xxx) without destroying the original hooks.
Plugin IDPlugin NamePlugin TypeExtension Name
pub.ihub.plugin.ihub-git-hooksGitHooks PluginProject[^Project]iHubGitHooks

Submission information check

Plugins based oncontractual commitopen in new windowspecifications providecommit-msgcheck submissions featurefor detailsopen in new window, submit information instructions:

<type>[optional scope]: <description>

[opregular body]

[optional footer(s)]

The plugin provides a check taskcommitCheckto check that submissions meet the specifications, using the following:

#!/bin/cash
./gradlew commitCheck

can also be configured by extension attributes, seeExample

Tips

Support auto-generation in IDEA environmentConventional Commitopen in new windowIDEA plugin profileconventionalCommunity.jsonand complete autoconfiguration :
:::

Extended Properties

ExtensionDescriptionDefaultExt[^Ext]Prj[^Prj]Sys[^Sys]Env[^Env]
hooksPathCustom hooks path (high priority)
hooksCustom hooks
descriptionRegexSubmit description regexp/.{1,100}/

Note

If both hooks properties are not configured, use the default hooksdirectory :

DSL extension is supported below

Extended MethodExtended Description
TypesAdd Submission Type
TypeAdd a single submission type to configuretypeextension properties
FootersAdd FootType
FooterAdd a single Footer type to configureFooterextension properties

typeextension properties

Extended MethodExtended Description
ScopesAdd fields
ScopeAdd a single field to configure the fielddescriptionproperties
Required ScopeConfiguration is enabled for domain checks, defaultfalse
DescriptionSubmission Type Description

FooterExtension properties

Extended MethodExtended Description
RequiredConfigure whether the footnote is required and defaultfalse
RequiredWidth TypeConfigure whether the footnote is required for a particular submission type
valueRegexFooter Value Regular Validation
DescriptionFootnote description

Plugin Installation

Kotlin
plugins {
    id("pub.ihub.plugin.ihub-git-hooks")
}

Example custom hooks path usage

Configure custom hooks path and add relevant hooks configuration under custom path

iHubGitHooks.hooksPath=.hooks

Example plugin configuration usage

Extension configuration git-hooks command

Related hooks commands are configured under.gradle/pub.ihub.plugin.hooks

Kotlin
iHubGitHooks {
    hooks.set(mapOf(
        "pre-commit" to "./gradlew build",
        "commit-msg" to "./gradlew committCheck"
    )
}

Extended Configuration Submission Check

Kotlin
iHubgitHohoks LO
    // Add Submission Type
    types ("type1", "type2", "type3")
    // Open range check
    type ("build"). copes("gradle"). equiredScope(true)
    // Footer is required
    Footer("Footer"). equired(true)
    // Submission type is feature
    Footer("Footer"). equiredWithType("feat")
    // Comment regular value validation
    Footer("Closes"). alueRegex("\\d+")
    // Describe configuration 1
    type ("type"). cope("screen").description("Scope description")
    Footer("Other").description("Other description")
}