43 Stanza(std::string n, std::string
name, std::string email)
44 : m_name(std::move(n)), m_maintainers{
Person(RoleType::Maintainer, std::move(
name),
45 std::move(email))} { }
56 unsigned match_path(
const std::filesystem::path &path)
const {
57 return std::accumulate(m_patterns.cbegin(), m_patterns.cend(), 0u,
58 [&path](
unsigned m,
const Pattern &p) {
59 return std::max(m, p.match(path));
70 std::set<std::string> &suse_users,
73 suse_users.insert(m->userName());
75 m->setEmail(translateEmail(m->email()));
77 m_maintainers.push_back(std::move(*m));
79 std::cerr <<
"MAINTAINERS: contact " << maintainer <<
80 " cannot be parsed into name and email!\n";
92 m_maintainers.push_back(
Person(RoleType::Maintainer,
name,
93 translateEmail(email), cnt));
103 const std::set<std::string> &suse_users,
107 m->setEmail(translateEmail(m->email()));
109 if (suse_users.contains(m->userName()))
110 m_maintainers.push_back(std::move(*m));
112 std::cerr <<
"Upstream MAINTAINERS: contact " << maintainer <<
113 " cannot be parsed into name and email!\n";
121 m_comments.emplace_back(std::move(comment));
133 m_patterns.push_back(std::move(*p));
139 return m_name.empty() || m_maintainers.empty() || m_patterns.empty();
152 const std::string &
name()
const {
return m_name; }
156 std::vector<std::string> m_comments;
157 std::vector<Pattern> m_patterns;
Loads and holds information from both Linux and SUSE MAINTAINERS files.
Definition Maintainers.h:23
Information about a person (such as username, e-mail, Role).
Definition Person.h:81
static std::optional< Person > parsePerson(std::string_view src, Role role)
Parse src into a Person.
Stanza (a subsystem) from MAINTAINERS file.
Definition Stanza.h:24
bool add_pattern(std::string pattern)
Add pattern to this Stanza.
Definition Stanza.h:129
std::vector< Person > Maintainers
Maintainers are a list of Person.
Definition Stanza.h:29
Stanza(std::string n, std::string name, std::string email)
Construct new Stanza called n with one Person (having name and email).
Definition Stanza.h:43
Stanza(Stanza &&)=default
Move constructor.
auto & comments() const
Get comment of this Stanza.
Definition Stanza.h:149
const std::string & name() const
Get name/title of this Stanza.
Definition Stanza.h:152
void add_comment(std::string comment)
Add comment to this Stanza.
Definition Stanza.h:120
unsigned match_path(const std::filesystem::path &path) const
Return weight of path in this Stanza.
Definition Stanza.h:56
Stanza(std::string name)
Construct new Stanza called name.
Definition Stanza.h:36
const Maintainers & maintainers() const
Obtain a list of Person in this Stanza.
Definition Stanza.h:146
std::function< std::string(std::string_view sv)> TranslateEmail
Callback to translate an e-mail.
Definition Stanza.h:27
void add_maintainer_if(std::string_view maintainer, const std::set< std::string > &suse_users, const TranslateEmail &translateEmail)
Add a maintainer (as Upstream) if in suse_users.
Definition Stanza.h:102
bool empty() const
Check if this Stanza has no name, maintainers, and patterns.
Definition Stanza.h:138
void add_maintainer_and_store(std::string_view maintainer, std::set< std::string > &suse_users, const TranslateEmail &translateEmail)
Add a maintainer (as Maintainer) and store them into SUSE users set too.
Definition Stanza.h:69
void add_backporter(const std::string &name, std::string_view email, unsigned cnt, const TranslateEmail &translateEmail)
Creates a Person and adds it as Maintainer.
Definition Stanza.h:90
Holds git patterns and reports weights if matched.
Definition Pattern.h:16
static std::optional< Pattern > create(std::string pattern)
Build a (git) Pattern.