Skip to content

Commit

Permalink
ConfigParser: make splitReleasever public
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-goode committed Jan 21, 2025
1 parent f9558fe commit a05d5ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions bindings/swig/conf.i
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,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

0 comments on commit a05d5ba

Please sign in to comment.