Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit d916e18

Browse files
Merge branch 'master' into features/publish
2 parents cd55c32 + 88adbf1 commit d916e18

20 files changed

+1131
-306
lines changed

src/GitHub.Api/Git/GitLogEntry.cs

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Text;
45

56
namespace GitHub.Unity
@@ -19,8 +20,8 @@ struct GitLogEntry
1920
public string CommitName;
2021
public string Summary;
2122
public string Description;
22-
public DateTimeOffset Time;
23-
public DateTimeOffset CommitTime;
23+
public string TimeString;
24+
public string CommitTimeString;
2425
public List<GitStatusEntry> Changes;
2526

2627
public string ShortID
@@ -41,11 +42,43 @@ public string PrettyTimeString
4142
}
4243
}
4344

45+
[NonSerialized] public DateTimeOffset? timeValue;
46+
public DateTimeOffset Time
47+
{
48+
get
49+
{
50+
if (!timeValue.HasValue)
51+
{
52+
timeValue = DateTimeOffset.Parse(TimeString);
53+
}
54+
55+
return timeValue.Value;
56+
}
57+
}
58+
59+
[NonSerialized] public DateTimeOffset? commitTimeValue;
60+
public DateTimeOffset? CommitTime
61+
{
62+
get
63+
{
64+
if (!timeValue.HasValue && !string.IsNullOrEmpty(CommitTimeString))
65+
{
66+
commitTimeValue = DateTimeOffset.Parse(CommitTimeString);
67+
}
68+
69+
return commitTimeValue;
70+
}
71+
}
72+
4473
public void Clear()
4574
{
4675
CommitID = MergeA = MergeB = AuthorName = AuthorEmail = Summary = Description = "";
47-
Time = DateTimeOffset.Now;
48-
Changes = new List<GitStatusEntry>();
76+
77+
timeValue = DateTimeOffset.MinValue;
78+
TimeString = timeValue.Value.ToString(DateTimeFormatInfo.CurrentInfo);
79+
80+
commitTimeValue = null;
81+
CommitTimeString = null;
4982
}
5083

5184
public override string ToString()

src/GitHub.Api/Git/GitObjectFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public GitObjectFactory(IEnvironment environment)
1414

1515
public GitStatusEntry CreateGitStatusEntry(string path, GitFileStatus status, string originalPath = null, bool staged = false)
1616
{
17-
var npath = new NPath(path).MakeAbsolute();
18-
var relativePath = npath.RelativeTo(environment.RepositoryPath);
19-
var projectPath = npath.RelativeTo(environment.UnityProjectPath);
17+
var absolutePath = new NPath(path).MakeAbsolute();
18+
var relativePath = absolutePath.RelativeTo(environment.RepositoryPath);
19+
var projectPath = absolutePath.RelativeTo(environment.UnityProjectPath);
2020

21-
return new GitStatusEntry(relativePath, npath, projectPath, status, originalPath?.ToNPath(), staged);
21+
return new GitStatusEntry(relativePath, absolutePath, projectPath, status, originalPath?.ToNPath(), staged);
2222
}
2323

2424
public GitLock CreateGitLock(string path, string user, int id)

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@
221221
<Compile Include="Extensions\UriExtensions.cs" />
222222
<Compile Include="Platform\Platform.cs" />
223223
<Compile Include="Git\GitCredentialManager.cs" />
224+
<Compile Include="UI\FileTreeNode.cs" />
225+
<Compile Include="UI\GitCommitTarget.cs" />
226+
<Compile Include="UI\TreeBuilder.cs" />
224227
</ItemGroup>
225228
<Choose>
226229
<When Condition="$(Buildtype) == 'Internal'">

src/GitHub.Api/GitHub.Api.csproj.DotSettings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=platform/@EntryIndexedValue">True</s:Boolean>
1515
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=primitives/@EntryIndexedValue">True</s:Boolean>
1616
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=process/@EntryIndexedValue">True</s:Boolean>
17-
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=tasks/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
17+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=tasks/@EntryIndexedValue">True</s:Boolean>
18+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=ui/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Text;
45
using System.Text.RegularExpressions;
56

@@ -328,8 +329,8 @@ private void ReturnGitLogEntry()
328329
Summary = summary,
329330
Description = description,
330331
CommitID = commitId,
331-
Time = time.Value,
332-
CommitTime = committerTime.Value
332+
TimeString = time.Value.ToString(DateTimeFormatInfo.CurrentInfo),
333+
CommitTimeString = committerTime.Value.ToString(DateTimeFormatInfo.CurrentInfo)
333334
});
334335
}
335336

src/GitHub.Api/UI/FileTreeNode.cs

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
4+
namespace GitHub.Unity
5+
{
6+
enum CommitState
7+
{
8+
None,
9+
Some,
10+
All
11+
}
12+
13+
class FileTreeNode
14+
{
15+
private List<FileTreeNode> children;
16+
private string path;
17+
private CommitState state;
18+
19+
public object Icon;
20+
public string Label;
21+
public bool Open = true;
22+
public string RepositoryPath;
23+
public GitCommitTarget Target { get; set; }
24+
25+
public FileTreeNode()
26+
{
27+
children = new List<FileTreeNode>();
28+
}
29+
30+
public FileTreeNode(string path)
31+
{
32+
this.path = path ?? "";
33+
Label = this.path;
34+
children = new List<FileTreeNode>();
35+
}
36+
37+
public FileTreeNode Add(FileTreeNode child)
38+
{
39+
children.Add(child);
40+
return child;
41+
}
42+
43+
public CommitState State
44+
{
45+
get
46+
{
47+
if (children == null)
48+
return state;
49+
50+
var commitState = CommitState.None;
51+
if (Target != null)
52+
{
53+
commitState = Target.All ? CommitState.All : Target.Any ? CommitState.Some : CommitState.None;
54+
if (!children.Any())
55+
{
56+
state = commitState;
57+
return state;
58+
}
59+
}
60+
61+
var allCount = children.Count(c => c.State == CommitState.All);
62+
63+
if (allCount == children.Count && (commitState == CommitState.All || Target == null))
64+
{
65+
state = CommitState.All;
66+
return state;
67+
}
68+
69+
if (allCount > 0 || commitState == CommitState.Some)
70+
{
71+
state = CommitState.Some;
72+
return state;
73+
}
74+
75+
var someCount = children.Count(c => c.State == CommitState.Some);
76+
if (someCount > 0 || commitState == CommitState.Some)
77+
{
78+
state = CommitState.Some;
79+
return state;
80+
}
81+
state = CommitState.None;
82+
return state;
83+
}
84+
85+
set
86+
{
87+
if (value == state)
88+
{
89+
return;
90+
}
91+
92+
if (Target != null)
93+
{
94+
if (value == CommitState.None)
95+
{
96+
Target.Clear();
97+
}
98+
else if (value == CommitState.All)
99+
{
100+
Target.All = true;
101+
}
102+
}
103+
104+
state = value;
105+
106+
if (children == null)
107+
{
108+
return;
109+
}
110+
111+
for (var index = 0; index < children.Count; ++index)
112+
{
113+
children[index].State = value;
114+
}
115+
}
116+
}
117+
118+
public string Path
119+
{
120+
get { return path; }
121+
}
122+
123+
public IEnumerable<FileTreeNode> Children
124+
{
125+
get {
126+
if (children == null)
127+
children = new List<FileTreeNode>();
128+
return children;
129+
}
130+
}
131+
132+
private ILogging logger;
133+
protected ILogging Logger
134+
{
135+
get
136+
{
137+
if (logger == null)
138+
logger = Logging.GetLogger(GetType());
139+
return logger;
140+
}
141+
}
142+
}
143+
}

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/GitCommitTarget.cs renamed to src/GitHub.Api/UI/GitCommitTarget.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
using System;
2-
using UnityEngine;
32

43
namespace GitHub.Unity
54
{
65
[Serializable]
76
class GitCommitTarget
87
{
9-
[SerializeField] public bool All = false;
8+
public bool All = false;
109

1110
public void Clear()
1211
{

0 commit comments

Comments
 (0)