Вот несколько методов, связанных с использованием GitHub с.NET, а также примеры кода:
-
Клонирование репозитория:
using LibGit2Sharp; var cloneOptions = new CloneOptions(); Repository.Clone("https://github.com/username/repository.git", "localPath", cloneOptions); -
Создание нового репозитория:
using Octokit; var client = new GitHubClient(new ProductHeaderValue("MyApp")); var newRepo = new NewRepository("repository-name"); var repository = await client.Repository.Create("username", newRepo); -
Содержимое репозитория списка:
using Octokit; var client = new GitHubClient(new ProductHeaderValue("MyApp")); var contents = await client.Repository.Content.GetAllContents("username", "repository-name"); foreach (var content in contents) { Console.WriteLine(content.Name); } -
Создание запроса на включение:
using Octokit; var client = new GitHubClient(new ProductHeaderValue("MyApp")); var newPullRequest = new NewPullRequest("PR Title", "branch:source", "branch:target"); var pullRequest = await client.PullRequest.Create("username", "repository-name", newPullRequest); -
Получение информации о репозитории:
using Octokit; var client = new GitHubClient(new ProductHeaderValue("MyApp")); var repository = await client.Repository.Get("username", "repository-name"); Console.WriteLine(repository.Description);