Skip to content
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

Trying to fetch all tags fails #927

Merged
merged 3 commits into from Jan 24, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 32 additions & 7 deletions LibGit2Sharp.Tests/FetchFixture.cs
Expand Up @@ -16,7 +16,9 @@ public class FetchFixture : BaseFixture
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
public void CanFetchIntoAnEmptyRepository(string url)
{
using (var repo = InitIsolatedRepository())
string path = InitNewRepository();

using (var repo = new Repository(path))
{
Remote remote = repo.Network.Remotes.Add(remoteName, url);

Expand Down Expand Up @@ -53,7 +55,9 @@ public void CanFetchIntoAnEmptyRepositoryWithCredentials()
InconclusiveIf(() => string.IsNullOrEmpty(Constants.PrivateRepoUrl),
"Populate Constants.PrivateRepo* to run this test");

using (var repo = InitIsolatedRepository())
string path = InitNewRepository();

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

Expand All @@ -71,7 +75,9 @@ public void CanFetchIntoAnEmptyRepositoryWithCredentials()
[InlineData("git://github.com/libgit2/TestGitRepository.git")]
public void CanFetchAllTagsIntoAnEmptyRepository(string url)
{
using (var repo = InitIsolatedRepository())
string path = InitNewRepository();

using (var repo = new Repository(path))
{
Remote remote = repo.Network.Remotes.Add(remoteName, url);

Expand Down Expand Up @@ -112,7 +118,9 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url)
[InlineData("git://github.com/libgit2/TestGitRepository.git", "master", "first-merge")]
public void CanFetchCustomRefSpecsIntoAnEmptyRepository(string url, string localBranchName, string remoteBranchName)
{
using (var repo = InitIsolatedRepository())
string path = InitNewRepository();

using (var repo = new Repository(path))
{
Remote remote = repo.Network.Remotes.Add(remoteName, url);

Expand All @@ -139,15 +147,17 @@ public void CanFetchCustomRefSpecsIntoAnEmptyRepository(string url, string local
}
}

[Theory(Skip = "Skipping due to recent github handling modification of --include-tag.")]
[Theory]
[InlineData(TagFetchMode.All, 4)]
[InlineData(TagFetchMode.None, 0)]
[InlineData(TagFetchMode.Auto, 3)]
//[InlineData(TagFetchMode.Auto, 3)] // TODO: Skipping due to github modification of --include-tag handling."
Copy link
Member Author

Choose a reason for hiding this comment

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

@carlosmn git fetch against a newly initialized repository with the following config

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[remote "origin"]
    url = https://github.com/libgit2/TestGitRepository
    fetch = +refs/heads/*:refs/remotes/origin/*

outputs

$ git fetch
remote: Counting objects: 68, done.
remote: Total 68 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (68/68), done.
From https://github.com/libgit2/TestGitRepository
 * [new branch]      first-merge -> origin/first-merge
 * [new branch]      master     -> origin/master
 * [new branch]      no-parent  -> origin/no-parent
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 1 (delta 0)
Unpacking objects: 100% (1/1), done.
 * [new tag]         annotated_tag -> annotated_tag
 * [new tag]         blob       -> blob
 * [new tag]         commit_tree -> commit_tree

Aren't we missing something in the way we handle the auto mode?

Copy link
Member

Choose a reason for hiding this comment

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

git is noticing that the server did not automatically send the tags and is performing a second fetch. This second fetch is completely different from the first one, so atm I don't think libgit2 should emulate that behaviour since we implement the underlying functionality, not the UI git wants to provide.

Copy link
Member Author

Choose a reason for hiding this comment

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

@carlosmn Thanks for this explanation. Do you think LibGit2Sharp should mimic git behavior?

/cc @ethomson @jamill @dahlbyk @Therzok

Copy link
Member

Choose a reason for hiding this comment

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

I think so - or at least a way to have it fetch with "expected" behavior. If someone wanted the "underlying functionality" behavior, maybe we could expose that as an advanced method.

As a writer of an application calling into lg2#'s fetch, I would expect for it to fetch tags (and not have to handle that in my application).

Copy link
Member Author

Choose a reason for hiding this comment

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

Created #936 to keep track of this.

public void FetchRespectsConfiguredAutoTagSetting(TagFetchMode tagFetchMode, int expectedTagCount)
{
string url = "http://github.com/libgit2/TestGitRepository";

using (var repo = InitIsolatedRepository())
string path = InitNewRepository();

using (var repo = new Repository(path))
{
Remote remote = repo.Network.Remotes.Add(remoteName, url);
Assert.NotNull(remote);
Expand All @@ -163,5 +173,20 @@ public void FetchRespectsConfiguredAutoTagSetting(TagFetchMode tagFetchMode, int
Assert.Equal(expectedTagCount, repo.Tags.Count());
}
}

[Fact]
public void CanFetchAllTagsAfterAnInitialClone()
{
var scd = BuildSelfCleaningDirectory();

const string url = "https://github.com/libgit2/TestGitRepository";

string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath);

using (var repo = new Repository(clonedRepoPath))
{
repo.Fetch("origin", new FetchOptions { TagFetchMode = TagFetchMode.All });
}
}
}
}