diff --git a/GitCandy.Web/Base/GitUrlConstraint.cs b/GitCandy.Web/Base/GitUrlConstraint.cs
index c68611b..555a08d 100644
--- a/GitCandy.Web/Base/GitUrlConstraint.cs
+++ b/GitCandy.Web/Base/GitUrlConstraint.cs
@@ -4,7 +4,7 @@ namespace GitCandy.Web.Base;
class GitUrlConstraint : IRouteConstraint
{
- private static HashSet<String> _cache = new HashSet<String>(StringComparer.OrdinalIgnoreCase)
+ private static HashSet<String> _cache = new(StringComparer.OrdinalIgnoreCase)
{
"info/refs","git-upload-pack","git-receive-pack"
};
diff --git a/GitCandy.Web/Controllers/RepositoryController.cs b/GitCandy.Web/Controllers/RepositoryController.cs
index f4b2713..fa2233c 100644
--- a/GitCandy.Web/Controllers/RepositoryController.cs
+++ b/GitCandy.Web/Controllers/RepositoryController.cs
@@ -613,7 +613,7 @@ public class RepositoryController : CandyControllerBase
var result = new List<GitUrl>(4)
{
- new GitUrl { Type = url.Scheme, Url = httpUrl }
+ new() { Type = url.Scheme, Url = httpUrl }
};
//if (UserConfiguration.Current.EnableSsh)
// result.Add(new GitUrl { Type = "ssh", Url = sshUrl });
diff --git a/GitCandy.Web/Data/RepositoryService.cs b/GitCandy.Web/Data/RepositoryService.cs
index 36c7564..aeba0b8 100644
--- a/GitCandy.Web/Data/RepositoryService.cs
+++ b/GitCandy.Web/Data/RepositoryService.cs
@@ -350,7 +350,7 @@ public class RepositoryService
if (user == null)
{
- model.Collaborations = new RepositoryModel[0];
+ model.Collaborations = [];
model.Repositories = ToModels(Repository.GetPublics(param));
}
else
diff --git a/GitCandy.Web/Git/ArchiverAccessor.cs b/GitCandy.Web/Git/ArchiverAccessor.cs
index d4e87b0..34a3e1b 100644
--- a/GitCandy.Web/Git/ArchiverAccessor.cs
+++ b/GitCandy.Web/Git/ArchiverAccessor.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.Contracts;
-using System.IO;
+using System.Diagnostics.Contracts;
using System.IO.Compression;
using System.Text;
using GitCandy.Git.Cache;
@@ -10,88 +7,87 @@ using LibGit2Sharp;
using NewLife;
using NewLife.Reflection;
-namespace GitCandy.Git
+namespace GitCandy.Git;
+
+public class ArchiverAccessor : GitCacheAccessor<String, ArchiverAccessor>
{
- public class ArchiverAccessor : GitCacheAccessor<String, ArchiverAccessor>
- {
- private readonly Commit commit;
- private readonly Encoding[] encodings;
+ private readonly Commit commit;
+ private readonly Encoding[] encodings;
- public ArchiverAccessor(String repoId, Repository repo, Commit commit, params Encoding[] encodings)
- : base(repoId, repo)
- {
- Contract.Requires(commit != null);
- Contract.Requires(encodings != null);
+ public ArchiverAccessor(String repoId, Repository repo, Commit commit, params Encoding[] encodings)
+ : base(repoId, repo)
+ {
+ Contract.Requires(commit != null);
+ Contract.Requires(encodings != null);
- this.commit = commit;
- this.encodings = encodings;
- }
+ this.commit = commit;
+ this.encodings = encodings;
+ }
- public override Boolean IsAsync => false;
+ public override Boolean IsAsync => false;
- protected override String GetCacheKey() => GetCacheKey(commit.Sha);
+ protected override String GetCacheKey() => GetCacheKey(commit.Sha);
- protected override void Init()
- {
- var info = new FileInfo(Path.Combine(GitSetting.Current.CachePath.GetFullPath(), GetCacheFile()));
- if (!info.Directory.Exists) info.Directory.Create();
+ protected override void Init()
+ {
+ var info = new FileInfo(Path.Combine(GitSetting.Current.CachePath.GetFullPath(), GetCacheFile()));
+ if (!info.Directory.Exists) info.Directory.Create();
- result = info.FullName;
- }
+ _result = info.FullName;
+ }
- protected override void Calculate()
+ protected override void Calculate()
+ {
+ using (var zip = ZipFile.Open(_result, ZipArchiveMode.Create))
{
- using (var zip = ZipFile.Open(result, ZipArchiveMode.Create))
- {
- var stack = new Stack<Tree>();
+ var stack = new Stack<Tree>();
- stack.Push(commit.Tree);
- while (stack.Count != 0)
+ stack.Push(commit.Tree);
+ while (stack.Count != 0)
+ {
+ var tree = stack.Pop();
+ foreach (var entry in tree)
{
- var tree = stack.Pop();
- foreach (var entry in tree)
+ switch (entry.TargetType)
{
- switch (entry.TargetType)
- {
- case TreeEntryTargetType.Blob:
- {
- var zipEntry = zip.CreateEntry(entry.Path);
- var ms = zipEntry.Open();
- var blob = (Blob)entry.Target;
- blob.GetContentStream().CopyTo(ms);
- ms.Close();
- break;
- }
- case TreeEntryTargetType.Tree:
- stack.Push((Tree)entry.Target);
+ case TreeEntryTargetType.Blob:
+ {
+ var zipEntry = zip.CreateEntry(entry.Path);
+ var ms = zipEntry.Open();
+ var blob = (Blob)entry.Target;
+ blob.GetContentStream().CopyTo(ms);
+ ms.Close();
+ break;
+ }
+ case TreeEntryTargetType.Tree:
+ stack.Push((Tree)entry.Target);
+ break;
+ case TreeEntryTargetType.GitLink:
+ {
+ var zipEntry = zip.CreateEntry(entry.Path + "/.gitsubmodule");
+ var ms = zipEntry.Open();
+ ms.Write(entry.Target.Sha.GetBytes());
+ ms.Close();
break;
- case TreeEntryTargetType.GitLink:
- {
- var zipEntry = zip.CreateEntry(entry.Path + "/.gitsubmodule");
- var ms = zipEntry.Open();
- ms.Write(entry.Target.Sha.GetBytes());
- ms.Close();
- break;
- }
- }
+ }
}
}
- //zip.SetComment(commit.Sha);
- var sb = new StringBuilder();
- sb.AppendLine(commit.Sha);
- sb.AppendLine(commit.Message);
+ }
+ //zip.SetComment(commit.Sha);
+ var sb = new StringBuilder();
+ sb.AppendLine(commit.Sha);
+ sb.AppendLine(commit.Message);
- var au = commit.Author;
- if (au != null) sb.AppendFormat("{0}({1}) {2}", au.Name, au.Email, au.When.DateTime.ToFullString());
+ var au = commit.Author;
+ if (au != null) sb.AppendFormat("{0}({1}) {2}", au.Name, au.Email, au.When.DateTime.ToFullString());
- var enc = Encoding.Default;
- zip.SetValue("_archiveComment", sb.ToString().GetBytes(enc));
- }
- resultDone = true;
+ var enc = Encoding.Default;
+ zip.SetValue("_archiveComment", sb.ToString().GetBytes(enc));
}
+ _resultDone = true;
+ }
- protected override Boolean Load() => File.Exists(result);
+ protected override Boolean Load() => File.Exists(_result);
- protected override void Save() { }
- }
+ protected override void Save() { }
}
\ No newline at end of file
diff --git a/GitCandy.Web/Git/BlameAccessor.cs b/GitCandy.Web/Git/BlameAccessor.cs
index cddd429..b76dd67 100644
--- a/GitCandy.Web/Git/BlameAccessor.cs
+++ b/GitCandy.Web/Git/BlameAccessor.cs
@@ -40,10 +40,9 @@ namespace GitCandy.Git
protected override void Init()
{
- result = new BlameHunkModel[]
- {
- new BlameHunkModel
- {
+ _result =
+ [
+ new() {
Code = code,
MessageShort = commit.MessageShort.RepetitionIfEmpty(GitService.UnknowString),
Sha = commit.Sha,
@@ -51,7 +50,7 @@ namespace GitCandy.Git
AuthorEmail = commit.Author.Email,
AuthorDate = commit.Author.When,
}
- };
+ ];
}
protected override void Calculate()
@@ -60,7 +59,7 @@ namespace GitCandy.Git
{
var reader = new StringReader(code);
var blame = repo.Blame(path, new BlameOptions { StartingAt = commit });
- result = blame.Select(s => new BlameHunkModel
+ _result = blame.Select(s => new BlameHunkModel
{
Code = reader.ReadLines(s.LineCount),
MessageShort = s.FinalCommit.MessageShort.RepetitionIfEmpty(GitService.UnknowString),
@@ -71,7 +70,7 @@ namespace GitCandy.Git
})
.ToArray();
}
- resultDone = true;
+ _resultDone = true;
}
}
}
diff --git a/GitCandy.Web/Git/Cache/GitCacheAccessor.cs b/GitCandy.Web/Git/Cache/GitCacheAccessor.cs
index 1b7615c..013511e 100644
--- a/GitCandy.Web/Git/Cache/GitCacheAccessor.cs
+++ b/GitCandy.Web/Git/Cache/GitCacheAccessor.cs
@@ -1,9 +1,10 @@
-using System.Diagnostics.Contracts;
-using System.Runtime.Serialization.Formatters.Binary;
+using System.Collections.Concurrent;
+using System.Diagnostics.Contracts;
using GitCandy.Web;
using GitCandy.Web.Extensions;
using LibGit2Sharp;
using NewLife;
+using NewLife.Caching;
using NewLife.Log;
using NewLife.Serialization;
using NewLife.Threading;
@@ -12,18 +13,19 @@ namespace GitCandy.Git.Cache;
public abstract class GitCacheAccessor
{
+ #region 单实例控制
protected static readonly Type[] accessors;
- protected static readonly Object locker = new Object();
- protected static readonly List<GitCacheAccessor> runningList = new List<GitCacheAccessor>();
+ protected static readonly Object locker = new();
+ protected static readonly List<GitCacheAccessor> runningList = [];
+ private static readonly ConcurrentDictionary<String, GitCacheAccessor> _running = [];
+ //private static readonly ICache _cache = new MemoryCache();
protected static Boolean enabled;
- protected Task task;
-
static GitCacheAccessor()
{
- accessors = new[]
- {
+ accessors =
+ [
typeof(ArchiverAccessor),
typeof(BlameAccessor),
typeof(CommitsAccessor),
@@ -33,7 +35,7 @@ public abstract class GitCacheAccessor
typeof(RepositorySizeAccessor),
typeof(ScopeAccessor),
typeof(SummaryAccessor),
- };
+ ];
}
public static T Singleton<T>(T accessor) where T : GitCacheAccessor
@@ -54,6 +56,19 @@ public abstract class GitCacheAccessor
}
}
+ public static T GetOrAdd<T>(T accessor) where T : GitCacheAccessor
+ {
+ var key = $"{accessor.GetType().Name}#{accessor.GetCacheKey()}";
+ return _running.GetOrAdd(key, k =>
+ {
+ accessor.Init();
+ accessor.LoadOrCalculate();
+ return accessor;
+ }) as T;
+ }
+ #endregion
+
+ #region 静态方法
private static TimerX _timer;
private static TimerX _timer2;
public static void Initialize()
@@ -133,12 +148,26 @@ public abstract class GitCacheAccessor
if (Directory.Exists(path)) Directory.Delete(path, true);
}
}
+ #endregion
+
+ #region 属性
+ /// <summary>是否异步处理。默认true</summary>
+ public virtual Boolean IsAsync => true;
+
+ protected Task _task;
+ #endregion
+
+ #region 方法
+ protected abstract String GetCacheKey();
protected void RemoveFromRunningPool()
{
lock (locker)
{
runningList.Remove(this);
+
+ var key = $"{GetType().Name}#{GetCacheKey()}";
+ _running.TryRemove(key, out _);
}
}
@@ -147,7 +176,7 @@ public abstract class GitCacheAccessor
protected virtual void LoadOrCalculate()
{
var loaded = enabled && Load();
- task = loaded
+ _task = loaded
? new Task(() => { })
: new Task(() =>
{
@@ -162,7 +191,7 @@ public abstract class GitCacheAccessor
}
});
- task.ContinueWith(t =>
+ _task.ContinueWith(t =>
{
Task.Delay(TimeSpan.FromMinutes(1.0)).Wait();
RemoveFromRunningPool();
@@ -170,16 +199,16 @@ public abstract class GitCacheAccessor
if (loaded)
{
- task.Start();
+ _task.Start();
}
else if (IsAsync)
{
//Scheduler.Instance.AddJob(new SingleJob(task));
- Task.Run(() => task.Start());
+ Task.Run(() => _task.Start());
}
else
{
- task.Start();
+ _task.Start();
}
}
@@ -189,47 +218,46 @@ public abstract class GitCacheAccessor
protected abstract void Calculate();
- public virtual Boolean IsAsync => true;
-
public static Boolean operator ==(GitCacheAccessor left, GitCacheAccessor right)
{
return ReferenceEquals(left, right)
- || !(left is null) && left.Equals(right)
- || !(right is null) && right.Equals(left);
+ || left is not null && left.Equals(right)
+ || right is not null && right.Equals(left);
}
public static Boolean operator !=(GitCacheAccessor left, GitCacheAccessor right)
{
- return !(left is null) && !left.Equals(right)
- || !(right is null) && !right.Equals(left);
+ return left is not null && !left.Equals(right)
+ || right is not null && !right.Equals(left);
}
public override Boolean Equals(Object obj) => throw new NotImplementedException("Must override this method");
public override Int32 GetHashCode() => throw new NotImplementedException("Must override this method");
+ #endregion
}
public abstract class GitCacheAccessor<TReturn, TAccessor> : GitCacheAccessor
where TAccessor : GitCacheAccessor<TReturn, TAccessor>
{
public static String Name { get; set; }
- //public static int AccessorId { get; private set; }
protected readonly String repoId;
protected readonly Repository repo;
protected readonly String repoPath;
- protected TReturn result;
- protected Boolean resultDone;
+ protected TReturn _result;
+ protected Boolean _resultDone;
protected String cacheKey;
+ /// <summary>结果。获取处理结果</summary>
public GitCacheReturn<TReturn> Result
{
get
{
- if (task != null && !IsAsync)
- task.Wait();
- return new GitCacheReturn<TReturn> { Value = result, Done = resultDone };
+ if (_task != null && !IsAsync)
+ _task.Wait();
+ return new GitCacheReturn<TReturn> { Value = _result, Done = _resultDone };
}
}
@@ -245,8 +273,6 @@ public abstract class GitCacheAccessor<TReturn, TAccessor> : GitCacheAccessor
repoPath = repo.Info.Path;
}
- protected abstract String GetCacheKey();
-
protected virtual String GetCacheKey(params Object[] keys)
{
Contract.Requires(keys != null);
@@ -271,14 +297,12 @@ public abstract class GitCacheAccessor<TReturn, TAccessor> : GitCacheAccessor
try
{
using var fs = File.Open(filename, FileMode.Open);
- //var formatter = new BinaryFormatter();
- //var value = formatter.Deserialize(fs);
- var binary = new Binary { Stream = fs };
+ var binary = new Binary { Stream = fs, UseProperty = false };
var value = binary.Read<TReturn>();
if (value is not null)
{
- result = value;
- resultDone = true;
+ _result = value;
+ _resultDone = true;
return true;
}
}
@@ -289,16 +313,14 @@ public abstract class GitCacheAccessor<TReturn, TAccessor> : GitCacheAccessor
protected override void Save()
{
- if (!resultDone) return;
+ if (!_resultDone) return;
var info = new FileInfo(Path.Combine(GitSetting.Current.CachePath.GetFullPath(), GetCacheFile()));
if (!info.Directory.Exists) info.Directory.Create();
using var fs = info.Create();
- //var formatter = new BinaryFormatter();
- //formatter.Serialize(fs, result);
- var binary = new Binary { Stream = fs };
- binary.Write(result);
+ var binary = new Binary { Stream = fs, UseProperty = false };
+ binary.Write(_result);
fs.Flush();
}
diff --git a/GitCandy.Web/Git/CommitsAccessor.cs b/GitCandy.Web/Git/CommitsAccessor.cs
index 6f14936..959a55b 100644
--- a/GitCandy.Web/Git/CommitsAccessor.cs
+++ b/GitCandy.Web/Git/CommitsAccessor.cs
@@ -1,61 +1,39 @@
-using System;
-using System.Diagnostics.Contracts;
-using System.Linq;
-using GitCandy.Git.Cache;
+using GitCandy.Git.Cache;
using GitCandy.Web.Extensions;
using LibGit2Sharp;
-namespace GitCandy.Git
-{
- public class CommitsAccessor : GitCacheAccessor<RevisionSummaryCacheItem[], CommitsAccessor>
- {
- private readonly Commit commit;
- private readonly String path;
- private readonly Int32 page, pageSize;
-
- public CommitsAccessor(String repoId, Repository repo, Commit commit, String path, Int32 page, Int32 pageSize)
- : base(repoId, repo)
- {
- Contract.Requires(commit != null);
- Contract.Requires(path != null);
- Contract.Requires(page >= 0);
- Contract.Requires(pageSize > 0);
+namespace GitCandy.Git;
- this.commit = commit;
- this.path = path;
- this.page = page;
- this.pageSize = pageSize;
- }
-
- public override Boolean IsAsync => false;
+public class CommitsAccessor(String repoId, Repository repo, Commit commit, String path, Int32 page, Int32 pageSize) : GitCacheAccessor<RevisionSummaryCacheItem[], CommitsAccessor>(repoId, repo)
+{
+ public override Boolean IsAsync => false;
- protected override String GetCacheKey() => GetCacheKey(commit.Sha, path, page, pageSize);
+ protected override String GetCacheKey() => GetCacheKey(commit.Sha, path, page, pageSize);
- protected override void Init() => result = new RevisionSummaryCacheItem[0];
+ protected override void Init() => _result = [];
- protected override void Calculate()
+ protected override void Calculate()
+ {
+ using (var repo = new Repository(repoPath))
{
- using (var repo = new Repository(this.repoPath))
- {
- result = repo.Commits
- .QueryBy(new CommitFilter { IncludeReachableFrom = commit, SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Time })
- .PathFilter(path)
- .Skip((page - 1) * pageSize)
- .Take(pageSize)
- .Select(s => new RevisionSummaryCacheItem
- {
- CommitSha = s.Sha,
- MessageShort = s.MessageShort.RepetitionIfEmpty(GitService.UnknowString),
- AuthorName = s.Author.Name,
- AuthorEmail = s.Author.Email,
- AuthorWhen = s.Author.When,
- CommitterName = s.Committer.Name,
- CommitterEmail = s.Committer.Email,
- CommitterWhen = s.Committer.When,
- })
- .ToArray();
- }
- resultDone = true;
+ _result = repo.Commits
+ .QueryBy(new CommitFilter { IncludeReachableFrom = commit, SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Time })
+ .PathFilter(path)
+ .Skip((page - 1) * pageSize)
+ .Take(pageSize)
+ .Select(s => new RevisionSummaryCacheItem
+ {
+ CommitSha = s.Sha,
+ MessageShort = s.MessageShort.RepetitionIfEmpty(GitService.UnknowString),
+ AuthorName = s.Author.Name,
+ AuthorEmail = s.Author.Email,
+ AuthorWhen = s.Author.When,
+ CommitterName = s.Committer.Name,
+ CommitterEmail = s.Committer.Email,
+ CommitterWhen = s.Committer.When,
+ })
+ .ToArray();
}
+ _resultDone = true;
}
}
diff --git a/GitCandy.Web/Git/ContributorsAccessor.cs b/GitCandy.Web/Git/ContributorsAccessor.cs
index 8e67197..4f60e43 100644
--- a/GitCandy.Web/Git/ContributorsAccessor.cs
+++ b/GitCandy.Web/Git/ContributorsAccessor.cs
@@ -26,9 +26,9 @@ namespace GitCandy.Git
protected override void Init()
{
- result = new RepositoryStatisticsModel.Statistics
+ _result = new RepositoryStatisticsModel.Statistics
{
- OrderedCommits = new RepositoryStatisticsModel.ContributorCommits[0]
+ OrderedCommits = []
};
}
@@ -65,8 +65,8 @@ namespace GitCandy.Git
statistics.OrderedCommits = commits;
- result = statistics;
- resultDone = true;
+ _result = statistics;
+ _resultDone = true;
}
private Int32 FilesInCommit(Commit commit, out Int64 sourceSize)
diff --git a/GitCandy.Web/Git/GitService.cs b/GitCandy.Web/Git/GitService.cs
index 67a15f4..5327f5a 100644
--- a/GitCandy.Web/Git/GitService.cs
+++ b/GitCandy.Web/Git/GitService.cs
@@ -338,7 +338,7 @@ public class GitService : IDisposable
var commit = GetCommitByPath(ref path, out var referenceName);
if (commit == null) return null;
- var commitsAccessor = GitCacheAccessor.Singleton(new CommitsAccessor(_repoId, _repository, commit, path, page, pagesize));
+ var commitsAccessor = GitCacheAccessor.GetOrAdd(new CommitsAccessor(_repoId, _repository, commit, path, page, pagesize));
var scopeAccessor = GitCacheAccessor.Singleton(new ScopeAccessor(_repoId, _repository, commit, path));
var model = new CommitsModel
diff --git a/GitCandy.Web/Git/HistoryDivergenceAccessor.cs b/GitCandy.Web/Git/HistoryDivergenceAccessor.cs
index caf7153..935e61b 100644
--- a/GitCandy.Web/Git/HistoryDivergenceAccessor.cs
+++ b/GitCandy.Web/Git/HistoryDivergenceAccessor.cs
@@ -26,7 +26,7 @@ namespace GitCandy.Git
if (head.Tip == null)
return;
- result = repo.Branches
+ _result = repo.Branches
.Where(s => s != head && s.FriendlyName != "HEAD")
.OrderByDescending(s => s.Tip.Author.When)
.Select(branch =>
@@ -54,7 +54,7 @@ namespace GitCandy.Git
using (var repo = new Repository(this.repoPath))
{
var head = repo.Head;
- foreach (var item in result)
+ foreach (var item in _result)
{
var commit = repo.Branches[item.Name].Tip;
var divergence = repo.ObjectDatabase.CalculateHistoryDivergence(commit, head.Tip);
@@ -62,7 +62,7 @@ namespace GitCandy.Git
item.Behind = divergence.BehindBy ?? 0;
}
}
- resultDone = true;
+ _resultDone = true;
}
}
}
diff --git a/GitCandy.Web/Git/LastCommitAccessor.cs b/GitCandy.Web/Git/LastCommitAccessor.cs
index 529f9ef..25ddf8a 100644
--- a/GitCandy.Web/Git/LastCommitAccessor.cs
+++ b/GitCandy.Web/Git/LastCommitAccessor.cs
@@ -26,7 +26,7 @@ namespace GitCandy.Git
protected override String GetCacheKey() => GetCacheKey(commit.Sha, path);
- protected override void Init() => result = commit.Sha;
+ protected override void Init() => _result = commit.Sha;
protected override void Calculate()
{
@@ -35,7 +35,7 @@ namespace GitCandy.Git
var treeEntry = commit[path];
if (treeEntry == null)
{
- resultDone = true;
+ _resultDone = true;
return;
}
@@ -47,7 +47,7 @@ namespace GitCandy.Git
while (queue.Count > 0)
{
commit = queue.Dequeue();
- result = commit.Sha;
+ _result = commit.Sha;
var has = false;
foreach (var parent in commit.Parents)
{
@@ -62,7 +62,7 @@ namespace GitCandy.Git
if (!has)
break;
}
- resultDone = true;
+ _resultDone = true;
return;
}
}
diff --git a/GitCandy.Web/Git/RepositorySizeAccessor.cs b/GitCandy.Web/Git/RepositorySizeAccessor.cs
index f4f3464..6812403 100644
--- a/GitCandy.Web/Git/RepositorySizeAccessor.cs
+++ b/GitCandy.Web/Git/RepositorySizeAccessor.cs
@@ -22,16 +22,16 @@ namespace GitCandy.Git
protected override String GetCacheKey() => GetCacheKey(key);
- protected override void Init() => result = 0;
+ protected override void Init() => _result = 0;
protected override void Calculate()
{
var info = new DirectoryInfo(this.repoPath);
foreach (var file in info.GetFiles("*", SearchOption.AllDirectories))
{
- result += file.Length;
+ _result += file.Length;
}
- resultDone = true;
+ _resultDone = true;
}
}
}
diff --git a/GitCandy.Web/Git/ScopeAccessor.cs b/GitCandy.Web/Git/ScopeAccessor.cs
index 820b261..95a1cd4 100644
--- a/GitCandy.Web/Git/ScopeAccessor.cs
+++ b/GitCandy.Web/Git/ScopeAccessor.cs
@@ -29,7 +29,7 @@ namespace GitCandy.Git
protected override void Init()
{
- result = new RepositoryScope
+ _result = new RepositoryScope
{
Commits = 0,
Contributors = 0,
@@ -49,12 +49,12 @@ namespace GitCandy.Git
var set = new HashSet<String>();
foreach (var ancestor in ancestors)
{
- result.Commits++;
+ _result.Commits++;
if (set.Add(ancestor.Author.ToString()))
- result.Contributors++;
+ _result.Contributors++;
}
}
- resultDone = true;
+ _resultDone = true;
}
}
}
diff --git a/GitCandy.Web/Git/SummaryAccessor.cs b/GitCandy.Web/Git/SummaryAccessor.cs
index 34fd0fb..f60c21a 100644
--- a/GitCandy.Web/Git/SummaryAccessor.cs
+++ b/GitCandy.Web/Git/SummaryAccessor.cs
@@ -27,7 +27,7 @@ namespace GitCandy.Git
protected override void Init()
{
- result = tree
+ _result = tree
.OrderBy(s => s.TargetType == TreeEntryTargetType.Blob)
.ThenBy(s => s.Name, new StringLogicalComparer())
.Select(s => new RevisionSummaryCacheItem
@@ -54,16 +54,16 @@ namespace GitCandy.Git
// null, continue search current reference
// true, have found, done
// false, search has been interrupted, but waiting for next match
- var status = new Boolean?[result.Length];
- var done = result.Length;
+ var status = new Boolean?[_result.Length];
+ var done = _result.Length;
Commit lastCommit = null;
foreach (var ancestor in ancestors)
{
- for (var index = 0; index < result.Length; index++)
+ for (var index = 0; index < _result.Length; index++)
{
if (status[index] == true)
continue;
- var item = result[index];
+ var item = _result[index];
var ancestorEntry = ancestor[item.Path];
if (ancestorEntry != null && ancestorEntry.Target.Sha == item.TargetSha)
{
@@ -102,7 +102,7 @@ namespace GitCandy.Git
lastCommit = ancestor;
}
}
- resultDone = true;
+ _resultDone = true;
}
}
}