-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitmetadata.cs
49 lines (40 loc) · 1.36 KB
/
gitmetadata.cs
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.VisualStudio.Services.Search.Extensions.Libraries.reSearch.Core.IndexingMetadata
{
public class GitMetadata
{
public string BranchName { get; private set; }
public string CollectionName { get; private set; }
public Uri RepositoryUri { get; private set; }
public string Ref { get; private set; }
protected GitMetadata()
{
}
public static GitMetadata ReadFromFile(string path)
{
var lines = File.ReadAllLines(path);
if (lines.Length < 4) throw new IOException("Incomplete GitMetadata: " + path);
return CreateFromLines(lines);
}
public static GitMetadata CreateFromString(string content)
{
return CreateFromLines(ConfigHelper.GetLinesFromString(content));
}
public static GitMetadata CreateFromLines(IList<string> lines)
{
if (lines.Count < 4) throw new IOException("Incomplete GitMetadata");
return new GitMetadata()
{
BranchName = lines[2],
CollectionName = lines[1],
RepositoryUri = new Uri(lines[0]),
Ref = lines[3]
};
}
}
}