Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,76 @@ Finally, we install the module itself.
1.2.3-alpha.1.2
```

## Conventional Commits
Benefits of Conventional Commits
1. Each commit message provides additional relevant information, making it easier to browse through the commit history quickly.
2. It allows for easy filtering of commits using git log --grep <keyword>, enabling fast searching for specific information.
3. Commit messages can be used to generate a Change log directly, summarizing the changes made in the project.

#### Conventional Commits consist of three parts: Header, Body, and Footer. The format is as follows:

```shell
<type>(<scope>): <subject>
<space>
<body>
<space>
<footer>
```
The Header is required, while the Body and Footer are optional.
#### Header
The header includes three parts: type, scope, and subject. Among them, scope is optional.
```shell
<type>(<scope>): <subject>

# example
feat(api)!: send an email to the customer when a product is shipped
```

"type" is used to specify the category of the commit, with specific identifiers as follows:

1. feat: A new feature;
2. fix: Bug fix;
3. docs: Document modifications, such as README.md, CHANGELOG.md, etc;
4. style: Code format changes that do not affect the operation of the code, such as spaces, code formatting, appending semicolons at the end of a sentence, etc;
5. refactor: Code refactoring, without adding new features or fixing bugs in code changes;
6. perf: Code optimization to improve performance;
7. test: Increasing tests or optimizing existing tests;
8. build: Changes affecting project build files or external dependencies, such as npm, gulp, webpack, broccoli, etc;
9. ci: Modifications to CI configuration files and scripts;
10. revert: Code rollback.

"scope" is used to specify the impact area of the commit, such as the data layer, control layer, view layer, etc., which vary from project to project. If your modification affects more than one scope, you can use * as a replacement.

"subject" is a brief description of the purpose of the commit, not exceeding 50 characters, and does not require a period at the end.

#### Body

The Body part is a detailed description of this commit and can be divided into multiple lines.

The Body part should explain the motivation for the code changes, as well as a comparison with the previous behavior.
```shell
# example
feat(api)!: send an email to the customer when a product is shipped

# below is the body
changes:
1. xxxxxxx
2. xxxxxxx
```
#### Footer

The Footer section is mainly used for two situations: incompatible changes and issue handling.
```shell
feat: allow provided config object to extend other configs

BREAKING CHANGE: `extends` key in config file is now used for extending other config files

# below is the footer
xxxxxxxxxxxx
xxxxxxxxxxxx
xxxxxxxxxxxx
```

### FAQs
#### How to use Xdebug?
1. Uncomment this line in `docker-compose.yml`:
Expand Down
35 changes: 35 additions & 0 deletions scripts/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Subject of the message.
commit_subject=$(head -1 "$1")

# Body of the message.
commit_body=$(sed -n '2,$p' "$1")

# Verify subject line.
commit_regex="^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?!?: .+"
error_msg="ERROR: The commit message does not follow the Conventional Commits 1.0.0 standard.
Please use format like: 'type(scope)!: Subject'
Type can be:
feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert
Scope is optional and can be anything specifying place of the commit change
The exclamation mark '!' is optional and indicates a breaking change"

if ! echo "$commit_subject" | grep -qE "$commit_regex"; then
echo "$error_msg" >&2
exit 1
fi

# Verify body of the submitted message.
footer_regex="^([A-Za-z][-A-Za-z0-9]*|BREAKING CHANGE|BREAKING-CHANGE)( |#).+"
if [[ -n "$commit_body" ]] && ! echo "$commit_body" | grep -qE "$footer_regex"; then
echo "ERROR: The footer of the commit message is not well-formed." >&2
exit 1
fi

# Check for significant changes.
breaking_change_footer=$(echo "$commit_body" | grep -E "^(BREAKING CHANGE|BREAKING-CHANGE): ")
if [[ "$commit_subject" == *'!'* ]] && [[ -z "$breaking_change_footer" ]]; then
echo "ERROR: The commit message indicates a breaking change but does not contain a 'BREAKING CHANGE:' or 'BREAKING-CHANGE:' footer." >&2
exit 1
fi
3 changes: 3 additions & 0 deletions scripts/drupal/install-new-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ drush -r ${APP}/${WEBROOT} si ${DRUPAL_PROFILE} -y --uri=${URI} --account-name=$
drush -r ${APP}/${WEBROOT} ublk --uri=${URI} 1
drush -r ${APP}/${WEBROOT} cr --uri=${URI} -y
drush -r ${APP}/${WEBROOT} --uri=${URI} php-eval "\$prefix = getenv('DRUPAL_MODULE_PREFIX'); if (\$prefix) { \$loaded = module_load_install(\$prefix . '_core'); if (\$loaded) { \$func = \$prefix . '_core_enable_modules'; \$func(TRUE); } }"

# Copy commit-msg to git hooks.
cp scripts/commit-msg .git/hooks/