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); }
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); } }
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); } }
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; }
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); } }
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); }
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 { } }
public void CanCreateBasicAuthClient() { var client = new GitHubClient(new ProductHeaderValue("OctokitTests", "1.0")) { Credentials = new Credentials("tclem", "pwd") }; Assert.Equal(AuthenticationType.Basic, client.Credentials.AuthenticationType); }
public void CanCreateOauthClient() { var client = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = new Credentials("token") }; Assert.Equal(AuthenticationType.Oauth, client.Credentials.AuthenticationType); }
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"); }
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; }
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); }
public async Task CanGetEmail() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; var emails = await github.User.Email.GetAll(); Assert.NotEmpty(emails); }
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); }
public async Task GetsAllTheEmojis() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; var emojis = await github.Miscellaneous.GetEmojis(); Assert.True(emojis.Count > 1); }
public void RequestsCorrectUrl() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For<IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableNotificationsClient(gitHubClient); client.GetAllForCurrent(); connection.Received().Get<List<Notification>>(endpoint, Args.EmptyDictionary, null); }
public GitHubModel(Dispatcher dispatcher) { Dispatcher = dispatcher; _exceptionAction = ex => Dispatcher.BeginInvoke(() => MessageBox.Show("Error: " + Enum.GetName(typeof(ErrorType), ex.ErrorType), "", MessageBoxButton.OK) ); _client = new GitHubClient(); Contexts = new ObservableCollection<Context>(); }
public async Task CanGetEmail() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; var client = new ObservableUserEmailsClient(github); var email = await client.GetAll(); Assert.NotNull(email); }
public async Task ReturnsSpecifiedUser() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; var user = await github.User.Current(); Assert.Equal(Helper.Credentials.Login, user.Login); }
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); }
public async Task ReturnsReleases() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; var releases = await github.Release.GetAll("git-tfs", "git-tfs"); Assert.True(releases.Count > 5); Assert.True(releases.Any(release => release.TagName == "v0.18.0")); }
public Watcher(BuildProject project, BuildServerClient buildServerClient, GitHubClient gitHubClient, CancellationToken token) { m_project = project; m_buildServerClient = buildServerClient; m_gitHubClient = gitHubClient; SplitRepoUrl(m_project.RepoUrl, out m_server, out m_user, out m_repo); m_branch = m_project.Branch ?? "master"; m_token = token; m_submodules = new Dictionary<string, Submodule>(); Log = LogManager.GetLogger("Watcher/{0}".FormatInvariant(m_project.Name)); Log.Info("Watching '{0}' branch in {1}/{2}.", m_branch, m_user, m_repo); }
public async Task ReturnsSpecifiedUser() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; // Get a user by username var user = await github.User.Get("tclem"); Assert.Equal("GitHub", user.Company); }
public Service() { InitializeComponent(); Logos.Utility.Logging.LogManager.Initialize(x => new LoggerProxy(x)); Log.Info("Initializing service (version {0}).", Assembly.GetExecutingAssembly().GetName().Version); ServicePointManager.DefaultConnectionLimit = 10; m_gitHubClient = new GitHubClient(new Uri("http://git/api/v3/"), Settings.Default.UserName, Settings.Default.Password) { UseGitDataApi = true }; }
public ObservableIssuesClientTests() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; client = new ObservableIssuesClient(github); repoName = Helper.MakeNameWithTimestamp("public-repo"); var result = github.Repository.Create(new NewRepository { Name = repoName }).Result; createdRepository = result; }
public async Task ReturnsAllMilestones() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; var client = new ObservableMilestonesClient(github); var milestones = await client.GetForRepository("libgit2", "libgit2sharp", new MilestoneRequest { State = ItemState.Closed }).ToList(); Assert.NotEmpty(milestones); Assert.True(milestones.All(m => m.State == ItemState.Closed)); }
public async Task ReturnsReadmeHtmlForSeeGit() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; var readmeHtml = await github.Repository.Content.GetReadmeHtml("octokit", "octokit.net"); Assert.True(readmeHtml.StartsWith("<div class=")); Assert.Contains(@"data-path=""README.md"" id=""readme""", readmeHtml); Assert.Contains("Octokit - GitHub API Client Library for .NET", readmeHtml); }
public TheGetReleasesMethod() { _github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; _releaseClient = _github.Release; var repoName = Helper.MakeNameWithTimestamp("public-repo"); _repository = _github.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }).Result; _repositoryOwner = _repository.Owner.Login; _repositoryName = _repository.Name; }
public async Task FailsWhenNotAuthenticated() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")); var userUpdate = new UserUpdate { Name = Helper.Credentials.Login, Bio = "UPDATED BIO" }; var e = await AssertEx.Throws<AuthorizationException>(async () => await github.User.Update(userUpdate)); Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode); }
/// <summary> /// Checks if the local repository is clean and if at least one remote branch tip /// is set to the latest known commit of a tracked remote repository. /// Note that this method can still return true if the local repository head is /// behind an up-to-date remote-tracking branch. /// </summary> /// <param name="localRepositoryPath">A path to the base directory of a repository on the local machine.</param> /// <param name="remoteOwner">The remote repository owner name.</param> /// <param name="remoteRepository">The remote repository name.</param> /// <param name="remoteBranch">The remote branch name of the repository.</param> /// <returns>True if the local repository is in sync, false if not.</returns> public static bool IsLocalRepositorySynchronizedToRemote(string localRepositoryPath, string remoteOwner, string remoteRepository, string remoteBranch) { GitHubClient client = new GitHubClient(new Uri("http://git/api/v3/")); string latestCommitId = client.GetLatestCommitId(remoteOwner, remoteRepository, remoteBranch); // HACK: it appears that LibGit2Sharp (or perhaps LibGit2) has trouble with submodules // where the .git file points to the parent repo's modules folder. Force the working // directory to be the specified path. using (Repository repo = new Repository(localRepositoryPath, new RepositoryOptions {WorkingDirectoryPath = localRepositoryPath})) { RepositoryStatus status = repo.Index.RetrieveStatus(); bool inSync = true; if (status.IsDirty) { bool isDirty = true; // HACK: handle an untracked .git file, in the case of a submodule (see above) if (status.CountIsExactly(1)) { StatusEntry entry = status.Single(); if (entry.State == FileStatus.Untracked && entry.FilePath == ".git") isDirty = false; } if (isDirty) { Log.Error("Git repository is dirty!"); foreach (StatusEntry entry in status) Log.Debug("{0}: {1}", entry.State, entry.FilePath); inSync = false; } } else { Log.Info("Git repository is clean."); } var remoteBranches = repo.Branches.Where(x => x.IsRemote).ToList(); if (!remoteBranches.Any(x => x.Tip.Sha == repo.Head.Tip.Sha)) Log.Warn("Repository HEAD ({0}) does not match tip of any branch; local repository is behind.", repo.Head.Tip.Sha); if (!remoteBranches.Any(x => x.Tip.Sha == latestCommitId)) { Log.Error("No remote branch tip is set to latest remote commit '{0}'.", latestCommitId); inSync = false; } return inSync; } }
public async Task <ObservableCollection <User> > GetAllPossibleAssignees(long repositoryId, GitHubClient authorizedGitHubClient) { return(new ObservableCollection <User>(await _issueRepository.GetAllPossibleAssignees(repositoryId, authorizedGitHubClient))); }
/// <summary> /// Create a searcher for the specified client, limited to the specified number of items, /// with the specified search criteria. /// </summary> /// <param name="client">The GitHub client.</param> /// <param name="maximumCount">The maximum number of items to return.</param> /// <param name="request">The request/search criteria.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="client"/> or <paramref name="request"/> is <see langword="null"/>. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="maximumCount"/> is less than or equal to zero. /// </exception> public IssueSearcher(GitHubClient client, int maximumCount, SearchIssuesRequest request) : base(client, maximumCount, request) { }
public async Task <Issue> GetIssueForRepository(long repositoryId, int issueNumber, GitHubClient authorizedGitHubClient) { return(await _issueRepository.GetIssueForRepository(repositoryId, issueNumber, authorizedGitHubClient)); }
public async Task <ObservableCollection <Repository> > GetAllRepositoriesForUser(string login, GitHubClient gitHubClient) { return(new ObservableCollection <Repository>(await _repoRepository.GetAllRepositoriesForUser(login, gitHubClient))); }
public async Task <Milestone> CreateMilestone(long repoId, NewMilestone newMilestone, GitHubClient authorizedGitHubClient) { return(await _issueRepository.CreateMilestone(repoId, newMilestone, authorizedGitHubClient)); }
public async Task <ObservableCollection <RepositoryContributor> > GetContributorsForRepository(long repositoryId, GitHubClient gitHubClient) { return(new ObservableCollection <RepositoryContributor>(await _userRepository.GetContributorsForRepository(repositoryId, gitHubClient))); }
public QueryController(GitHubClient gitHubClient) { _gitHubClient = gitHubClient; }
/// <summary> /// Create a searcher. /// </summary> /// <returns>The searcher that is created.</returns> public override Searcher CreateSearcher(GitHubClient client, int maximumCount) { previous = this; return(new CodeSearcher(client, maximumCount, CreateRequest())); }
public async Task <ObservableCollection <Repository> > SearchRepositories(string searchTerm, GitHubClient githubClient) { return(new ObservableCollection <Repository>(await _repoRepository.SearchRepositories(searchTerm, githubClient))); }
public async Task <ObservableCollection <Issue> > SearchIssues(string searchTerm, GitHubClient gitHubClient) { return(new ObservableCollection <Issue>(await _issueRepository.SearchIssues(searchTerm, gitHubClient))); }
public async Task <ObservableCollection <IssueComment> > GetCommentsForIssue(long repositoryId, int issueNumber, GitHubClient authorizedGithubClient) { return(new ObservableCollection <IssueComment>(await _issueRepository.GetCommentsForIssue(repositoryId, issueNumber, authorizedGithubClient))); }
public QueryHandler(GitHubClientOptions options) { _client = options.GitHubClientFactory(); }
public async Task <ObservableCollection <Repository> > GetAllRepositoriesForCurrentUser(GitHubClient authorizedGitHubClient) { return(new ObservableCollection <Repository>(await _repoRepository.GetAllRepositoriesForCurrentUser(authorizedGitHubClient))); }
public async Task <ObservableCollection <Issue> > GetAllClosedIssuesForRepository(long repositoryId, GitHubClient authorizedGitHubClient) { return(new ObservableCollection <Issue>(await _issueRepository.GetAllClosedIssuesForRepository(repositoryId, authorizedGitHubClient))); }
public async Task <ObservableCollection <Issue> > GetAllClosedIssuesForCurrentUser(GitHubClient authorizedGithubClient) { return(new ObservableCollection <Issue>(await _issueRepository.GetAllClosedIssuesForCurrentUser(authorizedGithubClient))); }
public async Task ReplaceLabelsForIssue(long repositoryId, int issueNumber, string labels, GitHubClient authorizedGitHubClient) { await _issueRepository.ReplaceLabelsForIssue(repositoryId, issueNumber, StringToStringArrayConverter.Convert(labels), authorizedGitHubClient); }
public async Task <bool> UnStarRepository(string repositoryOwner, string repositoryName, GitHubClient authorizedGithubClient) { return(await _repoRepository.UnStarRepository(repositoryOwner, repositoryName, authorizedGithubClient)); }
private async Task DoRepositoryAsync(Repository repository, GitHubClient gitHubClient) { }
public async Task <ObservableCollection <Label> > GetLabelsForRepository(long repositoryId, GitHubClient authorizedGitHubClient) { return(new ObservableCollection <Label>(await _issueRepository.GetLabelsForRepository(repositoryId, authorizedGitHubClient))); }
public async Task <Repository> ForkRepository(long repositoryId, GitHubClient authorizedGithubClient) { return(await _repoRepository.ForkRepository(repositoryId, authorizedGithubClient)); }
public async Task <IssueComment> UpdateComment(long repositoryId, int issueNumber, string updatedComment, GitHubClient authorizedGitHubClient) { return(await _issueRepository.UpdateComment(repositoryId, issueNumber, updatedComment, authorizedGitHubClient)); }
public async Task <Issue> RemoveAssigneesFromIssue(string owner, string name, int number, string assignees, GitHubClient authorizedGitHubClient) { return(await _issueRepository.RemoveAssigneesFromIssue(owner, name, number, new AssigneesUpdate(StringToStringArrayConverter.Convert(assignees)), authorizedGitHubClient)); }
public async Task <Issue> CreateIssue(long repositoryId, NewIssue newIssueDetails, GitHubClient authorizedGitHubClient) { return(await _issueRepository.CreateIssue(repositoryId, newIssueDetails, authorizedGitHubClient)); }
public async Task <Milestone> UpdateMilestone(long repoId, int number, MilestoneUpdate milestoneUpdate, GitHubClient authorizedGitHubClient) { return(await _issueRepository.UpdateMilestone(repoId, number, milestoneUpdate, authorizedGitHubClient)); }
public async Task <Issue> GetIssueForRepository(string owner, string repoName, int issueNumber, GitHubClient authorizedGitHubClient) { return(await _issueRepository.GetIssueForRepository(owner, repoName, issueNumber, authorizedGitHubClient)); }
public async Task <Issue> UpdateIssue(long repositoryId, int issueNumber, IssueUpdate updatedIssueDetails, GitHubClient authorizedGitHubClient) { return(await _issueRepository.UpdateIssue(repositoryId, issueNumber, updatedIssueDetails, authorizedGitHubClient)); }
public async Task <Repository> GetRepository(long repositoryId, GitHubClient githubClient) { return(await _repoRepository.GetRepository(repositoryId, githubClient)); }
public async Task <ObservableCollection <Milestone> > GetMilestonesForRepository(long repoId, GitHubClient authorizedGitHubClient) { return(new ObservableCollection <Milestone>(await _issueRepository.GetMilestonesForRepository(repoId, authorizedGitHubClient))); }
public async Task <IssueComment> GetComment(long repositoryId, int commentId, GitHubClient authorizedGitHubClient) { return(await _issueRepository.GetComment(repositoryId, commentId, authorizedGitHubClient)); }