forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLFSObject.cs
More file actions
22 lines (18 loc) · 686 Bytes
/
LFSObject.cs
File metadata and controls
22 lines (18 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.Text.RegularExpressions;
namespace SourceGit.Models
{
public partial class LFSObject
{
[GeneratedRegex(@"^version https://git-lfs.github.com/spec/v\d+\r?\noid sha256:([0-9a-f]+)\r?\nsize (\d+)[\r\n]*$")]
private static partial Regex REG_FORMAT();
public string Oid { get; set; } = string.Empty;
public long Size { get; set; } = 0;
public static LFSObject Parse(string content)
{
var match = REG_FORMAT().Match(content);
if (match.Success)
return new() { Oid = match.Groups[1].Value, Size = long.Parse(match.Groups[2].Value) };
return null;
}
}
}