@@ -12,7 +12,51 @@ if [ "$EVENT_NAME" = "pull_request" ]; then
1212else
1313 INPUT_OPTIONS=" $INPUT_OPTIONS --cr_event_type=manual"
1414fi
15- echo $INPUT_OPTIONS
15+
16+ # Function to remove spaces from the value
17+ remove_spaces () {
18+ echo " $1 " | tr -d ' '
19+ }
20+
21+ # Function to convert a string to lowercase
22+ to_lowercase () {
23+ echo " $1 " | tr ' [:upper:]' ' [:lower:]'
24+ }
25+
26+ process_input_options () {
27+ local input=" $1 "
28+ local docker_cmd_args=" "
29+
30+ # Use sed to add newlines before each '--' to simplify processing
31+ local formatted_input=$( echo " $input " | sed ' s/ --/\n--/g' )
32+
33+ docker_cmd_args=$( echo " $formatted_input " | while IFS= read -r line
34+ do
35+ # Extract key by cutting until the first '='
36+ key=$( echo " $line " | cut -d' =' -f1)
37+
38+ # Extract value by removing everything before the first '='
39+ value=$( echo " $line " | cut -d' =' -f2-)
40+
41+ # Check if the argument is --review_scope, --exclude_files, or --exclude_branches and remove spaces
42+ if [[ " $key " == " --review_scope" || " $key " == " --static_analysis_tool" ]]; then
43+ value=$( remove_spaces " $value " )
44+ value=$( to_lowercase " $value " )
45+ elif [[ " $key " == " --exclude_files" || " $key " == " --exclude_branches" ]]; then
46+ value=$( remove_spaces " $value " )
47+ fi
48+
49+ # Append to the modified arguments
50+ echo -n " $key =$value "
51+ done)
52+
53+ # Return the docker command arguments
54+ echo " $docker_cmd_args "
55+ }
56+
57+ # Process the input arguments and get the modified result
58+ docker_cmd_args=$( process_input_options " $INPUT_OPTIONS " )
59+ echo " Docker Command Args: $docker_cmd_args "
1660
1761SUPPORTED_COMMANDS=(" /review" " review" )
1862
3175# Run the Docker container from the specified image
3276if [ " $valid_command " = true ]; then
3377 docker pull bitoai/cra:latest >&2
34- exec docker run bitoai/cra:latest --mode=cli --pr_url $INPUT_PR --command " $INPUT_COMMAND " rest $INPUT_OPTIONS
78+ exec docker run bitoai/cra:latest --mode=cli --pr_url $INPUT_PR --command " $INPUT_COMMAND " rest $docker_cmd_args
3579else
3680 echo " $INPUT_COMMAND is not supported"
3781 exit 0 # Exit the script with a non-zero status code
0 commit comments