From ea70f51aaf5220c0023378911a9603dc65a4fb2e Mon Sep 17 00:00:00 2001 From: Konano Date: Fri, 28 Jan 2022 00:41:46 +0800 Subject: [PATCH] workflow: update git hook --- .github/git-hooks/commit-msg | 2 +- .../filter-flow-hotfix-start-version | 2 +- .../filter-flow-release-start-version | 2 +- .github/gitflow-hooks/post-flow-release-start | 26 ------------------- .github/gitflow-hooks/pre-flow-hotfix-finish | 7 ++--- .github/gitflow-hooks/pre-flow-release-delete | 23 ---------------- .github/gitflow-hooks/pre-flow-release-finish | 2 +- 7 files changed, 6 insertions(+), 58 deletions(-) delete mode 100755 .github/gitflow-hooks/post-flow-release-start delete mode 100755 .github/gitflow-hooks/pre-flow-release-delete diff --git a/.github/git-hooks/commit-msg b/.github/git-hooks/commit-msg index b2ce99ad1..393f2f675 100755 --- a/.github/git-hooks/commit-msg +++ b/.github/git-hooks/commit-msg @@ -4,7 +4,7 @@ COMMIT_MESSAGE=`cat $1` COMMIT_RE="^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|release|hotfix|workflow|update)(\(.+\))?: .{1,100}" -MERGE_RE="^Merge branch" +MERGE_RE="^Merge " if [[ ! $COMMIT_MESSAGE =~ $COMMIT_RE ]] && [[ ! $COMMIT_MESSAGE =~ $MERGE_RE ]] then diff --git a/.github/gitflow-hooks/filter-flow-hotfix-start-version b/.github/gitflow-hooks/filter-flow-hotfix-start-version index a57498169..8c85afec7 100755 --- a/.github/gitflow-hooks/filter-flow-hotfix-start-version +++ b/.github/gitflow-hooks/filter-flow-hotfix-start-version @@ -16,7 +16,7 @@ # VERSION=$1 VERSION=$1 -VERSION_RE="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$" +VERSION_RE="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(a[1-9][0-9]*)?$" if [[ ! $VERSION =~ $VERSION_RE ]] then # echo "Illegal version format: $VERSION" diff --git a/.github/gitflow-hooks/filter-flow-release-start-version b/.github/gitflow-hooks/filter-flow-release-start-version index 84b588f2c..a86614bae 100755 --- a/.github/gitflow-hooks/filter-flow-release-start-version +++ b/.github/gitflow-hooks/filter-flow-release-start-version @@ -16,7 +16,7 @@ # VERSION=$1 VERSION=$1 -VERSION_RE="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$" +VERSION_RE="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(a[1-9][0-9]*)?$" if [[ ! $VERSION =~ $VERSION_RE ]] then # echo "Illegal version format: $VERSION" diff --git a/.github/gitflow-hooks/post-flow-release-start b/.github/gitflow-hooks/post-flow-release-start deleted file mode 100755 index fe2c4674f..000000000 --- a/.github/gitflow-hooks/post-flow-release-start +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# Runs at the end of git flow release start -# -# Positional arguments: -# $1 The version (including the version prefix) -# $2 The origin remote -# $3 The full branch name (including the release prefix) -# $4 The base from which this release is started -# -# The following variables are available as they are exported by git-flow: -# -# MASTER_BRANCH - The branch defined as Master -# DEVELOP_BRANCH - The branch defined as Develop -# -# VERSION=$1 -# ORIGIN=$2 -# BRANCH=$3 -# BASE=$4 - -ROOT=`git rev-parse --show-toplevel` -VERSION=${1:1} - -sed -i "s/__version__ = '[0-9\.a]\+'/__version__ = '$VERSION'/g" "$ROOT/arknights_mower/__init__.py" -cp "$ROOT/doc/CHANGELOG/release.md" "$ROOT/doc/CHANGELOG/$VERSION.md" -code "$ROOT/doc/CHANGELOG/$VERSION.md" diff --git a/.github/gitflow-hooks/pre-flow-hotfix-finish b/.github/gitflow-hooks/pre-flow-hotfix-finish index a5d58414b..5ce4df1cf 100755 --- a/.github/gitflow-hooks/pre-flow-hotfix-finish +++ b/.github/gitflow-hooks/pre-flow-hotfix-finish @@ -5,8 +5,8 @@ # Positional arguments: # $1 The version (including the version prefix) # $2 The origin remote -# $3 The full branch name (including the feature prefix) -# $4 The base from which this feature is started +# $3 The full branch name (including the hotfix prefix) +# $4 The base from which this hotfix is started # # The following variables are available as they are exported by git-flow: # @@ -22,8 +22,5 @@ ROOT=`git rev-parse --show-toplevel` VERSION=${1:1} sed -i "s/__version__ = '[0-9\.a]\+'/__version__ = '$VERSION'/g" "$ROOT/arknights_mower/__init__.py" -cp "$ROOT/doc/CHANGELOG/hotfix.md" "$ROOT/doc/CHANGELOG/$VERSION.md" -node "$ROOT/doc/CHANGELOG/$VERSION.md" git add "$ROOT/arknights_mower/__init__.py" -git add "$ROOT/doc/CHANGELOG/$VERSION.md" git commit -m "hotfix: v$VERSION" diff --git a/.github/gitflow-hooks/pre-flow-release-delete b/.github/gitflow-hooks/pre-flow-release-delete deleted file mode 100755 index f620f6e23..000000000 --- a/.github/gitflow-hooks/pre-flow-release-delete +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# -# Runs before git flow release delete -# -# Positional arguments: -# $1 The version ( !!!NOT!!! including the version prefix) -# $2 The origin remote -# $3 The full branch name (including the release prefix) -# -# The following variables are available as they are exported by git-flow: -# -# MASTER_BRANCH - The branch defined as Master -# DEVELOP_BRANCH - The branch defined as Develop - -# VERSION=$1 -# ORIGIN=$2 -# BRANCH=$3 - -ROOT=`git rev-parse --show-toplevel` -VERSION=$1 - -rm "$ROOT/doc/CHANGELOG/$VERSION.md" -git reset --hard HEAD diff --git a/.github/gitflow-hooks/pre-flow-release-finish b/.github/gitflow-hooks/pre-flow-release-finish index eeed40d55..605f8c839 100755 --- a/.github/gitflow-hooks/pre-flow-release-finish +++ b/.github/gitflow-hooks/pre-flow-release-finish @@ -21,6 +21,6 @@ ROOT=`git rev-parse --show-toplevel` VERSION=${1:1} +sed -i "s/__version__ = '[0-9\.a]\+'/__version__ = '$VERSION'/g" "$ROOT/arknights_mower/__init__.py" git add "$ROOT/arknights_mower/__init__.py" -git add "$ROOT/doc/CHANGELOG/$VERSION.md" git commit -m "release: v$VERSION"