forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiffResult.cs
More file actions
112 lines (96 loc) · 3.7 KB
/
Copy pathDiffResult.cs
File metadata and controls
112 lines (96 loc) · 3.7 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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System.Collections.Generic;
using System.IO;
using Avalonia.Media.Imaging;
namespace SourceGit.Models
{
public enum TextDiffLineType
{
None,
Normal,
Indicator,
Added,
Deleted,
}
public class TextRange(int p, int n)
{
public int Start { get; set; } = p;
public int End { get; set; } = p + n - 1;
}
public class TextDiffLine
{
public TextDiffLineType Type { get; set; } = TextDiffLineType.None;
public byte[] RawContent { get; set; } = [];
public string Content { get; set; } = "";
public int OldLineNumber { get; set; } = 0;
public int NewLineNumber { get; set; } = 0;
public List<TextRange> Highlights { get; set; } = new List<TextRange>();
public bool NoNewLineEndOfFile { get; set; } = false;
public string OldLine => OldLineNumber == 0 ? string.Empty : OldLineNumber.ToString();
public string NewLine => NewLineNumber == 0 ? string.Empty : NewLineNumber.ToString();
public TextDiffLine() { }
public TextDiffLine(TextDiffLineType type, string content, byte[] rawContent, int oldLine, int newLine)
{
Type = type;
Content = content;
RawContent = rawContent;
OldLineNumber = oldLine;
NewLineNumber = newLine;
}
}
public partial class TextDiff
{
public List<TextDiffLine> Lines { get; set; } = new List<TextDiffLine>();
public int MaxLineNumber = 0;
public int AddedLines { get; set; } = 0;
public int DeletedLines { get; set; } = 0;
public int OldMode { get; set; } = 0;
public int NewMode { get; set; } = 0;
public string OldHash { get; set; } = string.Empty;
public string NewHash { get; set; } = string.Empty;
}
public class LFSDiff
{
public LFSObject Old { get; set; } = new LFSObject();
public LFSObject New { get; set; } = new LFSObject();
}
public class BinaryDiff
{
public long OldSize { get; set; } = 0;
public long NewSize { get; set; } = 0;
}
public class ImageDiff
{
public Bitmap Old { get; set; } = null;
public Bitmap New { get; set; } = null;
public long OldFileSize { get; set; } = 0;
public long NewFileSize { get; set; } = 0;
public string OldImageSize => Old != null ? $"{Old.PixelSize.Width} x {Old.PixelSize.Height}" : "0 x 0";
public string NewImageSize => New != null ? $"{New.PixelSize.Width} x {New.PixelSize.Height}" : "0 x 0";
}
public class EmptyFile
{
public const string SHA1 = "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391";
public const string SHA256 = "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813";
}
public class NoOrEOLChange;
public class SubmoduleDiff
{
public string FullPath { get; set; } = string.Empty;
public RevisionSubmodule Old { get; set; } = null;
public RevisionSubmodule New { get; set; } = null;
public bool CanOpenDetails => File.Exists(Path.Combine(FullPath, ".git")) &&
Old != null && Old.Commit.Author != User.Invalid &&
New != null && New.Commit.Author != User.Invalid;
}
public class DiffResult
{
public bool IsBinary { get; set; } = false;
public bool IsSubmoduleChange { get; set; } = false;
public string OldHash { get; set; } = string.Empty;
public string NewHash { get; set; } = string.Empty;
public int OldMode { get; set; } = 0;
public int NewMode { get; set; } = 0;
public TextDiff TextDiff { get; set; } = null;
public LFSDiff LFSDiff { get; set; } = null;
}
}