private IGitTfsRemote InitFromDefaultRemote()
{
IGitTfsRemote defaultRemote;
if (_globals.Repository.HasRemote(GitTfsConstants.DefaultRepositoryId))
defaultRemote = _globals.Repository.ReadTfsRemote(GitTfsConstants.DefaultRepositoryId);
else
defaultRemote = _globals.Repository.ReadAllTfsRemotes()
.Where(x => x != null && x.RemoteInfo != null && !string.IsNullOrEmpty(x.RemoteInfo.Url))
.OrderBy(x => x.RemoteInfo.Url.Length).FirstOrDefault();
if (defaultRemote == null)
throw new GitTfsException("error: No git-tfs repository found. Please try to clone first...\n");
_remoteOptions = new RemoteOptions();
if (!string.IsNullOrWhiteSpace(TfsUsername))
{
_remoteOptions.Username = TfsUsername;
_remoteOptions.Password = TfsPassword;
}
else
{
_remoteOptions.Username = defaultRemote.TfsUsername;
_remoteOptions.Password = defaultRemote.TfsPassword;
}
if (IgnoreRegex != null)
_remoteOptions.IgnoreRegex = IgnoreRegex;
else
_remoteOptions.IgnoreRegex = defaultRemote.IgnoreRegexExpression;
if (ExceptRegex != null)
_remoteOptions.ExceptRegex = ExceptRegex;
else
_remoteOptions.ExceptRegex = defaultRemote.IgnoreExceptRegexExpression;
return defaultRemote;
}