Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rhel-10: ConfigParser: make splitReleasever public #1697

Open
wants to merge 1 commit into
base: rhel-10.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bindings/swig/conf.i
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public:
std::string & getHeader() noexcept;
const Container & getData() const noexcept;
Container & getData() noexcept;
static std::pair<std::string, std::string> splitReleasever(const std::string & releasever);
};
}
%clear std::string & text;
Expand Down
6 changes: 3 additions & 3 deletions libdnf/conf/ConfigParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ std::pair<std::string, size_t> ConfigParser::substitute_expression(const std::st
if (variable_key == "releasever_major" || variable_key == "releasever_minor") {
const auto releasever_mapping = substitutions.find("releasever");
if (releasever_mapping != substitutions.end()) {
const auto & releasever_split = ConfigParser::split_releasever(releasever_mapping->second);
const auto & releasever_split = ConfigParser::splitReleasever(releasever_mapping->second);
if (variable_key == "releasever_major") {
variable_value = std::get<0>(releasever_split);
variable_value_has_value = true;
Expand Down Expand Up @@ -231,7 +231,7 @@ std::pair<std::string, size_t> ConfigParser::substitute_expression(const std::st
return std::make_pair(res, text.length());
}

std::tuple<std::string, std::string> ConfigParser::split_releasever(const std::string & releasever)
std::pair<std::string, std::string> ConfigParser::splitReleasever(const std::string & releasever)
{
// Uses the same logic as DNF 5 and as splitReleaseverTo in libzypp
std::string releasever_major;
Expand All @@ -243,7 +243,7 @@ std::tuple<std::string, std::string> ConfigParser::split_releasever(const std::s
releasever_major = releasever.substr(0, pos);
releasever_minor = releasever.substr(pos + 1);
}
return std::make_tuple(releasever_major, releasever_minor);
return std::make_pair(releasever_major, releasever_minor);
}

static void read(ConfigParser & cfgParser, IniParser & parser)
Expand Down
3 changes: 1 addition & 2 deletions libdnf/conf/ConfigParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ struct ConfigParser {
std::string & getHeader() noexcept;
const Container & getData() const noexcept;
Container & getData() noexcept;
static std::pair<std::string, std::string> splitReleasever(const std::string & releasever);

private:
std::map<std::string, std::string> substitutions;
Expand All @@ -159,8 +160,6 @@ struct ConfigParser {
static std::pair<std::string, size_t> substitute_expression(const std::string & text,
const std::map<std::string, std::string> & substitutions,
unsigned int depth);

static std::tuple<std::string, std::string> split_releasever(const std::string & releasever);
};

inline void ConfigParser::setSubstitutions(const std::map<std::string, std::string> & substitutions)
Expand Down
Loading