public ConvertedArguments Convert(DiffToolArguments arguments) { string baseSha = arguments.LeftSHA; string headSha = arguments.RightSHA; throwOnEmptySha(new[] { baseSha, headSha }); FileStorageDiffCacheFolder diffFolder = getDiffFolder(baseSha, headSha); Debug.Assert(diffFolder != null); var configValue = GitTools.GetConfigKeyValue(GitTools.ConfigScope.Global, Constants.GitDiffToolConfigKey); if (String.IsNullOrEmpty(configValue.FirstOrDefault())) { throw new ArgumentConversionException("Diff Tool is not registered", null); } string diffToolPath = configValue.FirstOrDefault() .Replace("$LOCAL", diffFolder.LeftSubfolder) .Replace("$REMOTE", diffFolder.RightSubfolder) .Replace("//", "/"); return(new ConvertedArguments(diffToolPath, String.Empty)); }
async private Task handleAuthenticationFailedException(Func <Task> command) { string configKey = "credential.interactive"; string configValue = "always"; GitTools.ConfigScope scope = _gitRepository.ExpectingClone ? GitTools.ConfigScope.Global : GitTools.ConfigScope.Local; string path = _gitRepository.ExpectingClone ? String.Empty : _gitRepository.Path; IEnumerable <string> prevValue = GitTools.GetConfigKeyValue(scope, configKey, path); string prevInteractiveMode = prevValue.Any() ? prevValue.First() : null; // `null` to unset try { GitTools.SetConfigKeyValue(scope, configKey, configValue, path); await command(); } finally { GitTools.SetConfigKeyValue(scope, configKey, prevInteractiveMode, path); } }