feat: 增加 post-commit 钩子;增加 README
This commit is contained in:
commit
265bf10495
8
README.md
Normal file
8
README.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
### post-commit
|
||||||
|
Script to ensure a tag for the current month exists.
|
||||||
|
每次提交时,检查是否存在当前月份的tag,如果不存在则创建一个。
|
||||||
|
|
||||||
|
#### usage
|
||||||
|
```shell
|
||||||
|
$ cp /path/to/your/git/hooks/post-commit /path/to/your/git/repo/.git/hooks/
|
||||||
|
```
|
||||||
21
post-commit
Normal file
21
post-commit
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Script to ensure a tag for the current month exists
|
||||||
|
|
||||||
|
# Get the current year and month
|
||||||
|
YEAR_MONTH=$(date +%Y%m)
|
||||||
|
|
||||||
|
# Format the tag as v{year}{month}
|
||||||
|
TAG_NAME="v$YEAR_MONTH"
|
||||||
|
|
||||||
|
# Check if the tag already exists
|
||||||
|
if ! git rev-parse -q --verify "refs/tags/$TAG_NAME" >/dev/null; then
|
||||||
|
echo "Creating new tag for this month: $TAG_NAME"
|
||||||
|
# Create the tag
|
||||||
|
git tag -a "$TAG_NAME" -m "Monthly tag for $TAG_NAME"
|
||||||
|
# Optionally, you can push the tag to a remote repository
|
||||||
|
git push origin "$TAG_NAME"
|
||||||
|
else
|
||||||
|
echo "Tag for this month already exists: $TAG_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user