From 6e67f03a4b72d3deb71aa0299495d642898be4e6 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 03:26:07 +0000 Subject: [PATCH 1/7] feat: Updated scripts/githooks/pre-commit.sh --- scripts/githooks/pre-commit.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/githooks/pre-commit.sh b/scripts/githooks/pre-commit.sh index b9d19ff0..c5ccd412 100644 --- a/scripts/githooks/pre-commit.sh +++ b/scripts/githooks/pre-commit.sh @@ -1,6 +1,8 @@ +#!/usr/bin/env bash chmod +x scripts/githooks/pre-commit.sh #!/usr/bin/env bash chmod +x scripts/githooks/pre-commit.sh +#!/usr/bin/env bash # Copyright © 2023 OpenIMSDK. # # Licensed under the Apache License, Version 2.0 (the "License"); From 98a5635387812056d3db0271f721ef0645af7c83 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 03:26:25 +0000 Subject: [PATCH 2/7] feat: Updated scripts/githooks/pre-commit.sh --- scripts/githooks/pre-commit.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/githooks/pre-commit.sh b/scripts/githooks/pre-commit.sh index c5ccd412..899d792f 100644 --- a/scripts/githooks/pre-commit.sh +++ b/scripts/githooks/pre-commit.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -chmod +x scripts/githooks/pre-commit.sh + #!/usr/bin/env bash chmod +x scripts/githooks/pre-commit.sh #!/usr/bin/env bash @@ -17,7 +17,7 @@ chmod +x scripts/githooks/pre-commit.sh # See the License for the specific language governing permissions and # limitations under the License. # -chmod +x scripts/githooks/pre-commit.sh + # ============================================================================== # This is a pre-commit hook that ensures attempts to commit files that are From 2614d973cf1692b8e146781d919f6d8c1797a8c5 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 03:26:42 +0000 Subject: [PATCH 3/7] feat: Updated scripts/githooks/pre-commit.sh --- scripts/githooks/pre-commit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/githooks/pre-commit.sh b/scripts/githooks/pre-commit.sh index 899d792f..1d0cb0c0 100644 --- a/scripts/githooks/pre-commit.sh +++ b/scripts/githooks/pre-commit.sh @@ -29,7 +29,7 @@ chmod +x scripts/githooks/pre-commit.sh # ============================================================================== # -LC_ALL=C +export LC_ALL=C local_branch="$(git rev-parse --abbrev-ref HEAD)" valid_branch_regex="^(main|master|develop|release(-[a-zA-Z0-9._-]+)?)$|(feature|feat|openim|hotfix|test|bug|bot|refactor|revert|ci|cicd|style|)\/[a-z0-9._-]+$|^HEAD$" From fe3c0cbdce87fc11b67808e76960247ac5a31fbd Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 03:26:59 +0000 Subject: [PATCH 4/7] feat: Updated scripts/githooks/pre-commit.sh --- scripts/githooks/pre-commit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/githooks/pre-commit.sh b/scripts/githooks/pre-commit.sh index 1d0cb0c0..a32214f4 100644 --- a/scripts/githooks/pre-commit.sh +++ b/scripts/githooks/pre-commit.sh @@ -77,7 +77,7 @@ HEREDOC } # Move to the repo root so git files paths make sense -repo_root=$( git rev-parse --show-toplevel ) +repo_root=$(git rev-parse --show-toplevel 2>/dev/null) cd $repo_root against=HEAD From 6f6be52d53c12bc1b4917146c0f472450a2a010c Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 03:29:25 +0000 Subject: [PATCH 5/7] feat: Updated scripts/githooks/pre-commit.sh --- scripts/githooks/pre-commit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/githooks/pre-commit.sh b/scripts/githooks/pre-commit.sh index a32214f4..15417506 100644 --- a/scripts/githooks/pre-commit.sh +++ b/scripts/githooks/pre-commit.sh @@ -88,7 +88,7 @@ IFS=' shouldFail=false for file in $( git diff-index --cached --name-only $against ); do - file_size=$(([ ! -f $file ] && echo 0) || (ls -la $file | awk '{ print $5 }')) + file_size=$(([ ! -f $file ] && echo 0) || (ls -la "$file" | awk '{ print $5 }')) if [ "$file_size" -gt "$limit" ] && { grep -q ".github/release-drafter.yml" $file ;}; then printError "File $file is $(( $file_size / 10**6 )) MB, which is larger than our configured limit of $limitInMB MB" shouldFail=true From e6c1be0e011a7f143b968676501a2dd5ce5c2e9d Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 03:29:50 +0000 Subject: [PATCH 6/7] feat: Updated scripts/githooks/pre-commit.sh --- scripts/githooks/pre-commit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/githooks/pre-commit.sh b/scripts/githooks/pre-commit.sh index 15417506..c856db9c 100644 --- a/scripts/githooks/pre-commit.sh +++ b/scripts/githooks/pre-commit.sh @@ -95,7 +95,7 @@ for file in $( git diff-index --cached --name-only $against ); do fi done -if $shouldFail +if [ "$shouldFail" = true ] then printMessage "If you really need to commit this file, you can override the size limit by setting the GIT_FILE_SIZE_LIMIT environment variable, e.g. GIT_FILE_SIZE_LIMIT=42000000 for 42MB. Or, commit with the --no-verify switch to skip the check entirely." printError "Commit aborted" From 2b3924bcfaf7f385460cc456b6642443b5c05e8c Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 03:30:35 +0000 Subject: [PATCH 7/7] feat: Updated scripts/githooks/pre-commit.sh --- scripts/githooks/pre-commit.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/githooks/pre-commit.sh b/scripts/githooks/pre-commit.sh index c856db9c..abcb2ab7 100644 --- a/scripts/githooks/pre-commit.sh +++ b/scripts/githooks/pre-commit.sh @@ -104,10 +104,8 @@ fi if [[ ! $local_branch =~ $valid_branch_regex ]] then - printError "The branch name format is invalid. Branch names in this project must adhere to the following format: $valid_branch_regex. Valid branch names should adhere to the following format: {valid format regex}. -Ensure that your branch follows the valid format (e.g., feat/name or bug/name) and try again. - -For more information, refer to: https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694" + printError "The branch name format is invalid. Branch names in this project must adhere to the following format: $valid_branch_regex. Valid branch names should adhere to the following format: {feature|feat|openim|hotfix|test|bug|bot|refactor|revert|ci|cicd|style|}/name.\nEnsure that your branch follows the valid format (e.g., feat/name or bug/name) and try again.\n\nFor more information, refer to: https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694" + exit 1 printError "For more information, refer to: https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694" exit 1 fi \ No newline at end of file