forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryAuthors.cs
More file actions
46 lines (40 loc) · 1.29 KB
/
Copy pathQueryAuthors.cs
File metadata and controls
46 lines (40 loc) · 1.29 KB
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
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SourceGit.Commands
{
public class QueryAuthors : Command
{
public QueryAuthors(string repo)
{
WorkingDirectory = repo;
Context = repo;
RaiseError = false;
Args = "log -100000 --all --format=%aN±%aE";
}
public async Task<List<Models.User>> GetResultAsync()
{
var rs = await ReadToEndAsync().ConfigureAwait(false);
if (!rs.IsSuccess)
return [];
var start = 0;
var end = rs.StdOut.IndexOf('\n', start);
var added = new HashSet<string>();
var users = new List<Models.User>();
while (end > 0)
{
var line = rs.StdOut.Substring(start, end - start);
if (!string.IsNullOrEmpty(line) && !added.Contains(line))
{
var user = Models.User.FindOrAdd(line);
users.Add(user);
added.Add(line);
}
start = end + 1;
if (start >= rs.StdOut.Length - 1)
break;
end = rs.StdOut.IndexOf('\n', start);
}
return users;
}
}
}