mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-18 08:55:00 +00:00
refactor<*>: rewrite all codes...
This commit is contained in:
parent
89ff8aa744
commit
30ab8ae954
342 changed files with 17208 additions and 19633 deletions
41
src/Commands/QueryLFSObjectChange.cs
Normal file
41
src/Commands/QueryLFSObjectChange.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
namespace SourceGit.Commands {
|
||||
/// <summary>
|
||||
/// 查询LFS对象变更
|
||||
/// </summary>
|
||||
public class QueryLFSObjectChange : Command {
|
||||
private Models.LFSChange change = new Models.LFSChange();
|
||||
|
||||
public QueryLFSObjectChange(string repo, string args) {
|
||||
Cwd = repo;
|
||||
Args = $"diff --ignore-cr-at-eol {args}";
|
||||
}
|
||||
|
||||
public Models.LFSChange Result() {
|
||||
Exec();
|
||||
return change;
|
||||
}
|
||||
|
||||
public override void OnReadline(string line) {
|
||||
var ch = line[0];
|
||||
if (ch == '-') {
|
||||
if (change.Old == null) change.Old = new Models.LFSObject();
|
||||
line = line.Substring(1);
|
||||
if (line.StartsWith("oid sha256:")) {
|
||||
change.Old.OID = line.Substring(11);
|
||||
} else if (line.StartsWith("size ")) {
|
||||
change.Old.Size = int.Parse(line.Substring(5));
|
||||
}
|
||||
} else if (ch == '+') {
|
||||
if (change.New == null) change.New = new Models.LFSObject();
|
||||
line = line.Substring(1);
|
||||
if (line.StartsWith("oid sha256:")) {
|
||||
change.New.OID = line.Substring(11);
|
||||
} else if (line.StartsWith("size ")) {
|
||||
change.New.Size = int.Parse(line.Substring(5));
|
||||
}
|
||||
} else if (line.StartsWith(" size ")) {
|
||||
change.New.Size = change.Old.Size = int.Parse(line.Substring(6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue