libgit2 / libgit2/libgit2sharp
Index.Remove with directory/pattern does not always work
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- C#
- Estrelas
- 3.5k
- Forks
- 925
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
The problem could be related to the commit operation but I'm not sure. If instead of repo.Index.Remove("*") you pass the filename, it is correctly removed from the Index.
Also if you commit the file using the console git client the * version starts working correctly.
For reproduction please see the following unit test:
using LibGit2Sharp;
using NUnit.Framework;
using System;
using System.IO;
using System.Linq;
namespace Tests
{
public class LibGitTest
{
[Test]
public void TestRemove()
{
var tempPath = Path.Combine(Path.GetTempPath(), "LibGitTest");
if (Directory.Exists(tempPath))
{
DeleteDirectory(tempPath);
}
Directory.CreateDirectory(tempPath);
using (var repo = new Repository(Repository.Init(tempPath)))
{
File.WriteAllText(Path.Combine(tempPath, "a.txt"), "some text");
repo.Stage("*.*");
var signature = repo.Config.BuildSignature(DateTimeOffset.Now);
repo.Commit("Initial commit", signature, signature);
repo.Index.Remove("*");
// repo.Index.Remove("a.txt"); // uncomment this line to make the test pass
var status = repo.RetrieveStatus();
Assert.Contains("a.txt", status.Removed.Select(entry => entry.FilePath).ToArray());
}
}
private static void DeleteDirectory(string tempPath)
{
// Some files in the .git folder are readonly, I'm not sure whether that's normal, but we need to reset the flag in order to successfully delete the directory
Directory.EnumerateFiles(Path.Combine(tempPath), "*", SearchOption.AllDirectories)
.ForEach(f => File.SetAttributes(f, File.GetAttributes(f) & ~FileAttributes.ReadOnly));
Directory.Delete(tempPath, recursive: true);
}
}
}
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece executando o teste unitário TestRemove e inspecione o comportamento de repo.Index.Remove("*") em comparação com a remoção direta de "a.txt". Rastreie a remoção do índice e o resultado subsequente de RetrieveStatus(), incluindo se a operação de commit afeta a correspondência de padrões. A tarefa estará concluída quando o teste existente passar com a remoção por curinga e o comportamento com o nome de arquivo direto continuar correto.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp, git
- Domínio
- devtools
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 45/100