LibGit2Sharp - The current branch is configured to

2019-08-13 17:23发布

I'm using LibGit2Sharp and after cloning the repository and try to call the PULL command, always gives the same error. I've tried to use checkout, reset, merging and not changed.

public void RecuperarRepositorio()
{
    if (!Directory.Exists(DS_CAMINHO_DESTINO + @"\.git"))
        CriarRepositorio();
    else
        AtualizarRepositorio();
}

private void CriarRepositorio()
{
    var path = Repository.Clone(DS_CAMINHO_GIT, DS_CAMINHO_DESTINO, RetornaCloneOptions());
}

private void AtualizarRepositorio()
{
    using (var repo = new Repository(DS_CAMINHO_DESTINO + @"\.git\"))
    {
        foreach (Remote remote in repo.Network.Remotes)
            repo.Network.Fetch(remote, RetornaPullOptions().FetchOptions);

        repo.Network.Pull(RetornaAssinatura(), RetornaPullOptions());
    }
}

private CloneOptions RetornaCloneOptions()
{
    var co = new CloneOptions();
    co.BranchName = NM_BRANCH;
    co.CredentialsProvider = (_url, _user, _cred) => RetornaCredencial();
    co.CertificateCheck += delegate(Certificate certificate, bool valid, string host) { return true; }; 
    return co;
}

private PullOptions RetornaPullOptions()
{
    var po = new PullOptions();
    po.FetchOptions = new FetchOptions();
    po.FetchOptions.TagFetchMode = TagFetchMode.All;
    po.FetchOptions.CredentialsProvider = (_url, _user, _cred) => RetornaCredencial();
    po.FetchOptions.CertificateCheck += delegate(Certificate certificate, bool valid, string host) { return true; };
    po.MergeOptions = new MergeOptions();
    po.MergeOptions.FileConflictStrategy = CheckoutFileConflictStrategy.Theirs;
    return po;
}

0条回答
登录 后发表回答