Beispiel #1
0
        private GitAutomationConfig GetGitAutomationConfig(string localRepository, string remoteUrl, Dictionary <string, string> additionalConfigs, bool?isPrivateRepository = null)
        {
            var config = new GitAutomationConfig
            {
                LocalRepository     = localRepository,
                RemoteUrl           = remoteUrl,
                IsPrivateRepository = isPrivateRepository,
            };

            var remoteUrlBrokenDown = new Uri(remoteUrl).AbsolutePath?.Trim(' ', '/').Split('/');

            if (remoteUrlBrokenDown != null && remoteUrlBrokenDown.Length == 2)
            {
                config.RepoOwner   = remoteUrlBrokenDown[0];
                config.ProjectName = remoteUrlBrokenDown[1];
            }

            if (additionalConfigs != null)
            {
                if (additionalConfigs.ContainsKey("RemoteCredentialType"))
                {
                    config.RemoteCredentialType = additionalConfigs["RemoteCredentialType"];
                }

                if (additionalConfigs.ContainsKey("RemoteUsername"))
                {
                    config.RemoteUsername = additionalConfigs["RemoteUsername"];
                }

                if (additionalConfigs.ContainsKey("RemotePassword"))
                {
                    config.RemotePassword = additionalConfigs["RemotePassword"];
                }

                if (additionalConfigs.ContainsKey("RepoAuthToken"))
                {
                    config.RepoAuthToken = additionalConfigs["RepoAuthToken"];
                }
            }

            return(config);
        }
Beispiel #2
0
 public GitAutomation(GitAutomationConfig config, IGitHubUtils gitHubUtils, ILogger logger)
 {
     _config      = config;
     _gitHubUtils = gitHubUtils ?? new GitHubUtils(config.RemoteCredentialType, config.RemoteCredentialType == "userPassword" ? config.RemoteUsername : config.RepoAuthToken, config.RemotePassword, logger);
     _logger      = logger;
 }