本文整理汇总了C#中GitHubClient类的典型用法代码示例。如果您正苦于以下问题:C# GitHubClient类的具体用法?C# GitHubClient怎么用?C# GitHubClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitHubClient类属于命名空间,在下文中一共展示了GitHubClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatesANewPrivateRepository
public async Task CreatesANewPrivateRepository()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = Helper.Credentials
};
var repoName = Helper.MakeNameWithTimestamp("private-repo");
var createdRepository = await github.Repository.Create(new NewRepository
{
Name = repoName,
Private = true
});
try
{
Assert.True(createdRepository.Private);
var repository = await github.Repository.Get(github.Credentials.Login, repoName);
Assert.True(repository.Private);
}
finally
{
Helper.DeleteRepo(createdRepository);
}
}
示例2: Main
public void Main(string[] args)
{
var client = new GitHubClient(new ProductHeaderValue("coreclr"));
var result = client.User.Get("naveensrinivasan").Result;
Console.WriteLine(result.Name);
Console.WriteLine(result.HtmlUrl);
}
示例3: CreatesARepositoryWithoutDownloads
public async Task CreatesARepositoryWithoutDownloads()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = Helper.Credentials
};
var repoName = Helper.MakeNameWithTimestamp("repo-without-downloads");
var createdRepository = await github.Repository.Create(new NewRepository
{
Name = repoName,
HasDownloads = false
});
try
{
Assert.False(createdRepository.HasDownloads);
var repository = await github.Repository.Get(github.Credentials.Login, repoName);
Assert.False(repository.HasDownloads);
}
finally
{
Helper.DeleteRepo(createdRepository);
}
}
示例4: CreateIssueTracker
public IIssueTracker CreateIssueTracker(Context context, IRepository repository)
{
switch (context.GetIssueTracker())
{
case IssueTracker.BitBucket:
break;
case IssueTracker.GitHub:
return new GitHubIssueTracker(repository, () =>
{
var gitHubClient = new GitHubClient(new ProductHeaderValue("GitReleaseNotes"));
if (context.IssueTracker.Token != null)
{
gitHubClient.Credentials = new Octokit.Credentials(context.IssueTracker.Token);
}
return gitHubClient;
}, context);
case IssueTracker.Jira:
return new JiraIssueTracker(new JiraApi(), context);
case IssueTracker.YouTrack:
return new YouTrackIssueTracker(new YouTrackApi(), context);
}
return null;
}
示例5: RequestsCorrectUrlWithApiOptions
public async Task RequestsCorrectUrlWithApiOptions()
{
var result = new List<EventInfo> { new EventInfo() };
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var client = new ObservableIssuesEventsClient(gitHubClient);
var options = new ApiOptions
{
StartPage = 1,
PageCount = 1,
PageSize = 1
};
IApiResponse<List<EventInfo>> response = new ApiResponse<List<EventInfo>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
gitHubClient.Connection.Get<List<EventInfo>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null)
.Returns(Task.FromResult(response));
var eventInfos = await client.GetAllForIssue("fake", "repo", 42, options).ToList();
connection.Received().Get<List<EventInfo>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
Assert.Equal(1, eventInfos.Count);
}
示例6: CreatesANewPublicRepository
public async Task CreatesANewPublicRepository()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = Helper.Credentials
};
var repoName = Helper.MakeNameWithTimestamp("public-repo");
var createdRepository = await github.Repository.Create(new NewRepository { Name = repoName });
try
{
var cloneUrl = string.Format("https://github.com/{0}/{1}.git", github.Credentials.Login, repoName);
Assert.Equal(repoName, createdRepository.Name);
Assert.False(createdRepository.Private);
Assert.Equal(cloneUrl, createdRepository.CloneUrl);
var repository = await github.Repository.Get(github.Credentials.Login, repoName);
Assert.Equal(repoName, repository.Name);
Assert.Null(repository.Description);
Assert.False(repository.Private);
Assert.True(repository.HasDownloads);
Assert.True(repository.HasIssues);
Assert.True(repository.HasWiki);
Assert.Null(repository.Homepage);
}
finally
{
Helper.DeleteRepo(createdRepository);
}
}
示例7: GetsRootContents
public async Task GetsRootContents()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = Helper.Credentials
};
var contents = await github.Repository.Contents.GetForPath("octokit", "octokit.net", "Octokit.Reactive/ObservableGitHubClient.cs");
}
示例8: DeleteRepo
public static void DeleteRepo(string owner, string name)
{
var api = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Credentials };
try
{
api.Repository.Delete(owner, name).Wait(TimeSpan.FromSeconds(15));
}
catch { }
}
示例9: Overseer
public Overseer(CancellationToken token, BuildServerClient buildServerClient, GitHubClient gitHubClient, string user, string repo, string branch)
{
m_token = token;
m_buildServerClient = buildServerClient;
m_gitHubClient = gitHubClient;
m_user = user;
m_repo = repo;
m_branch = branch;
}
示例10: CanCreateBasicAuthClient
public void CanCreateBasicAuthClient()
{
var client = new GitHubClient(new ProductHeaderValue("OctokitTests", "1.0"))
{
Credentials = new Credentials("tclem", "pwd")
};
Assert.Equal(AuthenticationType.Basic, client.Credentials.AuthenticationType);
}
示例11: CanCreateOauthClient
public void CanCreateOauthClient()
{
var client = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = new Credentials("token")
};
Assert.Equal(AuthenticationType.Oauth, client.Credentials.AuthenticationType);
}
示例12: RequestsCorrectUrlWithRepositoryId
public async Task RequestsCorrectUrlWithRepositoryId()
{
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var client = new ObservableIssuesLabelsClient(gitHubClient);
client.GetAllForIssue(1, 42);
connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Args.EmptyDictionary, null);
}
示例13: ReturnsSpecifiedUserUsingAwaitableCredentialProvider
public async Task ReturnsSpecifiedUserUsingAwaitableCredentialProvider()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"),
new ObservableCredentialProvider());
// Get a user by username
var user = await github.User.Get("tclem");
Assert.Equal("GitHub", user.Company);
}
示例14: CanGetEmail
public async Task CanGetEmail()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = Helper.Credentials
};
var emails = await github.User.Email.GetAll();
Assert.NotEmpty(emails);
}
示例15: CanRenderGitHubFlavoredMarkdown
public async Task CanRenderGitHubFlavoredMarkdown()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = Helper.Credentials
};
var result = await github.Miscellaneous.RenderRawMarkdown("This is a **test**");
Assert.Equal("<p>This is a <strong>test</strong></p>", result);
}