public BlogService( ILogger <BlogService> logger, IOptions <AppConfig> appConfig, IGitClient gitClient, IMemoryCacheClient memoryCacheClient, IEmailClient emailClient) { _logger = logger; _appConfig = appConfig.Value; _gitClient = gitClient; _emailClient = emailClient; _memoryCacheClient = memoryCacheClient; _tagParser = new BlogTagParser(); _postParser = new BlogPostParser(_appConfig); _categoryParser = new BlogCategoryParser(); _gitConfig = new GitConfig { GitHubRepositoryName = _appConfig.AssetGitHubRepoName, GitHubRepositoryBranch = _appConfig.AssetGitHubRepoBranch, GitHubRepositoryOwner = _appConfig.AssetGitHubRepoOwner, GitHubAccessToken = _appConfig.AssetGitHubRepoApiToken, GitCloneToDir = _appConfig.AssetRepoLocalDir, GitCommitEmail = _appConfig.AssetGitCommitEmail, GitCommitUser = _appConfig.AssetGitCommitUser }; }
public static async Task SetupClient(TestContext context) { generalConfig = GeneralConfig.Instance.Value; var conf = new BacklogJpConfigure(generalConfig.SpaceKey); conf.ApiKey = generalConfig.ApiKey; client = new BacklogClientFactory(conf).NewClient(); var users = await client.GetUsersAsync(); projectKey = generalConfig.ProjectKey; var project = await client.GetProjectAsync(projectKey); projectId = project.Id; gitConfig = GitConfig.Instance.Value; ownUser = await client.GetMyselfAsync(); var numericUserIds = (await client.GetUsersAsync()).ToDictionary(x => x.UserId, x => x.Id); notifiedNumericUserIds = new[] { gitConfig.NotifiedUserId1, gitConfig.NotifiedUserId2, gitConfig.NotifiedUserId3 } .Select(x => numericUserIds[x]) .ToArray(); assigneeUserIds = new[] { gitConfig.AssigneeUserId1, gitConfig.AssigneeUserId2, gitConfig.AssigneeUserId3 } .Select(x => numericUserIds[x]) .ToArray(); }
private void InitialiseGit(GitConfig config, string passwordStorePath) { if (config.UseGit) { try { if (config.SyncMode == SyncMode.NativeGit) { git = new Git(passwordStorePath, config.GitPath); } else { git = new Git(passwordStorePath); } } catch (RepositoryNotFoundException) { // Password store doesn't appear to be a Git repository. // Git support will be disabled. } catch (TypeInitializationException e) when(e.InnerException is DllNotFoundException) { notificationService.ShowErrorWindow("The git2 DLL could not be found. Git support will be disabled."); } catch (Exception e) { notificationService.ShowErrorWindow($"Failed to open the password store Git repository ({e.GetType().Name}: {e.Message}). Git support will be disabled."); } } }
public SyncServiceFactory(GitConfig config, string passwordStorePath, ISignService signService, GitSyncStrategies gitSyncStrategies) { this.config = config; this.passwordStorePath = passwordStorePath; this.signService = signService; this.gitSyncStrategies = gitSyncStrategies; }
static GitScenario() { MergedDefaultContent = RepoDefaultContent + Environment.NewLine + SystemDefaultContent.Replace("[Core]", "") + UserDefaultContent + Environment.NewLine; MergedDefault = Toml.ReadString <GitConfig>(MergedDefaultContent); }
static GitScenario() { MergedDefaultContent = RepoDefaultContent + Environment.NewLine + SystemDefaultContent.Replace("[Core]", "") + UserDefaultContent + Environment.NewLine; MergedDefault = Toml.ReadString<GitConfig>(MergedDefaultContent); }
public static LfxConfig Load(GitConfig gitConfig) { if (gitConfig == null) { return(null); } return(new LfxConfig(gitConfig)); }
public void TestReadCurrentBranch(string fileInput, string expectedResult) { var givenContent = File.ReadLines(System.IO.Path.Combine(@"TestData\Git", fileInput)); var result = GitConfig.GetCurrentBranchFromHead(givenContent.First()); result.Should().Be(expectedResult); }
public void CarregaConfigGit() { gitConfig = jsonHelper.RetornarConfigGit(); txtUrlGit.Text = gitConfig.UrlGit; txtDiretorioGit.Text = gitConfig.DiretorioGit; txtDiretorioProjetoFront.Text = gitConfig.DiretorioProjetoFront; }
private LfxConfig(GitConfig gitConfig) { m_gitConfig = gitConfig; m_configFile = new LfxConfigFile(m_gitConfig.ConfigFile); if (m_gitConfig.Parent != null) { m_parent = new LfxConfig(m_gitConfig.Parent); } }
public static void Clear() { GitConfig = null; IsGitFlow = false; BranchName = string.Empty; SolutionDir = string.Empty; TortoiseGitProc = string.Empty; HasStash = false; Git = string.Empty; }
public void ChooseSyncStrategy_ChoosesMatchingStrategy(string syncMode, Type type) { var resolver = new Mock <IExecutablePathResolver>(); var strategies = new GitSyncStrategies(resolver.Object); var config = new GitConfig { SyncModeString = syncMode, }; var strategy = strategies.ChooseSyncStrategy("test", null, config); strategy.ShouldBeOfType(type); }
public void ChooseSyncStrategy_AutoAndGitFound_ChoosesNativeGit() { var resolver = new Mock <IExecutablePathResolver>(); var strategies = new GitSyncStrategies(resolver.Object); var config = new GitConfig { SyncModeString = "auto", }; var strategy = strategies.ChooseSyncStrategy("test", null, config); strategy.ShouldBeOfType <NativeGitSyncStrategy>(); }
public void CriarJsonConfigGit(GitConfig gitConfig) { var diretorioConfig = $@"{toolsFolder}Config\"; Diretorio.CriarSeNaoExistirDiretorio(diretorioConfig); var fileDestino = $@"{diretorioConfig}\git.json"; using (StreamWriter fileWriter = File.CreateText(fileDestino)) { var serializer = new JsonSerializer(); serializer.Serialize(fileWriter, gitConfig); } }
/// <summary> /// Get GIT config. /// </summary> /// <remarks> /// - Cache received config based on the currently opened solution file path. /// - If the solution file path is different from last time we got the git config, /// it means we have a new solution and should also get new git config. /// </remarks> /// <returns>Strong typed GIT config about gitflow, svn and bugtraq.</returns> public static async Task <GitConfig> GetGitConfig() { var solution = await VS.Solutions.GetCurrentSolutionAsync(); if (_gitConfig == null || string.IsNullOrEmpty(_solutionFullPath) || !_solutionFullPath.Equals(solution?.FullPath)) { _gitConfig = new GitConfig(await ProcessHelper.StartProcessGitResult("config --get-regexp \"gitflow|bugtraq|svn-remote\"")); _solutionFullPath = solution?.FullPath; } return(_gitConfig); }
public static int Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += (s, a) => { Console.WriteLine($"Unhandled exception: {((Exception)a.ExceptionObject).Message}"); }; var options = ParseCommandLine(args); string clonePath = options.ClonePath; var cloneUrls = File.ReadAllLines(options.CloneUrlsFile); // load var gitConfig = new GitConfig { CloneBaseFolder = clonePath, UserName = options.UserName, Password = options.Password, RepositoryCloneUrls = cloneUrls, ShallowClone = true }; Console.WriteLine($"Starting git clone operation on {cloneUrls.Length} repositories..."); using (var loader = new GitLoader(gitConfig)) { if (!loader.Success) { Console.WriteLine("Loader failed to load; exiting"); return(1); } // read var dependencies = ReadDependencies(new NuGetReader(loader.Location)) .Union(ReadDependencies(new NpmReader(loader.Location)) .Union(ReadDependencies(new LibManReader(loader.Location)) .Union(ReadDependencies(new GemFileReader(loader.Location))))); // write Console.WriteLine("Writing dependencies to database..."); if (!CreateDatabase(options.ConnectionString)) { return(-1); } var writer = new MssqlWriter(options.ConnectionString); writer.Write(dependencies); Console.WriteLine("Cleaning up..."); } Console.WriteLine("Done."); return(0); }
private void ExecutarGitCloneESalvarJsonConfig(string urlGit, string diretorioGit, string diretorioProjetoFront) { var commandGit = "git clone"; LinhaDeComando.Executar($"{commandGit} {urlGit}", diretorioGit); gitConfig = new GitConfig { UrlGit = urlGit, DiretorioGit = diretorioGit, DiretorioProjetoFront = diretorioProjetoFront }; SalvarJsonConfig(gitConfig); txtDiretorioProjetoFront.Text = gitConfig.DiretorioProjetoFront; }
public void ChooseSyncStrategy_AutoAndGitNotFound_ChoosesLibGit2Sharp() { var resolver = new Mock <IExecutablePathResolver>(); resolver.Setup(r => r.Resolve(It.IsAny <string>())).Throws(new ExecutableNotFoundException("Executable not found")); var strategies = new GitSyncStrategies(resolver.Object); var config = new GitConfig { SyncModeString = "auto", }; var strategy = strategies.ChooseSyncStrategy("test", null, config); strategy.ShouldBeOfType <LibGit2SharpSyncStrategy>(); }
public static void ConfigCounts() { Console.WriteLine($"currentDir: {Environment.CurrentDirectory}"); using (var tempDir = new TempGitDir()) { var local = GitConfig.Load(); var global = local.Parent; var system = global.Parent; var systemKeys = system.ToArray(); var globalKeys = global.ToArray(); var localKeys = local.ToArray(); Assert.AreEqual(local.Count, local.Count()); Assert.AreEqual(global.Count, global.Count()); Assert.AreEqual(system.Count, system.Count()); } }
private GitRepository CreateRepository( string workingDir = null, GitConfig config = null, string commitSha = null, ImmutableArray <GitSubmodule> submodules = default, GitIgnore ignore = null) { workingDir ??= _workingDir; var gitDir = Path.Combine(workingDir, ".git"); return(new GitRepository( GitEnvironment.Empty, config ?? GitConfig.Empty, gitDir, gitDir, _workingDir, submodules.IsDefault ? ImmutableArray <GitSubmodule> .Empty : submodules, submoduleDiagnostics: ImmutableArray <string> .Empty, ignore ?? new GitIgnore(root: null, workingDir, ignoreCase: false), commitSha)); }
public static LfxConfig Load(string path = null) { if (path != null) { path += LfxConfigFile.FileName; if (File.Exists(path)) { return(Load(GitConfig.Load(path))); } path = path.GetDir(); } var gitConfig = GitConfig.Load(path, LfxConfigFile.FileName); if (gitConfig == null) { return(null); } return(Load(gitConfig)); }
public static LfxBlobCache Create(string workingDir = null) { if (workingDir == null) { workingDir = Environment.CurrentDirectory; } workingDir = workingDir.ToDir(); var gitLoader = GitConfig.Load(workingDir); // lfxDir -> /.git/lfx/ var lfxDir = gitLoader.GitDirectory + LfxDirName.ToDir(); // objectsDir -> /.git/lfx/objects/ var objectsDir = lfxDir + ObjectsDirName.ToDir(); var cache = Create( objectsDir, // L1 cache DefaultUserCacheDir // L2 cache ); return(cache); }
public static void Test() { Console.WriteLine($"currentDir: {Environment.CurrentDirectory}"); using (var tempDir = new TempDir()) { var tempDirString = (string)tempDir; Console.WriteLine($"tempDir: {tempDir}"); Git($"init"); var local = GitConfig.Load(); var global = local.Parent; var system = global.Parent; Assert.IsNull(system.Parent); Assert.IsTrue(!system.Except(local).Any()); Assert.IsTrue(!system.Except(global).Any()); Assert.IsTrue(!global.Except(local).Any()); Assert.AreEqual(local.Count, local.Count()); Assert.IsTrue(system.Keys().All(o => local.Contains(o))); Assert.IsTrue(system.Keys().All(o => global.Contains(o))); Assert.IsTrue(global.Keys().All(o => local.Contains(o))); Assert.IsTrue(!system.Keys().Except(local.Keys()).Any()); Assert.IsTrue(!global.Keys().Except(local.Keys()).Any()); Assert.AreEqual((string)tempDir, local.EnlistmentDirectory); Assert.AreEqual(null, global.EnlistmentDirectory); Assert.AreEqual(null, system.EnlistmentDirectory); var localFile = local.ConfigFile; Assert.AreEqual((string)tempDir, localFile.WorkingDir); Assert.AreEqual(tempDir + @".git\config", localFile.Path); var globalFile = global.ConfigFile; var systemFile = system.ConfigFile; var count = localFile.Count + globalFile.Count + systemFile.Count; Assert.AreEqual( local.Count, localFile.Keys().Union( globalFile.Keys().Union( systemFile.Keys())).Count() ); var myKey = "myKey.mySubKey"; var myValue = "myValue"; Git($"config --add {myKey} {myValue}"); var localFile0 = localFile.Reload(); var local0 = local.Reload(); Assert.AreEqual(localFile.Count + 1, local0.ConfigFile.Count); string result; Assert.IsFalse(local.TryGetValue(myKey, out result)); Assert.IsFalse(localFile.TryGetValue(myKey, out result)); Assert.IsTrue(local0.TryGetValue(myKey, out result)); Assert.AreEqual(myValue, result); Assert.IsTrue(local0.ConfigFile.TryGetValue(myKey, out result)); Assert.AreEqual(myValue, result); Assert.AreEqual(myValue, (string)local0[myKey]); Console.WriteLine("systemFile:"); foreach (var keyValue in systemFile) { Console.WriteLine(" " + keyValue.ToString()); } Console.WriteLine("globalFile:"); foreach (var keyValue in globalFile) { Console.WriteLine(" " + keyValue.ToString()); } Console.WriteLine("localFile:"); foreach (var keyValue in localFile) { Console.WriteLine(" " + keyValue.ToString()); } Console.WriteLine("config:"); foreach (var keyValue in local) { Console.WriteLine(" " + keyValue.ToString()); } } }
public IGitSyncStrategy ChooseSyncStrategy(string repositoryPath, Repository repository, GitConfig config) { var syncMode = config.SyncMode; if (syncMode == SyncMode.Auto) { try { executablePathResolver.Resolve(config.GitPath); syncMode = SyncMode.NativeGit; } catch (ExecutableNotFoundException) { syncMode = SyncMode.Builtin; } } if (syncMode == SyncMode.NativeGit) { return(new NativeGitSyncStrategy(config.GitPath, repositoryPath)); } else { return(new LibGit2SharpSyncStrategy(repository)); } }
private static IEnumerable <string> Inspect(GitConfig config) => config.EnumerateVariables().Select(kvp => $"{kvp.Key}={string.Join("|", kvp.Value)}");
public RemoteUpdateChecker(ISyncService syncService, GitConfig gitConfig, ISyncStateTracker syncStateTracker) { this.syncService = syncService; this.gitConfig = gitConfig; this.syncStateTracker = syncStateTracker; }
public RemoteUpdateCheckerFactory(Option <ISyncService> syncService, GitConfig gitConfig, ISyncStateTracker syncStateTracker) { this.syncService = syncService; this.gitConfig = gitConfig; this.syncStateTracker = syncStateTracker; }
public static void GetGitConfig() { GitConfig = GitHelper.GetGitConfig(); IsGitFlow = !string.IsNullOrEmpty(GitConfig.MasterBranch); }
public GitController(AuthConfig authConfig, GitConfig gitConfig) { _authConfig = authConfig; _gitConfig = gitConfig; }
public static void ManualTest() { Console.WriteLine($"currentDir: {Environment.CurrentDirectory}"); using (var tempDir = new TempDir()) { var tempDirString = (string)tempDir; Console.WriteLine($"tempDir: {tempDir}"); using (var env = new TempCurDir(ToolsDirName)) { // copy git-lfx.exe and libs to tools dir typeof(ImmutableDictionary).Assembly.Location.CopyToDir(); typeof(GitCmd).Assembly.Location.CopyToDir(); typeof(LfxCmd).Assembly.Location.CopyToDir(); typeof(Program).Assembly.Location.CopyToDir(); // add tools dir to path Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + env ); } using (var env = new TempCurDir(RemoteDirName)) { Git($"init --bare"); } using (var env = new TempCurDir(SourceDirName)) { Git($"init"); Git($"remote add origin ..\\{RemoteDirName}"); Git($"config --add filter.lfx.clean \"git-lfx clean %f\""); Git($"config --add filter.lfx.smudge \"git-lfx smudge --\""); Git($"config --get-regex .*lfx.*"); PackagesConfig.Save("packages.config"); using (var packages = new TempCurDir("packages")) { File.WriteAllText(GitAttributes, NugetGitAttributes); File.WriteAllText(GitIgnore, NugetGitIgnore); var gitConfig = GitConfig.Load(); Assert.AreEqual(env.ToString(), gitConfig.EnlistmentDirectory); Git($"config -f {LfxConfig} --add {LfxConfigFile.TypeId} {NugetType}"); Git($"config -f {LfxConfig} --add {LfxConfigFile.UrlId} {NugetUrl}"); Git($"config -f {LfxConfig} --add {LfxConfigFile.PatternId} {NugetRegex}"); Git($"config -f {LfxConfig} --add {LfxConfigFile.HintId} {NugetHint}"); Console.WriteLine($"{LfxConfig}: {Path.GetFullPath(LfxConfig)}:"); Console.WriteLine(File.ReadAllText(LfxConfig)); } Nuget($"restore -packagesDirectory packages"); Cmd($"where.exe", "git-lfx.exe"); Git($"add ."); Git($"commit -m \"Initial Commit\""); Git($"push -u origin master"); } Git($"clone remote target"); Console.WriteLine($"CurDir: {Environment.CurrentDirectory}"); } }
protected override void OnBeforeRun() { GitConfig.SetValue(this.basePath, "user.email", this.author.Email == string.Empty ? "<>" : this.author.Email); GitConfig.SetValue(this.basePath, "user.name", this.author.Name); }