1# Copyright (c) 2025 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14#!/bin/sh 15 16for FILE in $(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(cpp|hpp)$') 17do 18 git diff --cached --unified=0 "$FILE" | awk '/^\+[ ]*const std::string CommonEventSupport::/{ 19 match($0, /CommonEventSupport::([A-Za-z_]+) =/, arr); 20 print arr[1]; 21 }' | while read -r CONSTANT_NAME 22 do 23 if ! git diff --cached --unified=0 "$FILE" | grep -q "commonEventSupport_.emplace_back($CONSTANT_NAME)" 24 then 25 echo "Error: 在文件 $FILE 中,新增的常量字符串 $CONSTANT_NAME 未被添加到 commonEventSupport_.emplace_back 中。" 26 echo "请确保每个新增的常量字符串都被正确添加到 commonEventSupport_ 中。" 27 exit 1 28 fi 29 done 30done 31 32exit 0 33