When no value found in the git config file, use the default one specified
This commit is contained in:
@@ -87,6 +87,11 @@ namespace Sep.Git.Tfs.Core
|
||||
}
|
||||
|
||||
public T GetConfig<T>(string key)
|
||||
{
|
||||
return GetConfig(key, default(T));
|
||||
}
|
||||
|
||||
public T GetConfig<T>(string key, T defaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -95,10 +100,9 @@ namespace Sep.Git.Tfs.Core
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return default(T);
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetConfig(string key, string value)
|
||||
{
|
||||
_repository.Config.Set<string>(key, value, ConfigurationLevel.Local);
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Sep.Git.Tfs.Core
|
||||
string GitDir { get; set; }
|
||||
string GetConfig(string key);
|
||||
T GetConfig<T>(string key);
|
||||
T GetConfig<T>(string key, T defaultValue);
|
||||
void SetConfig(string key, string value);
|
||||
IEnumerable<IGitTfsRemote> ReadAllTfsRemotes();
|
||||
IGitTfsRemote ReadTfsRemote(string remoteId);
|
||||
|
||||
@@ -31,11 +31,7 @@ namespace Sep.Git.Tfs.Util
|
||||
if (_overrides.ContainsKey(key))
|
||||
return (T) _overrides[key];
|
||||
|
||||
var configEntry = _globals.Repository.GetConfig<T>(key);
|
||||
if (configEntry != null)
|
||||
return configEntry;
|
||||
|
||||
return defaultValue;
|
||||
return _globals.Repository.GetConfig<T>(key, defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user