2024-03-13 20:09:05 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace SourceGit.Models {
|
2024-02-05 23:08:37 -08:00
|
|
|
|
public enum ChangeViewMode {
|
|
|
|
|
List,
|
|
|
|
|
Grid,
|
|
|
|
|
Tree,
|
|
|
|
|
}
|
2021-04-29 05:05:55 -07:00
|
|
|
|
|
2024-02-05 23:08:37 -08:00
|
|
|
|
public enum ChangeState {
|
|
|
|
|
None,
|
|
|
|
|
Modified,
|
|
|
|
|
Added,
|
|
|
|
|
Deleted,
|
|
|
|
|
Renamed,
|
|
|
|
|
Copied,
|
|
|
|
|
Unmerged,
|
|
|
|
|
Untracked
|
|
|
|
|
}
|
2021-04-29 05:05:55 -07:00
|
|
|
|
|
2024-02-05 23:08:37 -08:00
|
|
|
|
public class Change {
|
|
|
|
|
public ChangeState Index { get; set; }
|
|
|
|
|
public ChangeState WorkTree { get; set; } = ChangeState.None;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
public string Path { get; set; } = "";
|
|
|
|
|
public string OriginalPath { get; set; } = "";
|
|
|
|
|
|
|
|
|
|
public bool IsConflit {
|
|
|
|
|
get {
|
2024-02-05 23:08:37 -08:00
|
|
|
|
if (Index == ChangeState.Unmerged || WorkTree == ChangeState.Unmerged) return true;
|
|
|
|
|
if (Index == ChangeState.Added && WorkTree == ChangeState.Added) return true;
|
|
|
|
|
if (Index == ChangeState.Deleted && WorkTree == ChangeState.Deleted) return true;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-05 23:08:37 -08:00
|
|
|
|
public void Set(ChangeState index, ChangeState workTree = ChangeState.None) {
|
2021-04-29 05:05:55 -07:00
|
|
|
|
Index = index;
|
|
|
|
|
WorkTree = workTree;
|
|
|
|
|
|
2024-02-05 23:08:37 -08:00
|
|
|
|
if (index == ChangeState.Renamed || workTree == ChangeState.Renamed) {
|
2024-03-13 20:09:05 -07:00
|
|
|
|
var idx = Path.IndexOf('\t', StringComparison.Ordinal);
|
2021-04-29 05:05:55 -07:00
|
|
|
|
if (idx >= 0) {
|
|
|
|
|
OriginalPath = Path.Substring(0, idx);
|
|
|
|
|
Path = Path.Substring(idx + 1);
|
|
|
|
|
} else {
|
2024-03-13 20:09:05 -07:00
|
|
|
|
idx = Path.IndexOf(" -> ", StringComparison.Ordinal);
|
2021-04-29 05:05:55 -07:00
|
|
|
|
if (idx > 0) {
|
|
|
|
|
OriginalPath = Path.Substring(0, idx);
|
|
|
|
|
Path = Path.Substring(idx + 4);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Path[0] == '"') Path = Path.Substring(1, Path.Length - 2);
|
|
|
|
|
if (!string.IsNullOrEmpty(OriginalPath) && OriginalPath[0] == '"') OriginalPath = OriginalPath.Substring(1, OriginalPath.Length - 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|