-
Notifications
You must be signed in to change notification settings - Fork 5
/
who.h
72 lines (58 loc) · 1.23 KB
/
who.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright (c) 2017 SUSE Linux GmbH
*
* Licensed under the GNU General Public License Version 2
* as published by the Free Software Foundation.
*
* See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* for details.
*
* Author: Joerg Roedel <[email protected]>
*/
#ifndef __WHO_H
#define __WHO_H
#include <vector>
#include <string>
#include <map>
#include <set>
#include <git2.h>
struct person {
std::string name;
int count;
bool operator<(const struct person &p) const
{
return count < p.count;
}
};
struct people {
std::vector<struct person> persons;
inline void add_one(const struct person &p)
{
for (auto &i : persons) {
if (p.name == i.name) {
i.count += p.count;
return;
}
}
persons.push_back(p);
}
inline struct people &operator+(const struct people &p)
{
for (auto &i : p.persons)
add_one(i);
return *this;
}
};
class git_who {
private:
std::map<std::string, struct people> path_map;
std::set<std::string> paths;
bool get_paths_from_commit(git_commit*, size_t);
public:
void add_path(std::string);
int load_path_map(std::string);
void match_paths(struct people &results);
bool get_paths_from_revision(git_repository*, std::string);
void reset(void);
};
#endif /* __WHO_H */