diff --git a/GitCandy.Web/Controllers/RepositoryController.cs b/GitCandy.Web/Controllers/RepositoryController.cs
index 283b52d..cad83de 100644
--- a/GitCandy.Web/Controllers/RepositoryController.cs
+++ b/GitCandy.Web/Controllers/RepositoryController.cs
@@ -389,8 +389,8 @@ namespace GitCandy.Controllers
using (var git = new GitService(owner, name))
{
var model = git.GetCommits(path, page ?? 1, UserConfiguration.Current.Commits);
- //if (model == null)
- // throw new HttpException((int)HttpStatusCode.NotFound, String.Empty);
+ if (model == null)
+ throw new HttpException((Int32)HttpStatusCode.NotFound, String.Empty);
ViewBag.Pager = Pager.Items(model.ItemCount)
.PerPage(UserConfiguration.Current.Commits)
diff --git a/GitCandy.Web/Git/GitService.cs b/GitCandy.Web/Git/GitService.cs
index 9b000e1..245fb0e 100644
--- a/GitCandy.Web/Git/GitService.cs
+++ b/GitCandy.Web/Git/GitService.cs
@@ -111,24 +111,21 @@ namespace GitCandy.Git
: commit[path].Target as Tree;
if (tree == null) return null;
- // 缓存加载摘要
- var summaryAccessor = GitCacheAccessor.Singleton(new SummaryAccessor(_repoId, _repository, commit, tree));
- var items = summaryAccessor.Result.Value;
var entries = (from entry in tree
- join item in items on entry.Name equals item.Name into g
- from item in g
+ //join item in items on entry.Name equals item.Name into g
+ //from item in g
select new TreeEntryModel
{
Name = entry.Name,
Path = entry.Path.Replace('\\', '/'),
Commit = new CommitModel
{
- Sha = item.CommitSha,
- CommitMessageShort = item.MessageShort,
- Author = CreateSafeSignature(item.AuthorName, item.AuthorEmail, item.AuthorWhen),
- Committer = CreateSafeSignature(item.CommitterName, item.CommitterEmail, item.CommitterWhen),
+ //Sha = item.CommitSha,
+ //CommitMessageShort = item.MessageShort,
+ //Author = CreateSafeSignature(item.AuthorName, item.AuthorEmail, item.AuthorWhen),
+ //Committer = CreateSafeSignature(item.CommitterName, item.CommitterEmail, item.CommitterWhen),
},
- Sha = item.CommitSha,
+ //Sha = item.CommitSha,
EntryType = entry.TargetType,
})
.OrderBy(s => s.EntryType == TreeEntryTargetType.Blob)
@@ -137,6 +134,29 @@ namespace GitCandy.Git
model.Entries = entries;
+ // 缓存加载摘要
+ var cfg = UserConfiguration.Current;
+ if (cfg.AllowSummary)
+ {
+ var summaryAccessor = GitCacheAccessor.Singleton(new SummaryAccessor(_repoId, _repository, commit, tree));
+ var items = summaryAccessor.Result.Value;
+ foreach (var entry in entries)
+ {
+ var item = items.FirstOrDefault(e => e.Name == entry.Name);
+ if (item != null)
+ {
+ entry.Commit = new CommitModel
+ {
+ Sha = item.CommitSha,
+ CommitMessageShort = item.MessageShort,
+ Author = CreateSafeSignature(item.AuthorName, item.AuthorEmail, item.AuthorWhen),
+ Committer = CreateSafeSignature(item.CommitterName, item.CommitterEmail, item.CommitterWhen),
+ };
+ entry.Sha = item.CommitSha;
+ }
+ }
+ }
+
// 加载说明文件
model.Readme = entries.FirstOrDefault(s => s.EntryType == TreeEntryTargetType.Blob
&& (s.Name.EqualIgnoreCase("readme.{0}.md".F(CultureInfo.CurrentCulture.Name), "readme", "readme.md")));
@@ -315,6 +335,9 @@ namespace GitCandy.Git
public CommitsModel GetCommits(String path, Int32 page = 1, Int32 pagesize = 20)
{
+ var cfg = UserConfiguration.Current;
+ if (!cfg.AllowCommits) return null;
+
var commit = GetCommitByPath(ref path, out var referenceName);
if (commit == null) return null;
@@ -353,13 +376,14 @@ namespace GitCandy.Git
public BlameModel GetBlame(String path)
{
+ var cfg = UserConfiguration.Current;
+ if (!cfg.AllowBlame) return null;
+
var commit = GetCommitByPath(ref path, out var referenceName);
- if (commit == null)
- return null;
+ if (commit == null) return null;
var entry = commit[path];
- if (entry == null || entry.TargetType != TreeEntryTargetType.Blob)
- return null;
+ if (entry == null || entry.TargetType != TreeEntryTargetType.Blob) return null;
var blob = (Blob)entry.Target;
@@ -428,9 +452,11 @@ namespace GitCandy.Git
public BranchesModel GetBranches()
{
+ var cfg = UserConfiguration.Current;
+ if (!cfg.AllowHistoryDivergence) return new BranchesModel();
+
var head = _repository.Head;
- if (head.Tip == null)
- return new BranchesModel();
+ if (head.Tip == null) return new BranchesModel();
var key = CalcBranchesKey();
var accessor = GitCacheAccessor.Singleton(new HistoryDivergenceAccessor(_repoId, _repository, key));
@@ -459,9 +485,11 @@ namespace GitCandy.Git
public ContributorsModel GetContributors(String path)
{
+ var cfg = UserConfiguration.Current;
+ if (!cfg.AllowContributors) return null;
+
var commit = GetCommitByPath(ref path, out var referenceName);
- if (commit == null)
- return null;
+ if (commit == null) return null;
var contributorsAccessor = GitCacheAccessor.Singleton(new ContributorsAccessor(_repoId, _repository, commit));
var contributors = contributorsAccessor.Result.Value;
diff --git a/GitCandy.Web/Views/Repository/Tree.cshtml b/GitCandy.Web/Views/Repository/Tree.cshtml
index d89560f..2da3437 100644
--- a/GitCandy.Web/Views/Repository/Tree.cshtml
+++ b/GitCandy.Web/Views/Repository/Tree.cshtml
@@ -71,26 +71,36 @@ else
<tbody>
@foreach (var entry in Model.Entries)
{
+ var commit = entry.Commit ?? new CommitModel();
+ var author = commit.Author;
<tr>
<td>
<span title="@entry.Name">
@if (entry.EntryType == TreeEntryTargetType.Tree)
- { <span class="glyphicon glyphicon-folder-close"></span> }
+ {<span class="glyphicon glyphicon-folder-close"></span> }
else if (entry.EntryType == TreeEntryTargetType.Blob)
{ <span class="glyphicon glyphicon-file"></span> }
else if (entry.EntryType == TreeEntryTargetType.GitLink)
{ <i class="glyphicon glyphicon-bookmark"></i> }
else
- { <span class="glyphicon glyphicon-leaf"></span> }
+ { <span class="glyphicon glyphicon-leaf"></span>}
@if (entry.EntryType == TreeEntryTargetType.GitLink)
- { @entry.Name.ShortString(25) }
- else
- { <a href="@Model.GetUrl(entry.EntryType + "", entry.Path)">@entry.Name.ShortString(25)</a> }
+ {@entry.Name.ShortString(25) }
+ else
+ { <a href="@Model.GetUrl(entry.EntryType + "", entry.Path)">@entry.Name.ShortString(25)</a>}
</span>
</td>
- <td><span title="@entry.Commit.CommitMessageShort">@(entry.Commit.Sha == null ? Html.Raw(entry.Commit.CommitMessageShort) : Html.ActionLink(entry.Commit.CommitMessageShort.ShortString(70), "Commit", Html.OverRoute(new { path = entry.Commit.Sha })))</span></td>
- <td title="@entry.Commit.Author">@entry.Commit.Author.Name.ShortString(20)</td>
- <td title="@entry.Commit.Author.When">@entry.Commit.Author.When.LocalDateTime.ToFullString()</td>
+ <td><span title="@commit.CommitMessageShort">@(commit.Sha == null ? Html.Raw(commit.CommitMessageShort) : Html.ActionLink(commit.CommitMessageShort.ShortString(70), "Commit", Html.OverRoute(new { path = commit.Sha })))</span></td>
+ @if (author != null)
+ {
+ <td title="@author">@author.Name.ShortString(20)</td>
+ <td title="@author.When">@author.When.LocalDateTime.ToFullString()</td>
+ }
+ else
+ {
+ <td></td>
+ <td></td>
+ }
</tr>
}
</tbody>
diff --git a/GitCandy.Web/Views/Repository/Tree.generated.cs b/GitCandy.Web/Views/Repository/Tree.generated.cs
index 4194f63..c81cb19 100644
--- a/GitCandy.Web/Views/Repository/Tree.generated.cs
+++ b/GitCandy.Web/Views/Repository/Tree.generated.cs
@@ -568,6 +568,8 @@ WriteLiteral("</div>\r\n </div>\r\n </caption>
#line 72 "..\..\Views\Repository\Tree.cshtml"
foreach (var entry in Model.Entries)
{
+ var commit = entry.Commit ?? new CommitModel();
+ var author = commit.Author;
#line default
@@ -575,40 +577,40 @@ WriteLiteral("</div>\r\n </div>\r\n </caption>
WriteLiteral(" <tr>\r\n <td>\r\n " +
" <span");
-WriteAttribute("title", Tuple.Create(" title=\"", 3887), Tuple.Create("\"", 3906)
+WriteAttribute("title", Tuple.Create(" title=\"", 4013), Tuple.Create("\"", 4032)
- #line 76 "..\..\Views\Repository\Tree.cshtml"
-, Tuple.Create(Tuple.Create("", 3895), Tuple.Create<System.Object, System.Int32>(entry.Name
+ #line 78 "..\..\Views\Repository\Tree.cshtml"
+, Tuple.Create(Tuple.Create("", 4021), Tuple.Create<System.Object, System.Int32>(entry.Name
#line default
#line hidden
-, 3895), false)
+, 4021), false)
);
WriteLiteral(">\r\n");
- #line 77 "..\..\Views\Repository\Tree.cshtml"
+ #line 79 "..\..\Views\Repository\Tree.cshtml"
#line default
#line hidden
- #line 77 "..\..\Views\Repository\Tree.cshtml"
+ #line 79 "..\..\Views\Repository\Tree.cshtml"
if (entry.EntryType == TreeEntryTargetType.Tree)
{
#line default
#line hidden
-WriteLiteral(" <span");
+WriteLiteral("<span");
WriteLiteral(" class=\"glyphicon glyphicon-folder-close\"");
WriteLiteral("></span> ");
- #line 78 "..\..\Views\Repository\Tree.cshtml"
- }
+ #line 80 "..\..\Views\Repository\Tree.cshtml"
+ }
else if (entry.EntryType == TreeEntryTargetType.Blob)
{
@@ -621,7 +623,7 @@ WriteLiteral(" class=\"glyphicon glyphicon-file\"");
WriteLiteral("></span> ");
- #line 80 "..\..\Views\Repository\Tree.cshtml"
+ #line 82 "..\..\Views\Repository\Tree.cshtml"
}
else if (entry.EntryType == TreeEntryTargetType.GitLink)
{
@@ -635,7 +637,7 @@ WriteLiteral(" class=\"glyphicon glyphicon-bookmark\"");
WriteLiteral("></i> ");
- #line 82 "..\..\Views\Repository\Tree.cshtml"
+ #line 84 "..\..\Views\Repository\Tree.cshtml"
}
else
{
@@ -646,11 +648,11 @@ WriteLiteral(" <span");
WriteLiteral(" class=\"glyphicon glyphicon-leaf\"");
-WriteLiteral("></span> ");
+WriteLiteral("></span>");
- #line 84 "..\..\Views\Repository\Tree.cshtml"
- }
+ #line 86 "..\..\Views\Repository\Tree.cshtml"
+ }
#line default
@@ -658,53 +660,53 @@ WriteLiteral("></span> ");
WriteLiteral(" ");
- #line 85 "..\..\Views\Repository\Tree.cshtml"
+ #line 87 "..\..\Views\Repository\Tree.cshtml"
if (entry.EntryType == TreeEntryTargetType.GitLink)
- {
+ {
#line default
#line hidden
- #line 86 "..\..\Views\Repository\Tree.cshtml"
- Write(entry.Name.ShortString(25));
+ #line 88 "..\..\Views\Repository\Tree.cshtml"
+ Write(entry.Name.ShortString(25));
#line default
#line hidden
- #line 86 "..\..\Views\Repository\Tree.cshtml"
- }
- else
- {
+ #line 88 "..\..\Views\Repository\Tree.cshtml"
+ }
+ else
+ {
#line default
#line hidden
WriteLiteral(" <a");
-WriteAttribute("href", Tuple.Create(" href=\"", 4823), Tuple.Create("\"", 4877)
+WriteAttribute("href", Tuple.Create(" href=\"", 4938), Tuple.Create("\"", 4992)
- #line 88 "..\..\Views\Repository\Tree.cshtml"
-, Tuple.Create(Tuple.Create("", 4830), Tuple.Create<System.Object, System.Int32>(Model.GetUrl(entry.EntryType + "", entry.Path)
+ #line 90 "..\..\Views\Repository\Tree.cshtml"
+, Tuple.Create(Tuple.Create("", 4945), Tuple.Create<System.Object, System.Int32>(Model.GetUrl(entry.EntryType + "", entry.Path)
#line default
#line hidden
-, 4830), false)
+, 4945), false)
);
WriteLiteral(">");
- #line 88 "..\..\Views\Repository\Tree.cshtml"
- Write(entry.Name.ShortString(25));
+ #line 90 "..\..\Views\Repository\Tree.cshtml"
+ Write(entry.Name.ShortString(25));
#line default
#line hidden
-WriteLiteral("</a> ");
+WriteLiteral("</a>");
- #line 88 "..\..\Views\Repository\Tree.cshtml"
- }
+ #line 90 "..\..\Views\Repository\Tree.cshtml"
+ }
#line default
@@ -712,71 +714,111 @@ WriteLiteral("</a> ");
WriteLiteral(" </span>\r\n </td>\r\n " +
" <td><span");
-WriteAttribute("title", Tuple.Create(" title=\"", 5027), Tuple.Create("\"", 5067)
+WriteAttribute("title", Tuple.Create(" title=\"", 5141), Tuple.Create("\"", 5175)
- #line 91 "..\..\Views\Repository\Tree.cshtml"
-, Tuple.Create(Tuple.Create("", 5035), Tuple.Create<System.Object, System.Int32>(entry.Commit.CommitMessageShort
+ #line 93 "..\..\Views\Repository\Tree.cshtml"
+, Tuple.Create(Tuple.Create("", 5149), Tuple.Create<System.Object, System.Int32>(commit.CommitMessageShort
#line default
#line hidden
-, 5035), false)
+, 5149), false)
);
WriteLiteral(">");
- #line 91 "..\..\Views\Repository\Tree.cshtml"
- Write(entry.Commit.Sha == null ? Html.Raw(entry.Commit.CommitMessageShort) : Html.ActionLink(entry.Commit.CommitMessageShort.ShortString(70), "Commit", Html.OverRoute(new { path = entry.Commit.Sha })));
+ #line 93 "..\..\Views\Repository\Tree.cshtml"
+ Write(commit.Sha == null ? Html.Raw(commit.CommitMessageShort) : Html.ActionLink(commit.CommitMessageShort.ShortString(70), "Commit", Html.OverRoute(new { path = commit.Sha })));
+
+
+ #line default
+ #line hidden
+WriteLiteral("</span></td>\r\n");
+
+
+ #line 94 "..\..\Views\Repository\Tree.cshtml"
+
+
+ #line default
+ #line hidden
+
+ #line 94 "..\..\Views\Repository\Tree.cshtml"
+ if (author != null)
+ {
#line default
#line hidden
-WriteLiteral("</span></td>\r\n <td");
+WriteLiteral(" <td");
-WriteAttribute("title", Tuple.Create(" title=\"", 5311), Tuple.Create("\"", 5339)
+WriteAttribute("title", Tuple.Create(" title=\"", 5480), Tuple.Create("\"", 5495)
- #line 92 "..\..\Views\Repository\Tree.cshtml"
-, Tuple.Create(Tuple.Create("", 5319), Tuple.Create<System.Object, System.Int32>(entry.Commit.Author
+ #line 96 "..\..\Views\Repository\Tree.cshtml"
+, Tuple.Create(Tuple.Create("", 5488), Tuple.Create<System.Object, System.Int32>(author
#line default
#line hidden
-, 5319), false)
+, 5488), false)
);
WriteLiteral(">");
- #line 92 "..\..\Views\Repository\Tree.cshtml"
- Write(entry.Commit.Author.Name.ShortString(20));
+ #line 96 "..\..\Views\Repository\Tree.cshtml"
+ Write(author.Name.ShortString(20));
#line default
#line hidden
-WriteLiteral("</td>\r\n <td");
+WriteLiteral("</td>\r\n");
+
+WriteLiteral(" <td");
-WriteAttribute("title", Tuple.Create(" title=\"", 5420), Tuple.Create("\"", 5453)
+WriteAttribute("title", Tuple.Create(" title=\"", 5567), Tuple.Create("\"", 5587)
- #line 93 "..\..\Views\Repository\Tree.cshtml"
-, Tuple.Create(Tuple.Create("", 5428), Tuple.Create<System.Object, System.Int32>(entry.Commit.Author.When
+ #line 97 "..\..\Views\Repository\Tree.cshtml"
+, Tuple.Create(Tuple.Create("", 5575), Tuple.Create<System.Object, System.Int32>(author.When
#line default
#line hidden
-, 5428), false)
+, 5575), false)
);
WriteLiteral(">");
- #line 93 "..\..\Views\Repository\Tree.cshtml"
- Write(entry.Commit.Author.When.LocalDateTime.ToFullString());
+ #line 97 "..\..\Views\Repository\Tree.cshtml"
+ Write(author.When.LocalDateTime.ToFullString());
#line default
#line hidden
-WriteLiteral("</td>\r\n </tr>\r\n");
+WriteLiteral("</td>\r\n");
- #line 95 "..\..\Views\Repository\Tree.cshtml"
+ #line 98 "..\..\Views\Repository\Tree.cshtml"
+ }
+ else
+ {
+
+
+ #line default
+ #line hidden
+WriteLiteral(" <td></td>\r\n");
+
+WriteLiteral(" <td></td>\r\n");
+
+
+ #line 103 "..\..\Views\Repository\Tree.cshtml"
+ }
+
+
+ #line default
+ #line hidden
+WriteLiteral(" </tr>\r\n");
+
+
+ #line 105 "..\..\Views\Repository\Tree.cshtml"
}
@@ -785,13 +827,13 @@ WriteLiteral("</td>\r\n </tr>\r\n");
WriteLiteral(" </tbody>\r\n </table>\r\n </div>\r\n");
- #line 99 "..\..\Views\Repository\Tree.cshtml"
+ #line 109 "..\..\Views\Repository\Tree.cshtml"
#line default
#line hidden
- #line 99 "..\..\Views\Repository\Tree.cshtml"
+ #line 109 "..\..\Views\Repository\Tree.cshtml"
if (Model.Readme != null)
{
@@ -817,7 +859,7 @@ WriteLiteral(" class=\"glyphicon glyphicon-list-alt\"");
WriteLiteral("></i> ");
- #line 104 "..\..\Views\Repository\Tree.cshtml"
+ #line 114 "..\..\Views\Repository\Tree.cshtml"
Write(Model.Readme.Name);
@@ -829,7 +871,7 @@ WriteLiteral("</div>\r\n </caption>\r\n <t
WriteLiteral(" ");
- #line 109 "..\..\Views\Repository\Tree.cshtml"
+ #line 119 "..\..\Views\Repository\Tree.cshtml"
Write(Html.Partial("_BlobPreview", Model.Readme));
@@ -839,7 +881,7 @@ WriteLiteral("\r\n </td>\r\n <
" </tbody>\r\n </table>\r\n </div>\r\n");
- #line 115 "..\..\Views\Repository\Tree.cshtml"
+ #line 125 "..\..\Views\Repository\Tree.cshtml"
}
@@ -848,7 +890,7 @@ WriteLiteral("\r\n </td>\r\n <
WriteLiteral(" </div>\r\n");
- #line 117 "..\..\Views\Repository\Tree.cshtml"
+ #line 127 "..\..\Views\Repository\Tree.cshtml"
}
#line default
diff --git a/GitCandy/Configuration/UserConfiguration.cs b/GitCandy/Configuration/UserConfiguration.cs
index 9cea6ad..9b861aa 100644
--- a/GitCandy/Configuration/UserConfiguration.cs
+++ b/GitCandy/Configuration/UserConfiguration.cs
@@ -71,21 +71,25 @@ namespace GitCandy.Configuration
[DisplayName("允许打包。默认true")]
public Boolean AllowArchive { get; set; } = true;
- /// <summary>允许打包。默认true</summary>
- [DisplayName("允许打包。默认true")]
+ /// <summary>允许查看审阅。默认true</summary>
+ [DisplayName("允许查看审阅。默认true")]
public Boolean AllowBlame { get; set; } = true;
- /// <summary>允许打包。默认true</summary>
- [DisplayName("允许打包。默认true")]
+ /// <summary>允许查看提交。默认true</summary>
+ [DisplayName("允许查看提交。默认true")]
public Boolean AllowCommits { get; set; } = true;
- /// <summary>允许打包。默认true</summary>
- [DisplayName("允许打包。默认true")]
+ /// <summary>允许查看贡献者。默认true</summary>
+ [DisplayName("允许查看贡献者。默认true")]
public Boolean AllowContributors { get; set; } = true;
- /// <summary>允许打包。默认true</summary>
- [DisplayName("允许打包。默认true")]
+ /// <summary>允许查看分支差异。默认true</summary>
+ [DisplayName("允许查看分支差异。默认true")]
public Boolean AllowHistoryDivergence { get; set; } = true;
+
+ /// <summary>允许查看摘要。默认true</summary>
+ [DisplayName("允许查看摘要。默认true")]
+ public Boolean AllowSummary { get; set; } = true;
#endregion
protected override void OnNew()