internal static async Task <GitActionResult <string> > Commit(GitRepository repository, string message, bool signoff = false) { var result = new GitActionResult <string>(); SolutionExtensions.WriteMessageToOutputPane("Commiting"); if (String.IsNullOrWhiteSpace(message)) { result.Succeeded = false; result.ErrorMessage = ErrorMessages.CommitMissingComment; SolutionExtensions.WriteMessageToOutputPane(ErrorMessages.CommitMissingComment); return(result); } var stagedCount = repository?.ChangedFiles.Count(f => f.IsStaged) ?? 0; if (stagedCount <= 0) { result.Succeeded = false; result.ErrorMessage = ErrorMessages.CommitNoFilesStaged; SolutionExtensions.WriteMessageToOutputPane(ErrorMessages.CommitNoFilesStaged); return(result); } result = repository?.Commit(message, false, signoff); if (result.Succeeded) { SolutionExtensions.WriteMessageToOutputPane("Commit successfully. Commit Hash: " + result.Item); } return(result); }
internal async Task InitRepo() { await GitCommandWrappers.InitRepo(await GetSolutionFileName()); SolutionExtensions.WriteMessageToOutputPane("Enabling SCC Provider"); await OpenTracker(); await EnableSccForSolution(); await ReloadAllGlyphs(); SolutionExtensions.WriteMessageToOutputPane("Done"); }
internal async Task InitRepo() { await GitCommandWrappers.InitRepo(await GetSolutionFileName()); SolutionExtensions.WriteMessageToOutputPane("Enabling SCC Provider"); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var projects = await SolutionExtensions.GetLoadedControllableProjects(); SolutionExtensions.WriteMessageToOutputPane("Adding Projects To git"); foreach (var vsSccProject2 in projects) { await AddProjectToSourceControl(vsSccProject2); } await OpenTracker(); await RefreshSolution(); SolutionExtensions.WriteMessageToOutputPane("Done"); }
internal static async Task <GitActionResult <string> > AmendCommit(GitRepository repository, string message, bool signoff = false) { var result = new GitActionResult <string>(); SolutionExtensions.WriteMessageToOutputPane("Amending Commiti"); if (String.IsNullOrWhiteSpace(message)) { result.Succeeded = false; result.ErrorMessage = ErrorMessages.CommitMissingComment; SolutionExtensions.WriteMessageToOutputPane(ErrorMessages.CommitMissingComment); return(result); } result = repository?.Commit(message, true, signoff); if (result.Succeeded) { SolutionExtensions.WriteMessageToOutputPane("Amend last commit successfully. Commit Hash: " + result.Item); } return(result); }
public static async Task InitRepo(string solutionFile) { var solutionPath = Path.GetDirectoryName(solutionFile); SolutionExtensions.WriteMessageToOutputPane("Creating Repo"); GitRepository.Init(solutionPath); SolutionExtensions.WriteMessageToOutputPane("Repo Created"); SolutionExtensions.WriteMessageToOutputPane("Adding .gitignore file"); await IgnoreFileManager.UpdateGitIgnore(solutionPath); //File.WriteAllText(Path.Combine(solutionPath, ".tfignore"), @"\.git"); RepositoryManager.Instance.Clear(); Thread.Sleep(1000); var repo = RepositoryManager.Instance.GetTrackerForPath(solutionFile); if (repo != null) { repo.AddFile(Path.Combine(solutionPath, ".gitignore")); repo.AddFile(solutionFile); } }
internal static async Task <GitActionResult <GitBranchInfo> > SwitchCommand(SwitchBranchInfo result) { if (!result.CreateBranch && !result.Switch) { return(new GitActionResult <GitBranchInfo>() { ErrorMessage = "No Branch Operation", Succeeded = false }); } GitActionResult <GitBranchInfo> branchResult = new GitActionResult <GitBranchInfo>(); bool inError = false; var branch = result.BranchInfo; await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionExtensions.WriteMessageToOutputPane("Branch Operation Started"); if (result.CreateBranch) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionExtensions.WriteMessageToOutputPane("Creating Branch"); await TaskScheduler.Default; branchResult = result.Repository.CreateBranch(result.BranchName); if (branchResult.Succeeded) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionExtensions.WriteMessageToOutputPane("Branch: ' " + branchResult.Item.Name + "' Created"); branch = branchResult.Item; } else { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); inError = true; SolutionExtensions.WriteMessageToOutputPane(branchResult.ErrorMessage); } } if (result.Switch && !inError) { if (branch != null) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionExtensions.WriteMessageToOutputPane("Switching Branch"); await TaskScheduler.Default; if (branch.IsRemote) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionExtensions.WriteMessageToOutputPane("Creating Local Branch"); var createResult = result.Repository.CreateBranch(branch.Name.Remove(0, branch.RemoteName.Length + 1), branch.Sha); if (!createResult.Succeeded) { return(createResult); } result.Repository.SetRemoteBranch(createResult.Item, branch.RemoteName); branchResult = result.Repository.Checkout(createResult.Item); } else { branchResult = result.Repository.Checkout(branch); } if (!branchResult.Succeeded) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); inError = true; SolutionExtensions.WriteMessageToOutputPane(branchResult.ErrorMessage); } } } if (!inError) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionExtensions.WriteMessageToOutputPane("Branch Operation Complete"); } return(branchResult); }
//TODO.. Move this and Commit. I sorta hate it all! internal async Task SwitchCommand(BranchPickerResult result) { if (!result.CreateBranch && !result.Switch) { return; } bool inError = false; var branch = result.BranchInfo; await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionExtensions.WriteMessageToOutputPane("Branch Operation Started"); if (result.CreateBranch) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionExtensions.WriteMessageToOutputPane("Creating Branch"); //await status.SetMessage("Creating Branch"); await TaskScheduler.Default; var branchResult = result.Repository.CreateBranch(result.BranchName); if (branchResult.Succeeded) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionExtensions.WriteMessageToOutputPane("Branch: ' " + branchResult.Item.Name + "' Created"); branch = branchResult.Item; } else { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); inError = true; //status.Hide(); SolutionExtensions.WriteMessageToOutputPane(branchResult.ErrorMessage); MessageBox.Show(branchResult.ErrorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } if (result.Switch && !inError) { if (branch != null) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionExtensions.WriteMessageToOutputPane("Switching Branch"); await TaskScheduler.Default; var switchResult = result.Repository.Checkout(branch); if (!switchResult.Succeeded) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); inError = true; SolutionExtensions.WriteMessageToOutputPane(switchResult.ErrorMessage); MessageBox.Show(switchResult.ErrorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } } if (!inError) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionExtensions.WriteMessageToOutputPane("Branch Operation Complete"); await UpdateRepositoryName(); } }