示例#1
0
        /// <summary>
        /// Make sure WC gets unsparsed when turning off sparse.
        /// </summary>
        private void SaveChangesTurningOffSparseSpecialCase()
        {
            if ((IsSparseCheckoutEnabled) || (IsSparseCheckoutEnabled == _isSparseCheckoutEnabledAsSaved))
            {
                return; // Not turning off
            }
            // Now check the rules, the well-known recommendation is to have the single "/*" rule active
            List <string> rulelines = RulesText.SplitLines().Select(l => l.Trim()).Where(l => (!l.IsNullOrEmpty()) && (l[0] != '#')).ToList(); // All nonempty and non-comment lines

            if (rulelines.All(l => l == "/*"))
            {
                return; // Rules OK for turning off
            }
            // Confirm
            var args = new ComfirmAdjustingRulesOnDeactEventArgs(!rulelines.Any());

            ComfirmAdjustingRulesOnDeactRequested(this, args);
            if (args.Cancel)
            {
                return;
            }

            // Adjust the rules
            // Comment out all existing nonempty lines, add the single “/*” line to make a total pass filter
            RulesText = new[] { "/*" }.Concat(RulesText.SplitLines().Select(l => (string.IsNullOrWhiteSpace(l) || (l[0] == '#')) ? l : "#" + l)).Join(Environment.NewLine);
        }
        /// <summary>
        /// Make sure WC gets unsparsed when turning off sparse.
        /// </summary>
        private void SaveChangesTurningOffSparseSpecialCase()
        {
            if((IsSparseCheckoutEnabled) || (IsSparseCheckoutEnabled == _isSparseCheckoutEnabledAsSaved))
                return; // Not turning off

            // Now check the rules, the well-known recommendation is to have the single "/*" rule active
            List<string> rulelines = RulesText.SplitLines().Select(l => l.Trim()).Where(l => (!l.IsNullOrEmpty()) && (l[0] != '#')).ToList(); // All nonempty and non-comment lines
            if(rulelines.All(l => l == "/*"))
                return; // Rules OK for turning off

            // Confirm
            var args = new ComfirmAdjustingRulesOnDeactEventArgs(!rulelines.Any());
            ComfirmAdjustingRulesOnDeactRequested(this, args);
            if(args.Cancel)
                return;

            // Adjust the rules
            // Comment out all existing nonempty lines, add the single “/*” line to make a total pass filter
            RulesText = new[] {"/*"}.Concat(RulesText.SplitLines().Select(l => (string.IsNullOrWhiteSpace(l) || (l[0] == '#')) ? l : "#" + l)).Join(Environment.NewLine);
        }