private void MenuItem_BeforeQueryStatus(object sender, EventArgs e) { var command = (OleMenuCommand)sender; try { // TODO:is should avoid create GitAnalysis every call? using (var git = new GitAnalysis(GetActiveFilePath())) { if (!git.IsDiscoveredGitRepository) { command.Enabled = false; return; } var type = ToGitHubUrlType(command.CommandID.ID); var targetPath = git.GetGitHubTargetPath(type); if (type == GitHubUrlType.CurrentBranch && targetPath == "master") { command.Visible = false; } else { command.Text = git.GetGitHubTargetDescription(type); command.Enabled = true; } } } catch (Exception ex) { var exstr = ex.ToString(); Debug.Write(exstr); command.Text = "error:" + ex.GetType().Name; command.Enabled = false; } }
private void ExecuteCommand(object sender, EventArgs e) { var command = (OleMenuCommand)sender; try { using (var git = new GitAnalysis(GetActiveFilePath())) { if (!git.IsDiscoveredGitRepository) { return; } var selectionLineRange = GetSelectionLineRange(); var type = ToGitHubUrlType(command.CommandID.ID); var gitHubUrl = git.BuildGitHubUrl(type, selectionLineRange); System.Diagnostics.Process.Start(gitHubUrl); // open browser } } catch (Exception ex) { Debug.Write(ex.ToString()); } }
private void MenuItem_BeforeQueryStatus(object sender, EventArgs e) { var command = (OleMenuCommand)sender; try { // TODO:is should avoid create GitAnalysis every call? ThreadHelper.ThrowIfNotOnUIThread(); using (var git = new GitAnalysis(GetActiveFilePath())) { if (!git.IsDiscoveredGitRepository) { command.Enabled = false; return; } var type = ToGitHubUrlType(command.CommandID.ID); var targetPath = git.GetGitHubTargetPath(type); if (type == GitHubUrlType.CurrentBranch && targetPath == "master") { command.Visible = false; } else { command.Text = git.GetGitHubTargetDescription(type); command.Enabled = true; } } } catch (Exception ex) { var exstr = ex.ToString(); Debug.Write(exstr); command.Text = "error:" + ex.GetType().Name; command.Enabled = false; } }