mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-21 02:15:00 +00:00
Merge 409ca380
into fix/file-rename
This commit is contained in:
commit
9553674f1a
6 changed files with 420 additions and 93 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SourceGit.Models
|
||||
{
|
||||
|
@ -9,17 +10,18 @@ namespace SourceGit.Models
|
|||
Tree,
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum ChangeState
|
||||
{
|
||||
None,
|
||||
Modified,
|
||||
TypeChanged,
|
||||
Added,
|
||||
Deleted,
|
||||
Renamed,
|
||||
Copied,
|
||||
Untracked,
|
||||
Conflicted,
|
||||
None = 0,
|
||||
Modified = 1 << 0,
|
||||
TypeChanged = 1 << 1,
|
||||
Added = 1 << 2,
|
||||
Deleted = 1 << 3,
|
||||
Renamed = 1 << 4,
|
||||
Copied = 1 << 5,
|
||||
Untracked = 1 << 6,
|
||||
Conflicted = 1 << 7,
|
||||
}
|
||||
|
||||
public enum ConflictReason
|
||||
|
@ -54,8 +56,8 @@ namespace SourceGit.Models
|
|||
public string ConflictMarker => CONFLICT_MARKERS[(int)ConflictReason];
|
||||
public string ConflictDesc => CONFLICT_DESCS[(int)ConflictReason];
|
||||
|
||||
public string WorkTreeDesc => TYPE_DESCS[(int)WorkTree];
|
||||
public string IndexDesc => TYPE_DESCS[(int)Index];
|
||||
public string WorkTreeDesc => TYPE_DESCS[GetPrimaryState(WorkTree)];
|
||||
public string IndexDesc => TYPE_DESCS[GetPrimaryState(Index)];
|
||||
|
||||
public void Set(ChangeState index, ChangeState workTree = ChangeState.None)
|
||||
{
|
||||
|
@ -88,18 +90,43 @@ namespace SourceGit.Models
|
|||
OriginalPath = OriginalPath.Substring(1, OriginalPath.Length - 2);
|
||||
}
|
||||
|
||||
private static readonly string[] TYPE_DESCS =
|
||||
[
|
||||
"Unknown",
|
||||
"Modified",
|
||||
"Type Changed",
|
||||
"Added",
|
||||
"Deleted",
|
||||
"Renamed",
|
||||
"Copied",
|
||||
"Untracked",
|
||||
"Conflict"
|
||||
];
|
||||
public static ChangeState GetPrimaryState(ChangeState state)
|
||||
{
|
||||
if (state == ChangeState.None)
|
||||
return ChangeState.None;
|
||||
if ((state & ChangeState.Conflicted) != 0)
|
||||
return ChangeState.Conflicted;
|
||||
if ((state & ChangeState.Untracked) != 0)
|
||||
return ChangeState.Untracked;
|
||||
if ((state & ChangeState.Renamed) != 0)
|
||||
return ChangeState.Renamed;
|
||||
if ((state & ChangeState.Copied) != 0)
|
||||
return ChangeState.Copied;
|
||||
if ((state & ChangeState.Deleted) != 0)
|
||||
return ChangeState.Deleted;
|
||||
if ((state & ChangeState.Added) != 0)
|
||||
return ChangeState.Added;
|
||||
if ((state & ChangeState.TypeChanged) != 0)
|
||||
return ChangeState.TypeChanged;
|
||||
if ((state & ChangeState.Modified) != 0)
|
||||
return ChangeState.Modified;
|
||||
|
||||
return ChangeState.None;
|
||||
}
|
||||
|
||||
private static readonly Dictionary<ChangeState, string> TYPE_DESCS = new Dictionary<ChangeState, string>
|
||||
{
|
||||
{ ChangeState.None, "Unknown" },
|
||||
{ ChangeState.Modified, "Modified" },
|
||||
{ ChangeState.TypeChanged, "Type Changed" },
|
||||
{ ChangeState.Added, "Added" },
|
||||
{ ChangeState.Deleted, "Deleted" },
|
||||
{ ChangeState.Renamed, "Renamed" },
|
||||
{ ChangeState.Copied, "Copied" },
|
||||
{ ChangeState.Untracked, "Untracked" },
|
||||
{ ChangeState.Conflicted, "Conflict" }
|
||||
};
|
||||
|
||||
private static readonly string[] CONFLICT_MARKERS =
|
||||
[
|
||||
string.Empty,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue