Skip to content
This repository has been archived by the owner on Apr 7, 2023. It is now read-only.

Commit

Permalink
update packages libgit2sharp v0.22 & sqlite v1.0.99
Browse files Browse the repository at this point in the history
  • Loading branch information
Aimeast committed Mar 10, 2016
1 parent e3f97e0 commit ed04aa9
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 53 deletions.
2 changes: 1 addition & 1 deletion GitCandy/Git/CommitsAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected override void Calculate()
using (var repo = new Repository(this.repoPath))
{
result = repo.Commits
.QueryBy(new CommitFilter { Since = commit, SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Time })
.QueryBy(new CommitFilter { IncludeReachableFrom = commit, SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Time })
.PathFilter(path)
.Skip((page - 1) * pageSize)
.Take(pageSize)
Expand Down
10 changes: 6 additions & 4 deletions GitCandy/Git/ContributorsAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected override void Calculate()
{
var commit = repo.Lookup<Commit>(key);
var ancestors = repo.Commits
.QueryBy(new CommitFilter { Since = commit });
.QueryBy(new CommitFilter { IncludeReachableFrom = commit });

var dict = new Dictionary<string, int>();
var statistics = new RepositoryStatisticsModel.Statistics();
Expand All @@ -59,7 +59,7 @@ protected override void Calculate()
statistics.NumberOfContributors++;
}
}
var size = 0;
var size = 0L;
statistics.NumberOfFiles = FilesInCommit(commit, out size);
statistics.SizeOfSource = size;

Expand All @@ -75,12 +75,14 @@ protected override void Calculate()
}
}

private int FilesInCommit(Commit commit, out int sourceSize)
private int FilesInCommit(Commit commit, out long sourceSize)
{
var count = 0;
var stack = new Stack<Tree>();
sourceSize = 0;

var repo = ((IBelongToARepository)commit).Repository;

stack.Push(commit.Tree);
while (stack.Count != 0)
{
Expand All @@ -90,7 +92,7 @@ private int FilesInCommit(Commit commit, out int sourceSize)
{
case TreeEntryTargetType.Blob:
count++;
sourceSize += ((Blob)entry.Target).Size;
sourceSize += repo.ObjectDatabase.RetrieveObjectMetadata(entry.Target.Id).Size;
break;
case TreeEntryTargetType.Tree:
stack.Push((Tree)entry.Target);
Expand Down
41 changes: 21 additions & 20 deletions GitCandy/Git/GitService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
using GitCandy.Configuration;
using GitCandy.Extensions;
using GitCandy.Git.Cache;
using GitCandy.Log;
using GitCandy.Models;
using GitCandy.Schedules;
using ICSharpCode.SharpZipLib.Zip;
using LibGit2Sharp;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
Expand Down Expand Up @@ -76,7 +72,7 @@ public TreeModel GetTree(string path)
?? _repository.Branches.FirstOrDefault();
return new TreeModel
{
ReferenceName = branch == null ? "HEAD" : branch.Name,
ReferenceName = branch == null ? "HEAD" : branch.FriendlyName,
};
}
return null;
Expand Down Expand Up @@ -269,16 +265,21 @@ public CompareModel GetCompare(string start, string end)
if (commit1 == null)
{
commit1 = _repository.Head.Tip;
name1 = _repository.Head.Name;
name1 = _repository.Head.FriendlyName;
}
if (commit2 == null)
{
commit2 = _repository.Head.Tip;
name2 = _repository.Head.Name;
name2 = _repository.Head.FriendlyName;
}

var walks = _repository.Commits
.QueryBy(new CommitFilter { Since = commit2, Until = commit1, SortBy = CommitSortStrategies.Time })
.QueryBy(new CommitFilter
{
IncludeReachableFrom = commit2,
ExcludeReachableFrom = commit1,
SortBy = CommitSortStrategies.Time
})
.Select(s => new CommitModel
{
Sha = s.Sha,
Expand Down Expand Up @@ -401,7 +402,7 @@ public TagsModel GetTags()
where commit != null
select new TagModel
{
ReferenceName = tag.Name,
ReferenceName = tag.FriendlyName,
Sha = tag.Target.Sha,
When = ((Commit)tag.Target).Author.When,
MessageShort = ((Commit)tag.Target).MessageShort.RepetitionIfEmpty(UnknowString),
Expand All @@ -423,7 +424,7 @@ public BranchesModel GetBranches()
var aheadBehinds = accessor.Result.Value;
var model = new BranchesModel
{
Commit = ToCommitModel(head.Tip, head.Name),
Commit = ToCommitModel(head.Tip, head.FriendlyName),
AheadBehinds = aheadBehinds.Select(s => new AheadBehindModel
{
Ahead = s.Ahead,
Expand Down Expand Up @@ -469,7 +470,7 @@ public ContributorsModel GetContributors(string path)
{
contributorsAccessor = GitCacheAccessor.Singleton(new ContributorsAccessor(_repoId, _repository, _repository.Head.Tip));
statistics.Default = contributorsAccessor.Result.Value;
statistics.Default.Branch = _repository.Head.Name;
statistics.Default.Branch = _repository.Head.FriendlyName;
}

var key = CalcBranchesKey(true);
Expand All @@ -491,12 +492,12 @@ public string GetHeadBranch()
var head = _repository.Head;
if (head == null)
return null;
return head.Name;
return head.FriendlyName;
}

public string[] GetLocalBranches()
{
return _repository.Branches.Select(s => s.Name).OrderBy(s => s, new StringLogicalComparer()).ToArray();
return _repository.Branches.Select(s => s.FriendlyName).OrderBy(s => s, new StringLogicalComparer()).ToArray();
}

public bool SetHeadBranch(string name)
Expand All @@ -515,8 +516,8 @@ private BranchSelectorModel GetBranchSelectorModel(string referenceName, string
{
var model = new BranchSelectorModel
{
Branches = _repository.Branches.Select(s => s.Name).OrderBy(s => s, new StringLogicalComparer()).ToList(),
Tags = _repository.Tags.Select(s => s.Name).OrderByDescending(s => s, new StringLogicalComparer()).ToList(),
Branches = _repository.Branches.Select(s => s.FriendlyName).OrderBy(s => s, new StringLogicalComparer()).ToList(),
Tags = _repository.Tags.Select(s => s.FriendlyName).OrderByDescending(s => s, new StringLogicalComparer()).ToList(),
Current = referenceName ?? refer.ToShortSha(),
Path = path,
};
Expand All @@ -531,25 +532,25 @@ private Commit GetCommitByPath(ref string path, out string referenceName)

if (string.IsNullOrEmpty(path))
{
referenceName = _repository.Head.Name;
referenceName = _repository.Head.FriendlyName;
path = "";
return _repository.Head.Tip;
}

path = path + "/";
var p = path;
var branch = _repository.Branches.FirstOrDefault(s => p.StartsWith(s.Name + "/"));
var branch = _repository.Branches.FirstOrDefault(s => p.StartsWith(s.FriendlyName + "/"));
if (branch != null && branch.Tip != null)
{
referenceName = branch.Name;
referenceName = branch.FriendlyName;
path = path.Substring(referenceName.Length).Trim('/');
return branch.Tip;
}

var tag = _repository.Tags.FirstOrDefault(s => p.StartsWith(s.Name + "/"));
var tag = _repository.Tags.FirstOrDefault(s => p.StartsWith(s.FriendlyName + "/"));
if (tag != null && tag.Target is Commit)
{
referenceName = tag.Name;
referenceName = tag.FriendlyName;
path = path.Substring(referenceName.Length).Trim('/');
return (Commit)tag.Target;
}
Expand Down
4 changes: 2 additions & 2 deletions GitCandy/Git/HistoryDivergenceAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected override void Init()
return;

result = repo.Branches
.Where(s => s != head && s.Name != "HEAD")
.Where(s => s != head && s.FriendlyName != "HEAD")
.OrderByDescending(s => s.Tip.Author.When)
.Select(branch =>
{
Expand All @@ -38,7 +38,7 @@ protected override void Init()
{
Ahead = 0,
Behind = 0,
Name = branch.Name,
Name = branch.FriendlyName,
CommitSha = commit.Sha,
AuthorName = commit.Author.Name,
AuthorEmail = commit.Author.Email,
Expand Down
4 changes: 2 additions & 2 deletions GitCandy/Git/ScopeAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ protected override void Calculate()
using (var repo = new Repository(this.repoPath))
{
var ancestors = pathExist
? repo.Commits.QueryBy(new CommitFilter { Since = commit }).PathFilter(path)
: repo.Commits.QueryBy(new CommitFilter { Since = commit });
? repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = commit }).PathFilter(path)
: repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = commit });

var set = new HashSet<string>();
foreach (var ancestor in ancestors)
Expand Down
2 changes: 1 addition & 1 deletion GitCandy/Git/SummaryAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected override void Calculate()
using (var repo = new Repository(this.repoPath))
{
var ancestors = repo.Commits
.QueryBy(new CommitFilter { Since = commit, SortBy = CommitSortStrategies.Topological });
.QueryBy(new CommitFilter { IncludeReachableFrom = commit, SortBy = CommitSortStrategies.Topological });

// null, continue search current reference
// true, have found, done
Expand Down
35 changes: 19 additions & 16 deletions GitCandy/GitCandy.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -90,8 +91,9 @@
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="LibGit2Sharp">
<HintPath>..\packages\LibGit2Sharp.0.15.0.0\lib\net35\LibGit2Sharp.dll</HintPath>
<Reference Include="LibGit2Sharp, Version=0.22.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
<HintPath>..\packages\LibGit2Sharp.0.22.0\lib\net40\LibGit2Sharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -120,13 +122,13 @@
<Reference Include="System.Configuration" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.92.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Data.SQLite.Core.1.0.92.0\lib\net45\System.Data.SQLite.dll</HintPath>
<Reference Include="System.Data.SQLite, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net45\System.Data.SQLite.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Data.SQLite.EF6, Version=1.0.92.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Data.SQLite.EF6.1.0.92.0\lib\net45\System.Data.SQLite.EF6.dll</HintPath>
<Reference Include="System.Data.SQLite.EF6, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.EF6.1.0.99.0\lib\net45\System.Data.SQLite.EF6.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Security" />
Expand Down Expand Up @@ -506,18 +508,19 @@
</ProjectExtensions>
<PropertyGroup>
<PostBuildEvent>
if not exist "$(TargetDir)NativeBinaries" md "$(TargetDir)NativeBinaries"
if not exist "$(TargetDir)NativeBinaries\x86" md "$(TargetDir)NativeBinaries\x86"
xcopy /s /y /d "$(SolutionDir)packages\LibGit2Sharp.0.15.0.0\lib\net35\NativeBinaries\x86\*.*" "$(TargetDir)NativeBinaries\x86"
if not exist "$(TargetDir)NativeBinaries\amd64" md "$(TargetDir)NativeBinaries\amd64"
xcopy /s /y /d "$(SolutionDir)packages\LibGit2Sharp.0.15.0.0\lib\net35\NativeBinaries\amd64\*.*" "$(TargetDir)NativeBinaries\amd64"

xcopy /s /y /d "$(SolutionDir)packages\System.Data.SQLite.Core.1.0.92.0\content\net45\*.*" "$(TargetDir)"
</PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>powershell.exe -ExecutionPolicy Unrestricted "$(ProjectDir)PreBuild.ps1" '$(ProjectDir)'</PreBuildEvent>
</PropertyGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props'))" />
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.99.0\build\net45\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.99.0\build\net45\System.Data.SQLite.Core.targets'))" />
</Target>
<Import Project="..\packages\System.Data.SQLite.Core.1.0.99.0\build\net45\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.99.0\build\net45\System.Data.SQLite.Core.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
2 changes: 1 addition & 1 deletion GitCandy/Models/RepositoryStatisticsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Statistics
public string Branch { get; set; }
public int NumberOfFiles { get; set; }
public int NumberOfCommits { get; set; }
public int SizeOfSource { get; set; }
public long SizeOfSource { get; set; }
public int NumberOfContributors { get; set; }
public ContributorCommits[] OrderedCommits { get; set; }
}
Expand Down
7 changes: 4 additions & 3 deletions GitCandy/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="GitCandyContext" connectionString="Data Source=|DataDirectory|GitCandy.db;" providerName="System.Data.SQLite" />
<add name="GitCandyContext" connectionString="Data Source=|DataDirectory|GitCandy.db;BinaryGUID=True;" providerName="System.Data.SQLite.EF6" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
Expand All @@ -19,8 +19,8 @@
</appSettings>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
<system.web>
Expand Down Expand Up @@ -84,6 +84,7 @@
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
-->
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
</configuration>
7 changes: 4 additions & 3 deletions GitCandy/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<package id="bootstrap" version="2.3.2" targetFramework="net45" />
<package id="EntityFramework" version="6.1.0" targetFramework="net45" />
<package id="jQuery" version="2.0.3" targetFramework="net45" />
<package id="LibGit2Sharp" version="0.15.0.0" targetFramework="net45" />
<package id="LibGit2Sharp" version="0.22.0" targetFramework="net45" />
<package id="LibGit2Sharp.NativeBinaries" version="1.0.129" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.2" targetFramework="net45" />
Expand All @@ -13,7 +14,7 @@
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
<package id="System.Data.SQLite.Core" version="1.0.92.0" targetFramework="net45" />
<package id="System.Data.SQLite.EF6" version="1.0.92.0" targetFramework="net45" />
<package id="System.Data.SQLite.Core" version="1.0.99.0" targetFramework="net45" />
<package id="System.Data.SQLite.EF6" version="1.0.99.0" targetFramework="net45" />
<package id="WebGrease" version="1.5.2" targetFramework="net45" />
</packages>

0 comments on commit ed04aa9

Please sign in to comment.