SlHelpers
Loading...
Searching...
No Matches
Maintainers.h
1// SPDX-License-Identifier: GPL-2.0-only
2
3#pragma once
4
5#include <filesystem>
6#include <set>
7#include <string>
8#include <vector>
9
10#include "Stanza.h"
11
12namespace SlHelpers {
13class GetLine;
14}
15
16namespace SlKernCVS {
17
24public:
26 using MaintainersType = std::vector<Stanza>;
27
37 Maintainers(const std::filesystem::path &SUSE,
38 const std::filesystem::path &linuxRepo,
39 const std::string &origin,
40 const Stanza::TranslateEmail &translateEmail) {
41 loadSUSE(SUSE, translateEmail);
42
43 if (!linuxRepo.empty())
44 loadUpstream(linuxRepo, origin, translateEmail);
45 }
46
52 const Stanza *findBestMatch(const std::set<std::filesystem::path> &paths) const {
53 return findBestMatchInMaintainers(m_maintainers, paths);
54 }
55
60 const Stanza *findBestMatchUpstream(const std::set<std::filesystem::path> &paths) const {
61 return findBestMatchInMaintainers(m_upstream_maintainers, paths);
62 }
63
68 const MaintainersType &maintainers() const { return m_maintainers; }
73 const MaintainersType &upstream_maintainers() const { return m_upstream_maintainers; }
78 const std::set<std::string> &suse_users() const { return m_suse_users; }
79private:
80 void readSUSEStanza(std::ifstream &file, Stanza &st,
81 const Stanza::TranslateEmail &translateEmail);
82 void loadSUSE(const std::filesystem::path &filename,
83 const Stanza::TranslateEmail &translateEmail);
84 void skipIntroUpstream(SlHelpers::GetLine &gl);
85 void readUpstreamStanza(SlHelpers::GetLine &gl, Stanza &st,
86 const Stanza::TranslateEmail &translateEmail);
87 void loadUpstream(const std::filesystem::path &lsource, const std::string &origin,
88 const Stanza::TranslateEmail &translateEmail);
89
90 static const Stanza *findBestMatchInMaintainers(const MaintainersType &sl,
91 const std::set<std::filesystem::path> &paths);
92
93 MaintainersType m_maintainers;
94 MaintainersType m_upstream_maintainers;
95 std::set<std::string> m_suse_users;
96};
97
98}
Parses a string view into lines.
Definition String.h:26
const MaintainersType & upstream_maintainers() const
Get all parsed Linux maintainers.
Definition Maintainers.h:73
const Stanza * findBestMatch(const std::set< std::filesystem::path > &paths) const
Find the best matched maintainer from the SUSE's MAINTAINERS file.
Definition Maintainers.h:52
Maintainers(const std::filesystem::path &SUSE, const std::filesystem::path &linuxRepo, const std::string &origin, const Stanza::TranslateEmail &translateEmail)
Load maintainers info.
Definition Maintainers.h:37
const std::set< std::string > & suse_users() const
Get all met SUSE users.
Definition Maintainers.h:78
const MaintainersType & maintainers() const
Get all parsed SUSE maintainers.
Definition Maintainers.h:68
const Stanza * findBestMatchUpstream(const std::set< std::filesystem::path > &paths) const
Find the best matched maintainer from the Linux's MAINTAINERS file.
Definition Maintainers.h:60
std::vector< Stanza > MaintainersType
Maintainers are a list of stanzas.
Definition Maintainers.h:26
Stanza (a subsystem) from MAINTAINERS file.
Definition Stanza.h:24
std::function< std::string(std::string_view sv)> TranslateEmail
Callback to translate an e-mail.
Definition Stanza.h:27