Skip to content

Commit 6dd5a7f

Browse files
authored
Merge pull request #53 from gitbito/release/2.3.2
Update bito-cra.sh
2 parents bae3b3d + 83638da commit 6dd5a7f

File tree

3 files changed

+66
-5
lines changed

3 files changed

+66
-5
lines changed

cra-scripts/bito-cra.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ include_source_branches=
2020
include_target_branches=
2121
exclude_files=*.xml,*.json,*.properties,.gitignore,*.yml,*.md
2222
exclude_draft_pr=True
23+
post_as_request_changes=False
24+
support_email=
25+
suggestion_mode=essential

cra-scripts/bito-cra.ps1

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ function Validate-Boolean {
7474
return $boolean_val
7575
}
7676

77+
# Function to set default suggestion mode
78+
function Validate-Suggestion-Mode {
79+
param($suggestion_mode)
80+
# Convert the input to lowercase
81+
$suggestion_mode = $suggestion_mode.ToLower()
82+
83+
if ($suggestion_mode -eq "comprehensive") {
84+
return $suggestion_mode
85+
}
86+
87+
return "essential"
88+
}
89+
7790
# Function to validate a mode value i.e. cli or server
7891
function Validate-Mode {
7992
param($mode_val)
@@ -414,7 +427,10 @@ $optional_params_cli = @(
414427
"enable_default_branch",
415428
"exclude_branches",
416429
"include_source_branches",
417-
"include_target_branches",
430+
"include_target_branches"
431+
"post_as_request_changes",
432+
"suggestion_mode",
433+
"locale",
418434
"exclude_files",
419435
"exclude_draft_pr",
420436
"dependency_check",
@@ -433,6 +449,7 @@ $optional_params_cli = @(
433449
"custom_rules.region_name"
434450
"custom_rules.bucket_name"
435451
"custom_rules.aes_key"
452+
"support_email"
436453
)
437454

438455
# Parameters that are required/optional in mode server
@@ -456,6 +473,9 @@ $optional_params_server = @(
456473
"exclude_branches",
457474
"include_source_branches",
458475
"include_target_branches",
476+
"post_as_request_changes",
477+
"suggestion_mode",
478+
"locale",
459479
"exclude_files",
460480
"exclude_draft_pr",
461481
"dependency_check",
@@ -474,6 +494,7 @@ $optional_params_server = @(
474494
"custom_rules.bucket_name"
475495
"custom_rules.aes_key"
476496
"output_path"
497+
"support_email"
477498
)
478499

479500
$bee_params = @(
@@ -542,7 +563,7 @@ foreach ($param in $required_params) {
542563
foreach ($param in $optional_params) {
543564
if ($param -eq "dependency_check.snyk_auth_token" -and $props["dependency_check"] -eq "True") {
544565
Ask-For-Param $param $false
545-
} elseif ($param -ne "acceptable_suggestions_enabled" -and $param -ne "dependency_check.snyk_auth_token" -and $param -ne "env" -and $param -ne "cli_path" -and $param -ne "output_path" -and $param -ne "static_analysis_tool" -and $param -ne "linters_feedback" -and $param -ne "secret_scanner_feedback" -and $param -ne "enable_default_branch" -and $param -ne "git.domain" -and $param -ne "review_scope" -and $param -ne "exclude_branches" -and $param -ne "include_source_branches" -and $param -ne "include_target_branches" -and $param -ne "exclude_files" -and $param -ne "exclude_draft_pr" -and $param -ne "cr_event_type" -and $param -ne "posting_to_pr" -and $param -ne "custom_rules.configured_ws_ids" -and $param -ne "custom_rules.aws_access_key_id" -and $param -ne "custom_rules.aws_secret_access_key" -and $param -ne "custom_rules.region_name" -and $param -ne "custom_rules.bucket_name" -and $param -ne "custom_rules.aes_key" -and $param -ne "code_context_config.partial_timeout" -and $param -ne "code_context_config.max_depth" -and $param -ne "code_context_config.kill_timeout_sec") {
566+
} elseif ($param -ne "acceptable_suggestions_enabled" -and $param -ne "dependency_check.snyk_auth_token" -and $param -ne "env" -and $param -ne "cli_path" -and $param -ne "output_path" -and $param -ne "static_analysis_tool" -and $param -ne "linters_feedback" -and $param -ne "secret_scanner_feedback" -and $param -ne "enable_default_branch" -and $param -ne "git.domain" -and $param -ne "review_scope" -and $param -ne "exclude_branches" -and $param -ne "include_source_branches" -and $param -ne "include_target_branches" -and $param -ne "suggestion_mode" -and $param -ne "locale" -and $param -ne "exclude_files" -and $param -ne "exclude_draft_pr" -and $param -ne "cr_event_type" -and $param -ne "posting_to_pr" -and $param -ne "custom_rules.configured_ws_ids" -and $param -ne "custom_rules.aws_access_key_id" -and $param -ne "custom_rules.aws_secret_access_key" -and $param -ne "custom_rules.region_name" -and $param -ne "custom_rules.bucket_name" -and $param -ne "custom_rules.aes_key" -and $param -ne "code_context_config.partial_timeout" -and $param -ne "code_context_config.max_depth" -and $param -ne "code_context_config.kill_timeout_sec" -and $param -ne "support_email" -and $param -ne "post_as_request_changes") {
546567
Ask-For-Param $param $false
547568
}
548569
}
@@ -571,6 +592,9 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
571592
} elseif ($param -eq "linters_feedback") {
572593
$validated_boolean = Validate-Boolean $props[$param]
573594
$docker_cmd += " --$param=$validated_boolean"
595+
} elseif ($param -eq "post_as_request_changes") {
596+
$validated_boolean = Validate-Boolean $props[$param]
597+
$docker_cmd += " --$param=$validated_boolean"
574598
} elseif ($param -eq "secret_scanner_feedback") {
575599
$validated_boolean = Validate-Boolean $props[$param]
576600
$docker_cmd += " --$param=$validated_boolean"
@@ -589,6 +613,11 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
589613
$docker_cmd += " --include_source_branches='$($props[$param])'"
590614
} elseif ($param -eq "include_target_branches") {
591615
$docker_cmd += " --include_target_branches='$($props[$param])'"
616+
} elseif ($param -eq "suggestion_mode") {
617+
$validated_suggestion_mode = Validate-Suggestion-Mode $props[$param]
618+
$docker_cmd += " --suggestion_mode='$validated_suggestion_mode'"
619+
} elseif ($param -eq "locale") {
620+
$docker_cmd += " --locale='$($props[$param])'"
592621
} elseif ($param -eq "exclude_files") {
593622
$docker_cmd += " --exclude_files='$($props[$param])'"
594623
} elseif ($param -eq "exclude_draft_pr") {
@@ -627,8 +656,9 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
627656
$crEventType = ValidateCrEventType $props[$param]
628657
} elseif ($param -eq "posting_to_pr") {
629658
$postingToPr = ValidatePostingToPr $props[$param]
630-
}
631-
else {
659+
} elseif ($param -eq "support_email") {
660+
$docker_cmd += " --support_email='$( $props[$param] )'"
661+
} else {
632662
$docker_cmd += " --$param=$($props[$param])"
633663
}
634664
}

cra-scripts/bito-cra.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ validate_boolean() {
6969
fi
7070
}
7171

72+
# Function to validate suggestion mode
73+
validate_suggestion_mode() {
74+
local suggestion_mode="$(echo "$1" | awk '{print tolower($0)}')"
75+
if [ "$suggestion_mode" == "comprehensive" ]; then
76+
echo "comprehensive"
77+
else
78+
echo "essential"
79+
fi
80+
}
81+
7282
# Function to validate a mode value i.e. cli or server
7383
validate_mode() {
7484
local mode_val="$1"
@@ -424,6 +434,9 @@ optional_params_cli=(
424434
"exclude_branches"
425435
"include_source_branches"
426436
"include_target_branches"
437+
"post_as_request_changes"
438+
"suggestion_mode"
439+
"locale"
427440
"exclude_files"
428441
"exclude_draft_pr"
429442
"dependency_check"
@@ -443,6 +456,7 @@ optional_params_cli=(
443456
"custom_rules.region_name"
444457
"custom_rules.bucket_name"
445458
"custom_rules.aes_key"
459+
"support_email"
446460
)
447461

448462
# Parameters that are required/optional in mode server
@@ -466,6 +480,9 @@ optional_params_server=(
466480
"exclude_branches"
467481
"include_source_branches"
468482
"include_target_branches"
483+
"post_as_request_changes"
484+
"suggestion_mode"
485+
"locale"
469486
"exclude_files"
470487
"exclude_draft_pr"
471488
"dependency_check"
@@ -485,6 +502,7 @@ optional_params_server=(
485502
"custom_rules.bucket_name"
486503
"custom_rules.aes_key"
487504
"output_path"
505+
"support_email"
488506
)
489507

490508
bee_params=(
@@ -550,7 +568,7 @@ done
550568
for param in "${optional_params[@]}"; do
551569
if [ "$param" == "dependency_check.snyk_auth_token" ] && [ "${props["dependency_check"]}" == "True" ]; then
552570
ask_for_param "$param" "False"
553-
elif [ "$param" != "acceptable_suggestions_enabled" ] && [ "$param" != "dependency_check.snyk_auth_token" ] && [ "$param" != "env" ] && [ "$param" != "cli_path" ] && [ "$param" != "output_path" ] && [ "$param" != "static_analysis_tool" ] && [ "$param" != "linters_feedback" ] && [ "$param" != "secret_scanner_feedback" ] && [ "$param" != "enable_default_branch" ] && [ "$param" != "git.domain" ] && [ "$param" != "review_scope" ] && [ "$param" != "exclude_branches" ] && [ "$param" != "include_source_branches" ] && [ "$param" != "include_target_branches" ] && [ "$param" != "nexus_url" ] && [ "$param" != "exclude_files" ] && [ "$param" != "exclude_draft_pr" ] && [ "$param" != "cr_event_type" ] && [ "$param" != "posting_to_pr" ] && [ "$param" != "custom_rules.configured_ws_ids" ] && [ "$param" != "custom_rules.aws_access_key_id" ] && [ "$param" != "custom_rules.aws_secret_access_key" ] && [ "$param" != "custom_rules.region_name" ] && [ "$param" != "custom_rules.bucket_name" ] && [ "$param" != "custom_rules.aes_key" ] && [ "$param" != "code_context_config.partial_timeout" ] && [ "$param" != "code_context_config.max_depth" ] && [ "$param" != "code_context_config.kill_timeout_sec" ]; then
571+
elif [ "$param" != "acceptable_suggestions_enabled" ] && [ "$param" != "dependency_check.snyk_auth_token" ] && [ "$param" != "env" ] && [ "$param" != "cli_path" ] && [ "$param" != "output_path" ] && [ "$param" != "static_analysis_tool" ] && [ "$param" != "linters_feedback" ] && [ "$param" != "secret_scanner_feedback" ] && [ "$param" != "enable_default_branch" ] && [ "$param" != "git.domain" ] && [ "$param" != "review_scope" ] && [ "$param" != "exclude_branches" ] && [ "$param" != "include_source_branches" ] && [ "$param" != "include_target_branches" ] && [ "$param" != "suggestion_mode" ] && [ "$param" != "locale" ] && [ "$param" != "nexus_url" ] && [ "$param" != "exclude_files" ] && [ "$param" != "exclude_draft_pr" ] && [ "$param" != "cr_event_type" ] && [ "$param" != "posting_to_pr" ] && [ "$param" != "custom_rules.configured_ws_ids" ] && [ "$param" != "custom_rules.aws_access_key_id" ] && [ "$param" != "custom_rules.aws_secret_access_key" ] && [ "$param" != "custom_rules.region_name" ] && [ "$param" != "custom_rules.bucket_name" ] && [ "$param" != "custom_rules.aes_key" ] && [ "$param" != "code_context_config.partial_timeout" ] && [ "$param" != "code_context_config.max_depth" ] && [ "$param" != "code_context_config.kill_timeout_sec" ] && [ "$param" != "post_as_request_changes" ] && [ "$param" != "support_email" ]; then
554572
ask_for_param "$param" "False"
555573
fi
556574
done
@@ -585,6 +603,9 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}";
585603
elif [ "$param" == "linters_feedback" ]; then
586604
props[$param]=$(validate_boolean "${props[$param]}")
587605
docker_cmd+=" --linters_feedback=${props[$param]}"
606+
elif [ "$param" == "post_as_request_changes" ]; then
607+
props[$param]=$(validate_boolean "${props[$param]}")
608+
docker_cmd+=" --post_as_request_changes=${props[$param]}"
588609
elif [ "$param" == "secret_scanner_feedback" ]; then
589610
props[$param]=$(validate_boolean "${props[$param]}")
590611
docker_cmd+=" --secret_scanner_feedback=${props[$param]}"
@@ -603,6 +624,11 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}";
603624
docker_cmd+=" --include_source_branches='${props[$param]}'"
604625
elif [ "$param" == "include_target_branches" ]; then
605626
docker_cmd+=" --include_target_branches='${props[$param]}'"
627+
elif [ "$param" == "suggestion_mode" ]; then
628+
props[$param]=$(validate_suggestion_mode "${props[$param]}")
629+
docker_cmd+=" --suggestion_mode='${props[$param]}'"
630+
elif [ "$param" == "locale" ]; then
631+
docker_cmd+=" --locale='${props[$param]}'"
606632
elif [ "$param" == "exclude_files" ]; then
607633
docker_cmd+=" --exclude_files='${props[$param]}'"
608634
elif [ "$param" == "exclude_draft_pr" ]; then
@@ -655,6 +681,8 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}";
655681
validate_cr_event_type "${props[$param]}"
656682
elif [ "$param" == "posting_to_pr" ]; then
657683
validate_posting_to_pr "${props[$param]}"
684+
elif [ "$param" == "support_email" ]; then
685+
docker_cmd+=" --support_email='${props[$param]}'"
658686
else
659687
docker_cmd+=" --$param=${props[$param]}"
660688
fi

0 commit comments

Comments
 (0)