feat: manually mirror opencoze's code from bytedance
Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
43
common/git-hooks/commit-msg
Executable file
43
common/git-hooks/commit-msg
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This is an example Git hook for use with Rush. To enable this hook, rename this file
|
||||
# to "commit-msg" and then run "rush install", which will copy it from common/git-hooks
|
||||
# to the .git/hooks folder.
|
||||
#
|
||||
# TO LEARN MORE ABOUT GIT HOOKS
|
||||
#
|
||||
# The Git documentation is here: https://git-scm.com/docs/githooks
|
||||
# Some helpful resources: https://githooks.com
|
||||
#
|
||||
# ABOUT THIS EXAMPLE
|
||||
#
|
||||
# The commit-msg hook is called by "git commit" with one argument, the name of the file
|
||||
# that has the commit message. The hook should exit with non-zero status after issuing
|
||||
# an appropriate message if it wants to stop the commit. The hook is allowed to edit
|
||||
# the commit message file.
|
||||
|
||||
# This example enforces that commit message should contain a minimum amount of
|
||||
# description text.
|
||||
# if [ `cat $1 | wc -w` -lt 3 ]; then
|
||||
# echo ""
|
||||
# echo "Invalid commit message: The message must contain at least 3 words."
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
if [ "$SKIP_COMMIT_MSG_HOOK" = "true" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# rebase 过程中分支名格式为 (no branch, rebasing chore/replace-rushtool)
|
||||
# 正常提交时分支名格式为 chore/replace-rushtool
|
||||
BRANCH_NAME=$(git branch | grep '*' | sed 's/* //')
|
||||
# 如果匹配到 rebase 格式的输出,认为是在rebase ,则跳过自动推送
|
||||
if [[ "X${BRANCH_NAME}" == "X(no branch"* ]]; then
|
||||
exit
|
||||
else
|
||||
node common/scripts/install-run-rush.js -q commitlint \
|
||||
--config common/autoinstallers/rush-commitlint/commitlint.config.js \
|
||||
--edit "$1" || exit 1
|
||||
|
||||
node common/scripts/install-run-rush.js change-x || exit 1
|
||||
fi
|
||||
25
common/git-hooks/commit-msg.sample
Normal file
25
common/git-hooks/commit-msg.sample
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This is an example Git hook for use with Rush. To enable this hook, rename this file
|
||||
# to "commit-msg" and then run "rush install", which will copy it from common/git-hooks
|
||||
# to the .git/hooks folder.
|
||||
#
|
||||
# TO LEARN MORE ABOUT GIT HOOKS
|
||||
#
|
||||
# The Git documentation is here: https://git-scm.com/docs/githooks
|
||||
# Some helpful resources: https://githooks.com
|
||||
#
|
||||
# ABOUT THIS EXAMPLE
|
||||
#
|
||||
# The commit-msg hook is called by "git commit" with one argument, the name of the file
|
||||
# that has the commit message. The hook should exit with non-zero status after issuing
|
||||
# an appropriate message if it wants to stop the commit. The hook is allowed to edit
|
||||
# the commit message file.
|
||||
|
||||
# This example enforces that commit message should contain a minimum amount of
|
||||
# description text.
|
||||
if [ `cat $1 | wc -w` -lt 3 ]; then
|
||||
echo ""
|
||||
echo "Invalid commit message: The message must contain at least 3 words."
|
||||
exit 1
|
||||
fi
|
||||
8
common/git-hooks/post-checkout
Executable file
8
common/git-hooks/post-checkout
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
if [ "$SKIP_COMMIT_MSG_HOOK" = "true" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# avoid conflicts in pnpm lock
|
||||
# https://7tonshark.com/posts/avoid-conflicts-in-pnpm-lock/
|
||||
git config merge.ours.driver true
|
||||
14
common/git-hooks/post-commit
Executable file
14
common/git-hooks/post-commit
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
if [ "$SKIP_COMMIT_MSG_HOOK" = "true" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# rebase 过程中分支名格式为 (no branch, rebasing chore/replace-rushtool)
|
||||
# 正常提交时分支名格式为 chore/replace-rushtool
|
||||
BRANCH_NAME=$(git branch | grep '*' | sed 's/* //')
|
||||
# 如果匹配到 rebase 格式的输出,认为是在rebase ,则跳过自动推送
|
||||
if [[ "X${BRANCH_NAME}" == "X(no branch"* ]]; then
|
||||
exit
|
||||
else
|
||||
node common/scripts/install-run-rush.js change-x -a || exit 1
|
||||
fi
|
||||
2
common/git-hooks/post-merge
Executable file
2
common/git-hooks/post-merge
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
|
||||
27
common/git-hooks/pre-commit
Executable file
27
common/git-hooks/pre-commit
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
|
||||
# Invoke the "rush prettier" custom command to reformat files whenever they
|
||||
# are committed. The command is defined in common/config/rush/command-line.json
|
||||
# and uses the "rush-lint-staged" autoinstaller.
|
||||
|
||||
# Force to update codeowners file if packasge.json changed.
|
||||
|
||||
# block unresolved conflict; https://git-scm.com/docs/git-diff
|
||||
|
||||
if [ "$SKIP_COMMIT_MSG_HOOK" = "true" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
source frontend/scripts/block-unresolved-conflict.sh
|
||||
|
||||
block_unresolved_conflict '--cached'
|
||||
|
||||
if [ "$PRE_LINT" != "1" ]; then
|
||||
node common/scripts/install-run-rush.js fix-ts-refers --use-cached-files --shallow --submit-changes
|
||||
# node infra/commanders/fix-peer-deps/bin/main.js fix --use-cached-files -s
|
||||
node common/scripts/install-run-rush.js -q lint-staged || exit $?
|
||||
bash .codebase/scripts/check-file-size.sh || exit $?
|
||||
fi
|
||||
9
common/git-hooks/pre-push
Executable file
9
common/git-hooks/pre-push
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$SKIP_COMMIT_MSG_HOOK" = "true" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
source frontend/scripts/block-unresolved-conflict.sh
|
||||
|
||||
source frontend/scripts/pre-push-hook.sh
|
||||
Reference in New Issue
Block a user