Skip to content

Introduce Network.ListReferences(Remote, Credentials) #704

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

Merged
merged 1 commit into from
May 5, 2014

Conversation

someoneigna
Copy link
Contributor

Network.ListReferences(Remote) was marked Obsolete and it's users have been updated to use the new Network.ListReferences(Remote, Credentials).

Fixes #647

@dahlbyk
Copy link
Member

dahlbyk commented May 2, 2014

I think we would want to have a test like https://github.com/libgit2/libgit2sharp/blob/vNext/LibGit2Sharp.Tests/FetchFixture.cs#L50-L66 for the Credentials behavior, otherwise tests shouldn't need to specify credentials.

/// <param name="remote">The <see cref="Remote"/> to list from.</param>
/// <param name="credentials">The <see cref="Credentials"/> used to connect to remote repository.</param>
/// <returns>The references in the <see cref="Remote"/> repository.</returns>
public virtual IEnumerable<DirectReference> ListReferences(Remote remote, Credentials credentials)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the compiler cringe if credentials was null by default?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll copy over my comment:

Do we really want to Obsolete the current method or just have it delegate to the other overload with credentials: null?

I believe the compiler will warn that making credentials optional here would conflict with the existing method.

Though now that I think about it, we've historically not considered adding optional parameters to existing methods to be a breaking change, since the call pattern doesn't change (just need to recompile dependent apps). So maybe we don't need to keep the old method, just add the parameter to it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@someoneigna
Copy link
Contributor Author

What about this one 😃 ?

    [SkippableFact]
    public void CanListRemoteReferencesWithCredentials()
    {
        InconclusiveIf(() => string.IsNullOrEmpty(Constants.PrivateRepoUrl),
            "Populate Constants.PrivateRepo* to run this test");

        string remoteName = "origin";

        string repoPath = InitNewRepository();

        using (var repo = new Repository(repoPath) )
        {
            Remote remote = repo.Network.Remotes.Add(remoteName, Constants.PrivateRepoUrl);

            var references = repo.Network.ListReferences(remote, Constants.PrivateRepoCredentials);

            foreach (var directReference in references)
            {
                Assert.NotNull(directReference);
            }
        }
    }

@nulltoken
Copy link
Member

@someoneigna Could you please reduce the first line of the commit message so that it doesn't exceed 50 chars?

Maybe

Make Network.ListReferences() accept credentials

Fixes #647

@someoneigna
Copy link
Contributor Author

Done 👍

@@ -73,6 +73,29 @@ public void CanListRemoteReferencesFromUrl(string url)
}
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop this trailing whitespace

@nulltoken
Copy link
Member

Once you've tamed those nasty whitespaces, could you please rebase this on top of the latest vNext?

@@ -89,9 +112,9 @@ public void CanListRemoteReferenceObjects()
Remote remote = repo.Network.Remotes[remoteName];
IEnumerable<DirectReference> references = repo.Network.ListReferences(remote);

var actualRefs = new List<Tuple<string,string>>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks unrelated to the scope of this PR. Could you please revert it?

Add CanListRemoteReferencesWithCredentials() test.
@nulltoken nulltoken merged commit 9962cb8 into libgit2:vNext May 5, 2014
@nulltoken nulltoken added this to the v0.18.0 milestone May 5, 2014
@nulltoken
Copy link
Member

Neat!!!! ✨ ✨ ✨

@someoneigna someoneigna deleted the issue_647 branch June 5, 2014 01:04
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

Successfully merging this pull request may close these issues.

4 participants