Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 176ae70

Browse files
authored
Merge pull request #1498 from janhq/j/fix-1437
fix(#1437): allow incasesensitive for branch name
2 parents d4d0d13 + a9f538c commit 176ae70

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

engine/utils/cli_selection_utils.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <optional>
33
#include <string>
44
#include <vector>
5-
#include "utils/logging_utils.h"
5+
#include "utils/string_utils.h"
66

77
namespace cli_selection_utils {
88
const std::string indent = std::string(4, ' ');
@@ -13,7 +13,8 @@ inline void PrintMenu(
1313
auto index{start_index};
1414
for (const auto& option : options) {
1515
bool is_default = false;
16-
if (default_option.has_value() && option == default_option.value()) {
16+
if (default_option.has_value() &&
17+
string_utils::EqualsIgnoreCase(option, default_option.value())) {
1718
is_default = true;
1819
}
1920
std::string selection{std::to_string(index) + ". " + option +
@@ -48,10 +49,13 @@ inline std::optional<std::string> PrintModelSelection(
4849

4950
// if selection is empty and default selection is inside availables, return default_selection
5051
if (selection.empty()) {
51-
if (default_selection.has_value() &&
52-
std::find(availables.begin(), availables.end(),
53-
default_selection.value()) != availables.end()) {
54-
return default_selection;
52+
if (default_selection.has_value()) {
53+
for (const auto& available : availables) {
54+
if (string_utils::EqualsIgnoreCase(available,
55+
default_selection.value())) {
56+
return available;
57+
}
58+
}
5559
}
5660
return std::nullopt;
5761
}

engine/utils/string_utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ struct ParsePromptResult {
1313
std::string ai_prompt;
1414
};
1515

16+
inline bool EqualsIgnoreCase(const std::string& a, const std::string& b) {
17+
return std::equal(a.begin(), a.end(), b.begin(), b.end(),
18+
[](char a, char b) { return tolower(a) == tolower(b); });
19+
}
20+
1621
inline ParsePromptResult ParsePrompt(const std::string& prompt) {
1722
auto& pt = prompt;
1823
ParsePromptResult result;

0 commit comments

Comments
 (0)