Skip to content

Refactored Network.Fetch() with FetchOptions #584

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
Dec 12, 2013

Conversation

Yogu
Copy link
Contributor

@Yogu Yogu commented Dec 10, 2013

Changed the signature to Network.Fetch(Remote, FetchOptions).

As of #536,

optional parameters should be grouped in a xxxOptions type.

Network.Fetch() has currently 5 optional parameters, and a sixth one (RefSpecs) will be introduced in #572. I think a FetchOptions class is by far more clear.

I'm not sure if we should keep tests for the obsolete syntax.

/// </summary>
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
/// <param name="remoteName">The name of the <see cref="Remote"/> to fetch from.</param>
public static void Fetch(this IRepository repository, string remoteName)
Copy link
Member

Choose a reason for hiding this comment

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

How about dropping this overload...

Copy link
Member

Choose a reason for hiding this comment

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

...And replacing the call in FetchHeadFixture.cs with the following?

repo.Network.Fetch(repo.Network.Remotes["origin"]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't you think that some production code is using Repository.Fetch(string)? We would break that without notice.

We would have to keep this hack in Network.Fetch(Remote) anyway, otherwise that statement would now work, either. In the end, when the obsolete overloads are removed, we can drop them both.

Copy link
Member

Choose a reason for hiding this comment

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

Could you update the "obsoleted" method to call the updated API (e.g. create the FetchOptions object from the input parameters)? That way you would not need a separate 2 parameter method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does not help. A call to Fetch(string) would still be ambiguous, because there is a Fetch(string, [TagFetchMode], ...) and a Fetch(string, [FetchOptions]) overload. The compiler does not know which one to pick, because both accept a single string argument, and neither of them gets precedence. Only a Fetch(string) overload is favored over these two, and eliminates the error.

Copy link
Member

Choose a reason for hiding this comment

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

Duh. Let's keep it that way, then.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes - that is correct!

@Yogu
Copy link
Contributor Author

Yogu commented Dec 12, 2013

Rebased, merged in 1374884 ( Network.Fetch(url, refspecs)), addressed @dahlbyk's comment on #585 and changed FetchOptions documentation for TagFetchMode and the callbacks.

Changed the signature to Network.Fetch(Remote, FetchOptions). As of
libgit2#536, optional parameters should be grouped in a xxxOptions type.
Network.Fetch() has currently 5 optional parameters, and a sixth one
(RefSpecs) will be introduced soon.
@nulltoken nulltoken merged commit dea2d7b into libgit2:vNext Dec 12, 2013
@nulltoken
Copy link
Member

💯 ✨

@dahlbyk
Copy link
Member

dahlbyk commented Dec 13, 2013

addressed @dahlbyk's comment on #585

Love it

@Yogu Yogu deleted the fetch-options branch December 13, 2013 14:30
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.

5 participants