How do I get the path of my last commit files? I have this example method:
private static void RepoListFiles()
{
if (!arguments.ContainsKey("repository"))
{
Error("O repositório ainda não foi informado.");
return;
}
using (repo)
{
if (repo.Head.Commits.Count() < 1)
{
Error("Nenhum Commit existente.");
return;
}
Commit commit = repo.Commits.First();
Tree tree = repo.Lookup<Commit>(commit.Sha).Tree;
Console.WriteLine("\nSha: " + commit.Sha);
if (commit.Author.Name != "Unknow") Console.WriteLine("Autor: " + commit.Author.Name);
if (commit.Committer.Name != "Unknow") Console.WriteLine("Commiter: " + commit.Committer.Name);
Console.WriteLine("Data: " + commit.Author.When); //Commit-Date
Console.WriteLine("Mensagem: " + commit.Message);
Console.WriteLine("---------------------------------");
arquivos = new List<string>();
GetFiles(tree);
/*foreach (TreeEntry treeEntry in tree)
{
Console.WriteLine("Path: " + treeEntry.Path);
Console.WriteLine("Name: " + treeEntry.Name);
Console.WriteLine("---------");
}*/
foreach (string file in arquivos)
{
Console.WriteLine(file);
}
Console.WriteLine("---------------------------------");
}
}
static void CompareTrees()
{
using (repo)
{
Tree commitTree = repo.Head.Tip.Tree;
Tree parentCommitTree = repo.Head.Tip.Parents.Single().Tree;
var changes = repo.Diff.Compare<TreeChanges>(parentCommitTree, commitTree);
TreeEntryChanges treeEntryChanges = changes.Single(c => c.Path == "1.txt");
var patch = repo.Diff.Compare<Patch>(parentCommitTree, commitTree);
}
}
Program:
But the way out does not get me all the way.
Directory structure
c:/teste
| - octocat.txt
| - parentoctocat.txt
| - /outros
| | - octocatblue.txt
| | - octored.txt
In my commit has only the files c:/teste/outros/octored.txt
and c:/teste/outros/octocatblue.txt
added.
But in the output comes all the files.
How do I get only the files added in my commit :
/outros/octocatblue.txt
/outros/octored.txt
[Edited]
Note: I have already been able to get the full path of the file. But I only need the files I've added in commit as $ git add outros/octocatblue.txt
.