Add a method to set bool config
and refactoring
This commit is contained in:
@@ -110,7 +110,7 @@ namespace GitTfs.Commands
|
||||
if (tfsRepositoryPath == GitTfsConstants.TfsRoot)
|
||||
_fetch.BranchStrategy = BranchStrategy.None;
|
||||
|
||||
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, (_fetch.BranchStrategy == BranchStrategy.None).ToString());
|
||||
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, _fetch.BranchStrategy == BranchStrategy.None);
|
||||
|
||||
if (retVal == 0)
|
||||
{
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace GitTfs.Commands
|
||||
private int Run(bool stopOnFailMergeCommit, params string[] args)
|
||||
{
|
||||
if (!FetchAll && BranchStrategy == BranchStrategy.None)
|
||||
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, true.ToString());
|
||||
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, true);
|
||||
|
||||
var remotesToFetch = GetRemotesToFetch(args).ToList();
|
||||
foreach (var remote in remotesToFetch)
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace GitTfs.Commands
|
||||
}
|
||||
}
|
||||
|
||||
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, false.ToString());
|
||||
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, false);
|
||||
}
|
||||
|
||||
private string[] BuildInitCommand()
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace GitTfs.Commands
|
||||
if (CloneAllBranches && NoFetch)
|
||||
throw new GitTfsException("error: --no-fetch cannot be used with --all");
|
||||
|
||||
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, false.ToString());
|
||||
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, false);
|
||||
|
||||
var defaultRemote = InitFromDefaultRemote();
|
||||
|
||||
|
||||
@@ -125,6 +125,11 @@ namespace GitTfs.Core
|
||||
_repository.Config.Set<string>(key, value, ConfigurationLevel.Local);
|
||||
}
|
||||
|
||||
public void SetConfig(string key, bool value)
|
||||
{
|
||||
SetConfig(key, value.ToString().ToLower());
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<IGitTfsRemote> ReadAllTfsRemotes()
|
||||
{
|
||||
|
||||
@@ -475,7 +475,7 @@ namespace GitTfs.Core
|
||||
if (isIgnoringBranchesDetected)
|
||||
Trace.TraceInformation(" if you want to enable branch support, use the command:" + Environment.NewLine
|
||||
+ " git config --local " + GitTfsConstants.IgnoreBranches + " false");
|
||||
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, isIgnoringBranchesDetected.ToString());
|
||||
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, isIgnoringBranchesDetected);
|
||||
return isIgnoringBranchesDetected;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace GitTfs.Core
|
||||
T GetConfig<T>(string key);
|
||||
T GetConfig<T>(string key, T defaultValue);
|
||||
void SetConfig(string key, string value);
|
||||
void SetConfig(string key, bool value);
|
||||
IEnumerable<IGitTfsRemote> ReadAllTfsRemotes();
|
||||
IGitTfsRemote ReadTfsRemote(string remoteId);
|
||||
IGitTfsRemote CreateTfsRemote(RemoteInfo remoteInfo, string autocrlf = null, string ignorecase = null);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace GitTfs.Util
|
||||
/// <param name="mappingFile"></param>
|
||||
public void InitializeConfig(IGitRepository repository, string mappingFile = null)
|
||||
{
|
||||
repository.SetConfig(GitTfsConstants.ExportMetadatasConfigKey, "true");
|
||||
repository.SetConfig(GitTfsConstants.ExportMetadatasConfigKey, true);
|
||||
if (!string.IsNullOrEmpty(mappingFile))
|
||||
{
|
||||
if (File.Exists(mappingFile))
|
||||
|
||||
Reference in New Issue
Block a user