예제 #1
0
        /// <summary>
        /// Build a comment for checkin for a range of change sets.
        /// </summary>
        public static string GetCombinedMergeCheckinComment(string sourceBranch, string targetBranch,
                                                            ICollection <Tuple <int, string> > idAndOwnerOfChanges, MergeOptionsEx mergeOptions)
        {
            int firstChangeset = idAndOwnerOfChanges.Min(ch => ch.Item1);
            int lastChangeset  = idAndOwnerOfChanges.Max(ch => ch.Item1);
            var owners         = idAndOwnerOfChanges.Select(cs => cs.Item2).Distinct().ToArray();

            string ownerStr = owners.Length == 1
                ? ShortenOwnerName(owners.First())
                : $"{owners.Length} authors";

            string optionsPrefix = GetOptionsString(mergeOptions);

            if (!string.IsNullOrEmpty(optionsPrefix))
            {
                optionsPrefix += ", ";
            }

            string branchStr = $"{sourceBranch} {firstChangeset}-{lastChangeset} > {targetBranch}";
            string comment   = optionsPrefix + branchStr + ", " + ownerStr + ": ";

            if (mergeOptions.HasFlag(MergeOptionsEx.AlwaysAcceptMine))
            {
                var popups = Caliburn.Micro.IoC.Get <IPopupService>();
                var answer = popups.AskYesNoQuestion("Is this a \"Cleaning history\" case?");
                if (answer == System.Windows.MessageBoxResult.Yes)
                {
                    comment = $"Cleaning merge history ({comment})";
                }
            }

            return(comment);
        }
예제 #2
0
        /// <summary>
        /// Converts MergeOptionsEx to string. Returns an empty string if options is None.
        /// </summary>
        /// <remarks>Does some replace work to improve readability, e.g. AlwaysAcceptMine -> Discard.</remarks>
        private static string GetOptionsString(MergeOptionsEx options)
        {
            string retval;

            if (options == MergeOptionsEx.None)
            {
                retval = string.Empty;
            }
            else
            {
                retval = options.ToString();

                if (options.HasFlag(MergeOptionsEx.ForceMerge))
                {
                    retval = retval.Replace("ForceMerge", "Force");
                }
                else if (options.HasFlag(MergeOptionsEx.AlwaysAcceptMine))
                {
                    retval = retval.Replace("AlwaysAcceptMine", "Discard");
                }
            }

            return(retval);
        }