Пример #1
0
        public static bool CheckValidFields(
            MultilinerBotConfiguration botConfig,
            out string errorMessage)
        {
            errorMessage = string.Empty;

            if (string.IsNullOrEmpty(botConfig.Server))
            {
                errorMessage += BuildFieldError("server");
            }

            if (string.IsNullOrEmpty(botConfig.Repository))
            {
                errorMessage += BuildFieldError("repository");
            }

            if (string.IsNullOrEmpty(botConfig.MergeToBranchesAttrName))
            {
                errorMessage += BuildFieldError("attribute name to specify merge destination branches");
            }

            if (string.IsNullOrEmpty(botConfig.UserApiKey))
            {
                errorMessage += BuildFieldError("user api key");
            }

            string propertyErrorMessage = null;

            if (!CheckValidPlasticFields(botConfig.Plastic, out propertyErrorMessage))
            {
                errorMessage += propertyErrorMessage;
            }

            propertyErrorMessage = null;
            if (!CheckValidIssueTrackerFields(botConfig.Issues, out propertyErrorMessage))
            {
                errorMessage += propertyErrorMessage;
            }

            propertyErrorMessage = null;
            if (!CheckValidContinuousIntegrationFields(botConfig.CI, out propertyErrorMessage))
            {
                errorMessage += propertyErrorMessage;
            }

            foreach (MultilinerBotConfiguration.Notifier notifier in botConfig.Notifiers)
            {
                propertyErrorMessage = null;
                if (!CheckValidNotifierFields(notifier, out propertyErrorMessage))
                {
                    errorMessage += propertyErrorMessage;
                }
            }

            return(string.IsNullOrEmpty(errorMessage));
        }
Пример #2
0
        public static bool CheckConfiguration(
            MultilinerBotConfiguration botConfig,
            out string errorMessage)
        {
            if (!CheckValidFields(botConfig, out errorMessage))
            {
                errorMessage = string.Format(
                    "multilinerbot can't start without specifying a valid config for the following fields:\n{0}",
                    errorMessage);
                return(false);
            }

            return(true);
        }