internal FormFileHistory(GitUICommands aCommands) : base(aCommands) { InitializeComponent(); _asyncLoader = new AsyncLoader(); // set tab page images { var imageList = new ImageList(); tabControl1.ImageList = imageList; imageList.ColorDepth = ColorDepth.Depth8Bit; imageList.Images.Add(Properties.Resources.IconViewFile); imageList.Images.Add(Properties.Resources.IconDiff); imageList.Images.Add(Properties.Resources.IconBlame); tabControl1.TabPages[0].ImageIndex = 0; tabControl1.TabPages[1].ImageIndex = 1; tabControl1.TabPages[2].ImageIndex = 2; } _filterBranchHelper = new FilterBranchHelper(toolStripBranchFilterComboBox, toolStripBranchFilterDropDownButton, FileChanges); _filterRevisionsHelper = new FilterRevisionsHelper(toolStripRevisionFilterTextBox, toolStripRevisionFilterDropDownButton, FileChanges, toolStripRevisionFilterLabel, ShowFirstParent, form: this); _formBrowseMenus = new FormBrowseMenus(FileHistoryContextMenu); _formBrowseMenus.ResetMenuCommandSets(); _formBrowseMenus.AddMenuCommandSet(MainMenuItem.NavigateMenu, FileChanges.MenuCommands.GetNavigateMenuCommands()); _formBrowseMenus.AddMenuCommandSet(MainMenuItem.ViewMenu, FileChanges.MenuCommands.GetViewMenuCommands()); _formBrowseMenus.InsertAdditionalMainMenuItems(toolStripSeparator4); _commitDataManager = new CommitDataManager(() => Module); _fullPathResolver = new FullPathResolver(() => Module.WorkingDir); _gitRevisionProvider = new GitRevisionProvider(() => Module); }
/// <summary> /// Gets the commit info from CommitData. /// </summary> /// <returns></returns> public static CommitInformation GetCommitInfo(IGitRevisionProvider module, CommitData data, bool showRevisionsAsLinks) { if (data == null) { throw new ArgumentNullException("data"); } string header = data.GetHeader(module, showRevisionsAsLinks); string body = "\n" + WebUtility.HtmlEncode(data.Body.Trim()); return(new CommitInformation(header, body)); }
/// <summary> /// Generate header. /// </summary> /// <returns></returns> public static string GetHeader(this CommitData commitData, IGitRevisionProvider module, bool showRevisionsAsLinks) { StringBuilder header = new StringBuilder(); string authorEmail = GetEmail(commitData.Author); header.AppendLine( FillToLength(WebUtility.HtmlEncode(Strings.GetAuthorText()) + ":", COMMITHEADER_STRING_LENGTH) + "<a href='mailto:" + WebUtility.HtmlEncode(authorEmail) + "'>" + WebUtility.HtmlEncode(commitData.Author) + "</a>"); header.AppendLine( FillToLength(WebUtility.HtmlEncode(Strings.GetAuthorDateText()) + ":", COMMITHEADER_STRING_LENGTH) + WebUtility.HtmlEncode( LocalizationHelpers.GetRelativeDateString(DateTime.UtcNow, commitData.AuthorDate.UtcDateTime) + " (" + LocalizationHelpers.GetFullDateString(commitData.AuthorDate) + ")")); string committerEmail = GetEmail(commitData.Committer); header.AppendLine( FillToLength(WebUtility.HtmlEncode(Strings.GetCommitterText()) + ":", COMMITHEADER_STRING_LENGTH) + "<a href='mailto:" + WebUtility.HtmlEncode(committerEmail) + "'>" + WebUtility.HtmlEncode(commitData.Committer) + "</a>"); header.AppendLine( FillToLength(WebUtility.HtmlEncode(Strings.GetCommitDateText()) + ":", COMMITHEADER_STRING_LENGTH) + WebUtility.HtmlEncode( LocalizationHelpers.GetRelativeDateString(DateTime.UtcNow, commitData.CommitDate.UtcDateTime) + " (" + LocalizationHelpers.GetFullDateString(commitData.CommitDate) + ")")); header.Append( FillToLength(WebUtility.HtmlEncode(Strings.GetCommitHashText()) + ":", COMMITHEADER_STRING_LENGTH) + WebUtility.HtmlEncode(commitData.Guid)); var indent = FillToLength(" ", COMMITHEADER_STRING_LENGTH); if (commitData.ChildrenGuids != null && commitData.ChildrenGuids.Count != 0) { header.AppendLine(); string commitsString; if (showRevisionsAsLinks) { commitsString = commitData.ChildrenGuids .Select(c => LinkFactory.CreateCommitLink(c) + " " + GetCommitSubject(c, module)) .Join(Environment.NewLine + indent); } else { commitsString = commitData.ChildrenGuids .Select(guid => guid.Substring(0, 10) + " " + GetCommitSubject(guid, module)) .Join(Environment.NewLine + indent); } header.Append(FillToLength(WebUtility.HtmlEncode(Strings.GetChildrenText()) + ":", COMMITHEADER_STRING_LENGTH) + commitsString); } var parentGuids = commitData.ParentGuids.Where(s => !String.IsNullOrEmpty(s)).ToList(); if (parentGuids.Any()) { header.AppendLine(); string commitsString; if (showRevisionsAsLinks) { commitsString = parentGuids .Select(c => LinkFactory.CreateCommitLink(c) + " " + GetCommitSubject(c, module)) .Join(Environment.NewLine + indent); } else { commitsString = parentGuids .Select(guid => indent + guid.Substring(0, 10) + " " + GetCommitSubject(guid, module)) .Join(Environment.NewLine + indent); } header.Append(FillToLength(WebUtility.HtmlEncode(Strings.GetParentsText()) + ":", COMMITHEADER_STRING_LENGTH) + commitsString); } return(RemoveRedundancies(header.ToString())); }
private static string GetCommitSubject(string sha, IGitRevisionProvider module) { return(GitRevision.IsArtificial(sha) ? "" : module.GetRevision(sha, shortFormat: true).Subject); }