SlHelpers
PatchesAuthors.h
1 // SPDX-License-Identifier: GPL-2.0-only
2 
3 #pragma once
4 
5 #include <filesystem>
6 #include <functional>
7 #include <map>
8 #include <string>
9 
10 namespace SlGit {
11 class Commit;
12 class Repo;
13 }
14 
15 namespace SlKernCVS {
16 
24 public:
26  using Map = std::map<std::string, std::map<std::string, unsigned int>>;
28  using InsertUser = std::function<bool (const std::string &email)>;
30  using InsertUFMap = std::function<bool (const std::string &email,
31  const std::filesystem::path &file, unsigned gitFixes, unsigned realFixes)>;
32 
39  PatchesAuthors(const SlGit::Repo &repo, bool dumpRefs, bool reportUnhandled) :
40  repo(&repo), dumpRefs(dumpRefs), reportUnhandled(reportUnhandled)
41  {}
42 
50  bool processAuthors(const SlGit::Commit &commit, const InsertUser &insertUser,
51  const InsertUFMap &insertUFMap);
52 private:
53  PatchesAuthors() : repo(nullptr), dumpRefs(false), reportUnhandled(false) {}
54  friend void testProcessPatch();
55 
56  int processPatch(const std::filesystem::path &file, const std::string &content);
57 
58  const SlGit::Repo *repo;
59  const bool dumpRefs;
60  const bool reportUnhandled;
61  Map m_HoH;
62  Map m_HoHReal;
63  Map m_HoHRefs;
64 };
65 
66 }
Definition: Blob.h:11
PatchesAuthors parses all patches in all ("build") branches in the kernel-source tree and reports who...
Definition: PatchesAuthors.h:23
std::function< bool(const std::string &email, const std::filesystem::path &file, unsigned gitFixes, unsigned realFixes)> InsertUFMap
A callback invoked for e-mail, file, and counts of git-fixes and real changes.
Definition: PatchesAuthors.h:31
The most important Git class.
Definition: Repo.h:45
Commit is a representation of a git commit.
Definition: Commit.h:21
std::map< std::string, std::map< std::string, unsigned int > > Map
E-mail -> file -> count mapping.
Definition: PatchesAuthors.h:26
PatchesAuthors(const SlGit::Repo &repo, bool dumpRefs, bool reportUnhandled)
PatchesAuthors constructor.
Definition: PatchesAuthors.h:39
Definition: Branches.h:15
bool processAuthors(const SlGit::Commit &commit, const InsertUser &insertUser, const InsertUFMap &insertUFMap)
The real work function of this class.
std::function< bool(const std::string &email)> InsertUser
A callback invoked for e-mail.
Definition: PatchesAuthors.h:28