Add a method to set bool config

and refactoring
This commit is contained in:
Philippe Miossec
2018-01-27 13:09:59 +01:00
parent 81bb9de628
commit 445722e702
8 changed files with 12 additions and 6 deletions
+1 -1
View File
@@ -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)
{
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -149,7 +149,7 @@ namespace GitTfs.Commands
}
}
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, false.ToString());
_globals.Repository.SetConfig(GitTfsConstants.IgnoreBranches, false);
}
private string[] BuildInitCommand()
+1 -1
View File
@@ -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();
+5
View File
@@ -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()
{
+1 -1
View File
@@ -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;
}
+1
View File
@@ -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))