/// <summary> /// Gets a single Issue by number. /// </summary> /// <remarks> /// http://developer.github.com/v3/issues/#get-a-single-issue /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The issue number</param> public IObservable <Issue> Get(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); return(_client.Get(owner, name, number).ToObservable()); }
public async Task CanCreateRetrieveAndCloseIssue() { string owner = _repository.Owner.Login; var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(owner, _repository.Name, newIssue); try { Assert.NotNull(issue); var retrieved = await _issuesClient.Get(owner, _repository.Name, issue.Number); var all = await _issuesClient.GetForRepository(owner, _repository.Name); Assert.NotNull(retrieved); Assert.True(all.Any(i => i.Number == retrieved.Number)); } finally { var closed = _issuesClient.Update(owner, _repository.Name, issue.Number, new IssueUpdate { State = ItemState.Closed }) .Result; Assert.NotNull(closed); } }
static void WriteCard(ProjectCard card) { string text; if (card.ContentUrl != null) { var cardURL = card.ContentUrl; var issueID = Int32.Parse(cardURL.Split('/').Last()); var issue = issuesClient.Get(repo.Id, issueID).Result; text = MakeLink(issue.Title, issue.Url); if (issue.State.Value == ItemState.Closed) { text = MakeStrikethrough(text); } text = MakeItalic("#" + issueID) + " -- " + text; } else { text = card.Note; } writer.WriteLine(text); writer.WriteLine(writer.NewLine + "---" + writer.NewLine); }
public async Task CanDeserializeIssue() { const string title = "a test issue"; const string description = "A new unassigned issue"; var newIssue = new NewIssue(title) { Body = description }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.NotNull(retrieved); Assert.NotEqual(0, issue.Id); Assert.Equal(false, issue.Locked); Assert.Equal(title, retrieved.Title); Assert.Equal(description, retrieved.Body); }
private async Task UpdateGitHubIssues(IEnumerable <Issue> gitHubIssuesCreated, IEnumerable <GoogleIssue> googleIssues) { const string gitHubIssueNotFoundStringFormatTemplate = "ERROR: Unable to retrieve Issue #{0} from GitHub."; //convert to list to avoid re-enumeration of IEnumerable googleIssues = googleIssues.ToList(); //final step, update each issue to reflect correct status, etc. foreach (var gitHubIssue in gitHubIssuesCreated) { var correspondingGoogleIssue = googleIssues.Single(s => s.Id == gitHubIssue.Number); //santity-check: ensure that the target issue actually exists on GitHub, report error if not found try { var gitHubIssueToUpdate = await _issuesClient.Get(_settings.GitHubRepositoryOwner, _settings.GitHubRepositoryName, gitHubIssue.Number); if (null == gitHubIssueToUpdate) { //just throw in order to end up in the catch block... throw new Exception(); } } catch (Exception) { Logger.ErrorFormat(gitHubIssueNotFoundStringFormatTemplate, correspondingGoogleIssue.Id); //TODO: reconsider this choice to continue on here...since we require all GitHub issue numbers // to match their Google Code issue numbers, its not ENTIRELY correct to just log-and-ignore this error condition... continue; } //assuming we got this far, process the update... Logger.InfoFormat("Processing Update to Issue #{0}", correspondingGoogleIssue.Id); var issueUpdate = ComposeIssueUpdate(correspondingGoogleIssue); await _issuesClient.Update(_settings.GitHubRepositoryOwner, _settings.GitHubRepositoryName, gitHubIssue.Number, issueUpdate); } }
public async Task LoadIssue(IIssuesClient client) { var issue = await client.Get(this.Owner, this.Repo, int.Parse(this.Number)); this.Issue = issue; }