public static GitLabModel Create(string gitLabAddress, string gitLabKey, string projectName, string favoriteGroupFullPath) { GitLabClient gitLabCLient = GitLabClient.Connect(gitLabAddress, gitLabKey); var accessibleProjects = gitLabCLient.Projects.Accessible().ToList(); var project = accessibleProjects.First(p => p.SshUrl.ToLowerInvariant().Contains(projectName.ToLowerInvariant()) || p.HttpUrl.ToLowerInvariant().Contains(projectName.ToLowerInvariant())); return(new GitLabModel(gitLabAddress, gitLabKey, gitLabCLient, project, favoriteGroupFullPath)); }
public static GitLabModel Create(string gitLabAddress, string gitLabKey, string projectName) { GitLabClient gitLabCLient = GitLabClient.Connect(gitLabAddress, gitLabKey); ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; var accessibleProjects = gitLabCLient.Projects.Accessible().ToList(); var project = accessibleProjects.First(p => p.SshUrl.ToLowerInvariant().Contains(projectName.ToLowerInvariant()) || p.HttpUrl.ToLowerInvariant().Contains(projectName.ToLowerInvariant())); return(new GitLabModel(gitLabCLient, project)); }
public GitLabClient GetGitLabClient() { var client = GitLabClient.Connect(GitLabSettings.GitLabUri, GitLabSettings.GitLabUsername, GitLabSettings.GitLabPassword); return(client); }
public static GitLabClient Connect() { return(GitLabClient.Connect(ServiceUrl, Secret)); }
protected GitLabClient GetClient() => GitLabClient.Connect(GetSetting(GitLabSetting.Host), GetSetting(GitLabSetting.Token));
public GitLabWrapper(string server, string token) { client = GitLabClient.Connect(server, token); }
public static GitLabClient Connect() { return(GitLabClient.Connect(ServiceUrl, Secret, ApiVersion.V4)); }
public VersionControlSystemGateway(GitlabSettings settings) { Require.NotNull(settings, nameof(settings)); _settings = settings; _gitLabClient = GitLabClient.Connect(_settings.Host, _settings.ApiKey); }
public static GitLabClient Connect() { return(GitLabClient.Connect(ServiceUrl, "maikebing", "kissme", Impl.ApiVersion.V3_1)); }
public async Task<bool> Backup(string targetFolder) { try { ConsoleService.WriteToConsole("started GitLab Service"); //check for config Dictionary<string, string> versions = ResolveDictionaryCache(targetFolder); var client = GitLabClient.Connect(ConfiguredKeyValues[GitLabApiUrl], ConfiguredKeyValues[GitLabApiKey]); var projs = client.Projects; foreach (var project in projs.Accessible) { var repo = client.GetRepository(project.Id); ConsoleService.WriteToConsole("Working on project " + project.Name); var lastCommit = repo.Commits.FirstOrDefault(); if (lastCommit != null) { if (!File.Exists(Path.Combine(targetFolder, project.Name + ".tar.gz")) || !versions.ContainsKey(project.Name) || versions[project.Name] != lastCommit.CreatedAt.ToLongDateString() + "_" + lastCommit.CreatedAt.ToLongTimeString()) { ConsoleService.WriteToConsole("Replacing project " + project.Name); if (File.Exists(Path.Combine(targetFolder, project.Name + ".tar.gz"))) File.Delete(Path.Combine(targetFolder, project.Name + ".tar.gz")); ConsoleService.WriteToConsole("downloading project " + project.Name); repo.GetArchive((str) => { var fileStream = File.Create(Path.Combine(targetFolder, project.Name + ".tar.gz")); long totalFileSize = 0; var bufferSize = 2048; var buffer = new byte[bufferSize]; int count = str.Read(buffer, 0, bufferSize); while (count > 0) { // Dumps the 256 characters on a string and displays the string to the console. fileStream.Write(buffer, 0, count); count = str.Read(buffer, 0, bufferSize); totalFileSize += count; ConsoleService.WriteSameLineToConsole("downloaded " + FormatHelper.ConvertToHumanReadbleFileSize(totalFileSize)); } str.CopyToAsync(fileStream); fileStream.Close(); versions[project.Name] = lastCommit.CreatedAt.ToLongDateString() + "_" + lastCommit.CreatedAt.ToLongTimeString(); //add new line ConsoleService.WriteToConsole(""); }); ConsoleService.WriteToConsole("Finished downloading project " + project.Name); DoLog("actualized " + project.Name); } else { ConsoleService.WriteToConsole("skipped project " + project.Name + " as it is already up to date"); DoLog("skipped " + project.Name + " (up to date)"); } } else { ConsoleService.WriteToConsole("skipped project " + project.Name + " as no commit was found"); DoLog("skipped " + project.Name + " (no commit)"); } } ConsoleService.WriteToConsole("finished GitLab Service"); Cache(targetFolder, versions); return true; } catch (Exception ex) { ConsoleService.WriteToConsole("Exception occured"); ConsoleService.WriteToConsole(ex.ToString()); } finally { SaveLogs(targetFolder); } return false; }