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