Replace GitSharp in GitCommit and GitTreeEntry
The paths returned from LibGit2Sharp are platform dependent, while the paths returned from TFS are URIs that use a forward slash.
This commit is contained in:
@@ -63,7 +63,7 @@ namespace Sep.Git.Tfs.Commands
|
||||
{
|
||||
_stdout.WriteLine("Comparing TFS changeset " + changeset.ChangesetId + " to git commit " + changeset.GitCommit);
|
||||
var tfsTree = changeset.Remote.GetChangeset(changeset.ChangesetId).GetTree().ToDictionary(entry => entry.FullName.ToLowerInvariant());
|
||||
var gitTree = changeset.Remote.Repository.GetCommit(changeset.GitCommit).GetTree().ToDictionary(entry => entry.Entry.FullName.ToLowerInvariant());
|
||||
var gitTree = changeset.Remote.Repository.GetCommit(changeset.GitCommit).GetTree().ToDictionary(entry => entry.Entry.Path.ToLowerInvariant());
|
||||
|
||||
var all = tfsTree.Keys.Union(gitTree.Keys);
|
||||
var inBoth = tfsTree.Keys.Intersect(gitTree.Keys);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using GitSharp.Core;
|
||||
using LibGit2Sharp;
|
||||
|
||||
namespace Sep.Git.Tfs.Core
|
||||
{
|
||||
@@ -16,23 +16,23 @@ namespace Sep.Git.Tfs.Core
|
||||
|
||||
public IEnumerable<GitTreeEntry> GetTree()
|
||||
{
|
||||
var treesToDescend = new Queue<Tree>(new[] {_commit.TreeEntry});
|
||||
var treesToDescend = new Queue<Tree>(new[] {_commit.Tree});
|
||||
while(treesToDescend.Any())
|
||||
{
|
||||
var currentTree = treesToDescend.Dequeue();
|
||||
foreach(var entry in currentTree.Members)
|
||||
foreach(var entry in currentTree)
|
||||
{
|
||||
if(entry is Tree)
|
||||
if(entry.Type == GitObjectType.Tree)
|
||||
{
|
||||
treesToDescend.Enqueue((Tree) entry);
|
||||
treesToDescend.Enqueue((Tree)entry.Target);
|
||||
}
|
||||
else if (entry is FileTreeEntry)
|
||||
else if (entry.Type == GitObjectType.Blob)
|
||||
{
|
||||
yield return new GitTreeEntry((FileTreeEntry)entry);
|
||||
yield return new GitTreeEntry(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
Trace.WriteLine("Not including " + entry.FullName + ": type is " + entry.GetType().Name);
|
||||
Trace.WriteLine("Not including " + entry.Name + ": type is " + entry.GetType().Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,8 +224,7 @@ namespace Sep.Git.Tfs.Core
|
||||
|
||||
public GitCommit GetCommit(string commitish)
|
||||
{
|
||||
GitSharp.Core.Repository repo = new GitSharp.Core.Repository(new DirectoryInfo(GitDir));
|
||||
return _container.With(repo.MapCommit(commitish)).GetInstance<GitCommit>();
|
||||
return new GitCommit(_repository.Lookup<Commit>(commitish));
|
||||
}
|
||||
|
||||
public IEnumerable<TfsChangesetInfo> GetLastParentTfsCommits(string head)
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Sep.Git.Tfs.Core
|
||||
if(!tfsPath.StartsWith(TfsRepositoryPath,StringComparison.InvariantCultureIgnoreCase)) return null;
|
||||
tfsPath = tfsPath.Substring(TfsRepositoryPath.Length);
|
||||
while (tfsPath.StartsWith("/"))
|
||||
tfsPath = tfsPath.Substring(1);
|
||||
tfsPath = tfsPath.Substring(1).Replace("/","\\");
|
||||
return tfsPath;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
using System.IO;
|
||||
using GitSharp.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
using LibGit2Sharp;
|
||||
|
||||
namespace Sep.Git.Tfs.Core
|
||||
{
|
||||
public class GitTreeEntry : ITreeEntry
|
||||
{
|
||||
private readonly FileTreeEntry _entry;
|
||||
private readonly TreeEntry _entry;
|
||||
|
||||
public GitTreeEntry(FileTreeEntry entry)
|
||||
public GitTreeEntry(TreeEntry entry)
|
||||
{
|
||||
_entry = entry;
|
||||
}
|
||||
@@ -16,12 +17,17 @@ namespace Sep.Git.Tfs.Core
|
||||
|
||||
public string FullName
|
||||
{
|
||||
get { return _entry.FullName; }
|
||||
get { return _entry.Path; }
|
||||
}
|
||||
|
||||
public Stream OpenRead()
|
||||
{
|
||||
return new MemoryStream(_entry.OpenReader().CachedBytes);
|
||||
if (_entry.Type == GitObjectType.Blob)
|
||||
{
|
||||
return ((Blob)_entry.Target).ContentStream;
|
||||
}
|
||||
else
|
||||
throw new InvalidOperationException("Invalid object type");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ namespace Sep.Git.Tfs.Core
|
||||
{
|
||||
if(item.DeletionId == 0)
|
||||
{
|
||||
// Download the content directly into the index as a blob:
|
||||
// Download the content directly into the git database as a blob:
|
||||
using (var temp = item.DownloadFile())
|
||||
{
|
||||
index.Update(Mode.NewFile, pathInGitRepo, temp);
|
||||
|
||||
Reference in New Issue
Block a user