public void InitializeRepository() { isBusy = true; progress.UpdateProgress(0, 100, "Initializing..."); var thread = new Thread(() => { var success = true; try { var targetPath = NPath.CurrentDirectory; var gitignore = targetPath.Combine(".gitignore"); var gitAttrs = targetPath.Combine(".gitattributes"); var assetsGitignore = targetPath.Combine("Assets", ".gitignore"); var filesForInitialCommit = new List <string> { gitignore, gitAttrs, assetsGitignore }; GitClient.Init().RunSynchronously(); progress.UpdateProgress(10, 100, "Initializing..."); ConfigureMergeSettings(); progress.UpdateProgress(20, 100, "Initializing..."); GitClient.LfsInstall().RunSynchronously(); progress.UpdateProgress(30, 100, "Initializing..."); AssemblyResources.ToFile(ResourceType.Generic, ".gitignore", targetPath, Environment); AssemblyResources.ToFile(ResourceType.Generic, ".gitattributes", targetPath, Environment); assetsGitignore.CreateFile(); GitClient.Add(filesForInitialCommit).RunSynchronously(); progress.UpdateProgress(60, 100, "Initializing..."); GitClient.Commit("Initial commit", null).RunSynchronously(); progress.UpdateProgress(70, 100, "Initializing..."); Environment.InitializeRepository(); } catch (Exception ex) { Logger.Error(ex, "A problem ocurred initializing the repository"); progress.UpdateProgress(90, 100, "Failed to initialize repository"); success = false; } if (success) { progress.UpdateProgress(90, 100, "Initializing..."); RestartRepository(); TaskManager.RunInUI(InitializeUI); UsageTracker.IncrementProjectsInitialized(); progress.UpdateProgress(100, 100, "Initialized"); } isBusy = false; }); thread.Start(); }
public void SetupGit(GitInstaller.GitInstallationState state) { if (!state.GitIsValid || !state.GitLfsIsValid) { if (!state.GitExecutablePath.IsInitialized) { Logger.Warning(Localization.GitNotFound); } else if (!state.GitLfsExecutablePath.IsInitialized) { Logger.Warning(Localization.GitLFSNotFound); } else if (state.GitVersion < Constants.MinimumGitVersion) { Logger.Warning(String.Format(Localization.GitVersionTooLow, state.GitExecutablePath, state.GitVersion, Constants.MinimumGitVersion)); } else if (state.GitLfsVersion < Constants.MinimumGitLfsVersion) { Logger.Warning(String.Format(Localization.GitLfsVersionTooLow, state.GitLfsExecutablePath, state.GitLfsVersion, Constants.MinimumGitLfsVersion)); } return; } Environment.GitInstallationState = state; Environment.User.Initialize(GitClient); if (firstRun) { if (Environment.RepositoryPath.IsInitialized) { UpdateMergeSettings(); GitClient.LfsInstall() .Catch(e => { Logger.Error(e, "Error running lfs install"); return(true); }) .RunSynchronously(); } if (Environment.IsWindows) { var credentialHelper = GitClient.GetConfig("credential.helper", GitConfigSource.Global) .Catch(e => { Logger.Error(e, "Error getting the credential helper"); return(true); }).RunSynchronously(); if (string.IsNullOrEmpty(credentialHelper)) { Logger.Warning("No Windows CredentialHelper found: Setting to wincred"); GitClient.SetConfig("credential.helper", "wincred", GitConfigSource.Global) .Catch(e => { Logger.Error(e, "Error setting the credential helper"); return(true); }) .RunSynchronously(); } } } }