Skip to content

Commands.Pull stopped working in 0.27.0-preview-0102 #1898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mikasoukhov opened this issue Jul 27, 2021 · 3 comments
Closed

Commands.Pull stopped working in 0.27.0-preview-0102 #1898

mikasoukhov opened this issue Jul 27, 2021 · 3 comments

Comments

@mikasoukhov
Copy link

mikasoukhov commented Jul 27, 2021

Commands.Pull stopped working on cloned repos with an access token in URL (https://testToken:[email protected]/myproj/myproj.git). Without access token in URL it works.

Reproduction steps

using var repository = new Repository(args[0]);
SyncRepo(repository);

		private static void SyncRepo(Repository repository)
		{
			var signature = new Signature("invalid signature. not used for fast forward merge.", "[email protected]", DateTimeOffset.Now);
			var pullOptions = new PullOptions
			{
				MergeOptions = new MergeOptions { FastForwardStrategy = FastForwardStrategy.FastForwardOnly }
			};
			var result = Commands.Pull(repository, signature, pullOptions);

			if (result.Status != MergeStatus.FastForward && result.Status != MergeStatus.UpToDate)
				throw new InvalidOperationException($"unexpected pull status {result.Status}");
		}

Expected behavior

A pull must be done

Actual behavior

Unhandled exception. LibGit2Sharp.LibGit2SharpException: No error message has been provided by the native library
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteHandle remote, IEnumerable`1 refSpecs, GitFetchOptions fetchOptions, String logMessage)
   at LibGit2Sharp.Commands.Fetch(Repository repository, String remote, IEnumerable`1 refspecs, FetchOptions options, String logMessage)
   at LibGit2Sharp.Commands.Pull(Repository repository, Signature merger, PullOptions options)
   at ConsoleApp1.Program.SyncRepo(Repository repository, String username, String password) in C:\StockSharp\Web\ConsoleApp1\Program.cs:line 58
   at ConsoleApp1.Program.Main(String[] args) in C:\StockSharp\Web\ConsoleApp1\Program.cs:line 14

Version of LibGit2Sharp (release number or SHA1)

0.27.0-preview-0102

Operating system(s) tested; .NET runtime tested

Windows 2019, Windows 10 (.NET 5.0)

@davesearle
Copy link

davesearle commented Aug 2, 2021

I'm also seeing the same issue, although I'm setting the CredentialsProvider in the FetchOptions:

var pullOptions = new PullOptions
{
    MergeOptions = new MergeOptions
    {
        FastForwardStrategy = FastForwardStrategy.Default
    },
    FetchOptions = new FetchOptions
    {
        CredentialsProvider = new CredentialsHandler(
            (url, usernameFromUrl, types) =>
                new UsernamePasswordCredentials
                {
                    Username = "...",
                    Password = "..."
                })
    }
};

var mergeResult = Commands.Pull(
    repo,
    new Signature("name", "[email protected]", DateTimeOffset.Now),
    pullOptions
);

Version: 0.27.0-preview-0102, Windows 10, .NET 5.0

@davesearle
Copy link

If I change the CredentialsProvider to use DefaultCredentials() then my issue is resolved, which leads me to believe it is related to issue #1871

@mikasoukhov
Copy link
Author

I don't use any credential providers. It is anonymous request with embedded credentials inside url.

The issue reproduced on the lowest layer - libgit2. I've tried use directly - same behaviour. You can see the link to read more information. Sharp wrapper is not the reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants