Skip to content

When using gitHub flow we don't need to Fetch other branches then master #85

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
Mar 7, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion GitFlowVersion/BuildServers/GitHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace GitFlowVersion.GitFlowVersion
{
using System;
using System.Linq;
using LibGit2Sharp;

Expand All @@ -14,7 +15,8 @@ public static void NormalizeGitDirectory(string gitDirectory)
Logger.WriteInfo(string.Format("Fetching from remote '{0}' using the following refspecs: {1}.",
remote.Name, string.Join(", ", remote.FetchRefSpecs.Select(r => r.Specification))));

repo.Network.Fetch(remote);
var fetchOptions = BuildFetchOptions();
repo.Network.Fetch(remote, fetchOptions);

CreateMissingLocalBranchesFromRemoteTrackingOnes(repo, remote.Name);

Expand All @@ -30,6 +32,21 @@ public static void NormalizeGitDirectory(string gitDirectory)
}
}

static FetchOptions BuildFetchOptions()
{
var username = Environment.GetEnvironmentVariable("GITVERSION_REMOTE_USERNAME");
var password = Environment.GetEnvironmentVariable("GITVERSION_REMOTE_PASSWORD");

var fetchOptions = new FetchOptions();

if (!string.IsNullOrEmpty(username))
{
fetchOptions.Credentials = new Credentials { Username = username, Password = password };
}

return fetchOptions;
}

static void CreateFakeBranchPointingAtThePullRequestTip(Repository repo)
{
var remote = repo.Network.Remotes.Single();
Expand Down