Forest_Client/Tool/BuildTool/blame.sh

37 lines
2.0 KiB
Bash

#!/bin/bash
script_directory="$(cd "$(dirname "$0")" && pwd)"
#if [ "$#" -eq 0 ]; then
# echo "Usage: $0 <text>"
# exit 1
#fi
text="$1"
#测试用
#text="[Licensing::Client] Error: HandshakeResponse reported an error:
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,77): error CS0117: 'SDKManager.SdkName' does not contain a definition for 'IAP'
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,85): error CS0246: The type or namespace name 'IBuyServices' could not be found (are you missing a using directive or an assembly reference?)
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,77): error CS0117: 'SDKManager.SdkName' does not contain a definition for 'IAP'
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,85): error CS0246: The type or namespace name 'IBuyServices' could not be found (are you missing a using directive or an assembly reference?)
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,77): error CS0117: 'SDKManager.SdkName' does not contain a definition for 'IAP'
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,85): error CS0246: The type or namespace name 'IBuyServices' could not be found (are you missing a using directive or an assembly reference?)
# Scripts have compiler errors."
echo "blame start $text"
if [[ $text =~ (Assets\/[^:\(]+)\/([^:\(]+\.cs)[:\(]([0-9]+) ]]; then
path="${BASH_REMATCH[1]}"
fileName="${BASH_REMATCH[2]}"
line_number="${BASH_REMATCH[3]}"
echo "blame path:$path"
echo "blame file: $fileName"
echo "blame line_num: $line_number"
cd ../../ProjectNLD/"$path" || exit
#git blame -L "$line_number" "$fileName"
last_commit_author=$(git blame -L "$line_number" "$fileName" | sed 's/^[^(]*(\([^[:space:]]*\).*/\1/' | head -n 1)
message="fileName:$path/$fileName \r\n line_num:$line_number \r\n author:${last_commit_author}"
echo "message:$message"
cd "$script_directory" || exit
sh to_inner_wechat_robot.sh "$message"
fi