private GitAutomationConfig GetGitAutomationConfig(string localRepository, string remoteUrl, Dictionary <string, string> additionalConfigs, bool?isPrivateRepository = null, List <ProjectMemberDto> projectMembers = 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"]; } if (additionalConfigs.ContainsKey("SkipMemberConfig") && bool.TryParse(additionalConfigs["SkipMemberConfig"], out var skipMemberConfig)) { config.SkipMemberConfig = skipMemberConfig; } } if (projectMembers != null) { config.Members = projectMembers.Where(p => p.ExternalAccountIds != null && p.ExternalAccountIds.ContainsKey(ExternalAccountType.GitHub)) .Select(p => p.ExternalAccountIds[ExternalAccountType.GitHub]).Where(p => !string.IsNullOrEmpty(p)).Distinct().ToList(); } return(config); }
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); }
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; }