public async Task ReturnsCorrectCountOfIssueLabelsWithStartForAnIssue()
    {
        var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewIssue("A test issue") { Body = "A new unassigned issue" });
        var issueUpdate = new IssueUpdate();

        var labels = new List<Label>();

        for (int i = 0; i < 2; i++)
        {
            var label = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewLabel("test label " + (i + 1), "FFFFF" + (i+1)));
            labels.Add(label);
            issueUpdate.AddLabel(label.Name);
        }

        var issueLabelsInfo = await _issuesLabelsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
        Assert.Empty(issueLabelsInfo);
        
        var updated = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, issueUpdate);
        Assert.NotNull(updated);

        var options = new ApiOptions
        {
            PageCount = 1,
            PageSize = 1,
            StartPage = 2
        };

        issueLabelsInfo = await _issuesLabelsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, options);

        Assert.Equal(1, issueLabelsInfo.Count);
        Assert.Equal(labels.Last().Color, issueLabelsInfo.First().Color);
    }
    public async Task ReturnsCorrectCountOfIssueLabelsWithoutStartForAnIssue()
    {
        var newIssue = new NewIssue("A test issue") { Body = "A new unassigned issue" };
        var newLabel = new NewLabel("test label", "FFFFFF");

        var label = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newLabel);
        var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);

        var issueLabelsInfo = await _issuesLabelsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
        Assert.Empty(issueLabelsInfo);

        var issueUpdate = new IssueUpdate();
        issueUpdate.AddLabel(label.Name);
        var updated = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, issueUpdate);
        Assert.NotNull(updated);

        var options = new ApiOptions
        {
            PageCount = 1,
            PageSize = 1
        };

        issueLabelsInfo = await _issuesLabelsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, options);

        Assert.Equal(1, issueLabelsInfo.Count);
        Assert.Equal(newLabel.Color, issueLabelsInfo[0].Color);
    }
Beispiel #3
0
		public async Task when_updating_issue_then_can_assign_non_existent_label()
		{
			var label = Guid.NewGuid().ToString();
            var github = new GitHubClient(
                new ProductHeaderValue("kzu-client"), new InMemoryCredentialStore(credentials));

			var update = new IssueUpdate
            {
                State = ItemState.Open,
            };
			update.AddLabel(label);

            await github.Issue.Update("kzu", "sandbox", 56, update);

			var issue = await github.Issue.Get("kzu", "sandbox", 56);

			Assert.True(issue.Labels.Any(l => l.Name == label));

			var labels = await github.Issue.Labels.GetForRepository("kzu", "sandbox");
			foreach (var l in labels.Select(l => l.Name)) {
				Guid g;
				if (Guid.TryParse(l, out g))
					await github.Issue.Labels.Delete("kzu", "sandbox", l);
			}
		}
Beispiel #4
0
		public bool Process(IssuesEvent issue, IssueUpdate update)
		{
			if (processed.Contains(issue))
				return false;

			var updated = ProcessAsync(issue, update).Result;
			processed.Add(issue);

			return updated;
		}
Beispiel #5
0
        public bool Process(IssuesEvent issue, IssueUpdate update)
        {
            var match = expression.Match(update.Title);
            if (!match.Success)
                return false;

            var login = match.Groups["user"].Value;
            if (string.Equals(login, "me", StringComparison.OrdinalIgnoreCase))
                update.Assignee = issue.Sender.Login;
            else
                update.Assignee = login;

            update.Title = update.Title.Replace(match.Value, "");

            return true;
        }
    public async Task CanListLabelsForAnIssue()
    {
        var newIssue = new NewIssue("A test issue") { Body = "A new unassigned issue" };
        var newLabel = new NewLabel("test label", "FFFFFF");

        var label = await _issuesLabelsClient.Create(_repositoryOwner, _repository.Name, newLabel);
        var issue = await _issuesClient.Create(_repositoryOwner, _repositoryName, newIssue);

        var issueLabelsInfo = await _issuesLabelsClient.GetForIssue(_repositoryOwner, _repositoryName, issue.Number);
        Assert.Empty(issueLabelsInfo);

        var issueUpdate = new IssueUpdate();
        issueUpdate.Labels.Add(label.Name);
        var updated = await _issuesClient.Update(_repositoryOwner, _repository.Name, issue.Number, issueUpdate);
        Assert.NotNull(updated);
        issueLabelsInfo = await _issuesLabelsClient.GetForIssue(_repositoryOwner, _repositoryName, issue.Number);

        Assert.Equal(1, issueLabelsInfo.Count);
        Assert.Equal(newLabel.Color, issueLabelsInfo[0].Color);
    }
Beispiel #7
0
        public bool Process(IssuesEvent issue, IssueUpdate update)
        {
            var match = expression.Match(update.Title);
            if (!match.Success)
                return false;

            if (labels == null)
            {
                labels = github.Issue.Labels.GetForRepository(issue.Repository.Owner.Login, issue.Repository.Name)
                    .Result
                    .Select(l => l.Name)
                    .ToList();
            }

            // Match label in case-insensitive manner, without the prefix first
            var label = labels.FirstOrDefault(l => string.Equals(l, match.Groups["simpleLabel"].Value, StringComparison.OrdinalIgnoreCase));
            if (label == null)
                // Labels themselves could use the "+" sign, so we match next by the full string.
                label = labels.FirstOrDefault(l => string.Equals(l, match.Groups["fullLabel"].Value, StringComparison.OrdinalIgnoreCase));

            if (label != null)
            {
                update.AddLabel(label);
                tracer.Verbose("Applied pre-defined label '{0}'", label);
            }
            else
            {
                // Just apply the bare label as-is otherwise.
                label = match.Groups["simpleLabel"].Value;
                update.AddLabel(label);
                tracer.Verbose("Applied ad-hoc label '{0}'", label);
            }

            update.Title = update.Title.Replace(match.Value, "");

            return true;
        }
Beispiel #8
0
        public void when_processing_issue_other_links_then_updates_with_story_link_from_prefix()
        {
            var github = new Mock<IGitHubClient>(MockBehavior.Strict);
            var task = new Issue
            {
                Number = 1,
                Title = "[ui] Issue with story prefix",
                Body = "An issue with an existing issue #2 link",
                Labels = new[] { new Label { Name = "Task" } }
            };

            github.SetupGet(repository, task);
            github.SetupGet(repository, new Issue
            {
                Number = 2,
                Labels = new List<Label>()
            });
            github.SetupSearch(new Issue
            {
                Number = 3,
                Title = "[ui] Story"
            });

            var linker = new AutoLink(github.Object);
            var update = new IssueUpdate();
            var updated = linker.Process(new Octokit.Events.IssuesEvent
            {
                Action = IssuesEvent.IssueAction.Opened,
                Issue = task,
                Repository = repository,
                Sender = repository.Owner,
            }, update);

            Assert.True(updated);
            Assert.True(update.Body.Contains("#3"));
        }
Beispiel #9
0
		private async Task<bool> ProcessAsync(IssuesEvent issue, IssueUpdate update)
		{
			var storyPrefix = storyPrefixExpr.Match(issue.Issue.Title);
			if (!storyPrefix.Success)
			{
				tracer.Verbose("Skipping issue {0}/{1}#{2} without a story prefix: '{3}'.",
					issue.Repository.Owner.Login,
					issue.Repository.Name,
					issue.Issue.Number,
					issue.Issue.Title);
				return false;
			}

			// Skip issues that are the story itself.
			if (issue.Issue.Labels != null &&
				issue.Issue.Labels.Any(l => string.Equals(l.Name, "story", StringComparison.OrdinalIgnoreCase)))
				return false;

			// Skip the issue if it already has a story link
			if (!string.IsNullOrEmpty(issue.Issue.Body))
			{
				foreach (var number in issueLinkExpr.Matches(issue.Issue.Body).OfType<Match>().Where(m => m.Success).Select(m => int.Parse(m.Value)))
				{
					try
					{
						var linkedIssue = await github.Issue.Get(issue.Repository.Owner.Login, issue.Repository.Name, number);
						if (linkedIssue.Labels.Any(l => string.Equals(l.Name, "story", StringComparison.OrdinalIgnoreCase)))
						{
							tracer.Info("Skipping issue {0}/{1}#{2} as it already contains story link to #{3}.",
								issue.Repository.Owner.Login,
								issue.Repository.Name,
								issue.Issue.Number,
								number);
							return false;
						}
					}
					catch (NotFoundException)
					{
						// It may be a link to a bug/issue in another system.
					}
				}
			}

			// Find the story with the same prefix.
			var repository = issue.Repository.Owner.Login + "/" + issue.Repository.Name;
			var story = await FindOpenStoryByPrefixAsync(repository, storyPrefix.Value);
			if (story == null || story.State == ItemState.Closed)
			{
				tracer.Warn("Issue {0}/{1}#{2} has story prefix '{3}' but no matching opened issue with the label 'Story' or 'story' was found with such prefix.",
					issue.Repository.Owner.Login,
					issue.Repository.Name,
					issue.Issue.Number,
					storyPrefix.Value);
				return false;
			}

			update.State = issue.Issue.State;
			update.Body = (issue.Issue.Body == null ? "" : issue.Issue.Body + @"

")
					+ "Story #" + story.Number;

			tracer.Info("Established new story link between issue {0}/{1}#{2} and story #{3}.",
				issue.Repository.Owner.Login,
				issue.Repository.Name,
				issue.Issue.Number,
				story.Number);

			return true;
		}
Beispiel #10
0
        public IssueUpdate ToUpdate()
        {
            var milestoneId = Milestone == null
                ? new int?()
                : Milestone.Number;

            var assignee = Assignee == null
                ? null
                : Assignee.Name;

            var issueUpdate = new IssueUpdate
            {
                Assignee = assignee,
                Body = Body,
                Milestone = milestoneId,
                State = State,
                Title = Title
            };

            if (Labels.Any())
            {
                issueUpdate.Labels = new List<string>(Labels.Select(l => l.Name));
            }

            return issueUpdate;
        }
Beispiel #11
0
		public async Task when_task_list_link_exists_and_matches_then_does_not_update()
		{
			var github = new Mock<IGitHubClient>();
			var task = new Issue
			{
				Number = 1,
				Title = "Issue with story link",
				Body = "Story #2",
			};

			github.SetupGet(repository, task);
			github.SetupGet(repository, new Issue
			{
				Number = 2,
				Title = "Story",
				Body = OctoHook.Properties.Strings.FormatTask(" ", "#" + task.Number, task.Title)
			});

			var linker = new AutoTask(github.Object);
			var update = new IssueUpdate();

			await linker.ProcessAsync(new Octokit.Events.IssuesEvent
			{
				Action = IssuesEvent.IssueAction.Opened,
				Issue = task,
				Repository = repository,
				Sender = repository.Owner
			});

			github.Verify(x => x.Issue.Update(repository.Owner.Login, repository.Name, 2, It.IsAny<IssueUpdate>()),
				Times.Never());
		}
    public async Task ReturnsDistinctIssueLabelsBasedOnStartPageForAMilestoneWithRepositoryId()
    {
        var newMilestone = new NewMilestone("New Milestone");
        var milestone = await _issuesClient.Milestone.Create(_context.RepositoryOwner, _context.RepositoryName, newMilestone);

        for (int i = 0; i < 2; i++)
        {
            int k = i + 1;
            var newIssue = new NewIssue("A test issue " + k) { Body = "A new unassigned issue " + k };
            var newLabel = new NewLabel("test label " + k, "FFFFF" + k);

            var label = await _issuesLabelsClient.Create(_context.Repository.Id, newLabel);
            var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);

            var issueUpdate = new IssueUpdate { Milestone = milestone.Number };
            issueUpdate.AddLabel(label.Name);
            var updated = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, issueUpdate);
            Assert.NotNull(updated);
        }

        var startOptions = new ApiOptions
        {
            PageCount = 1,
            PageSize = 1,
            StartPage = 1
        };

        var firstPage = await _issuesLabelsClient.GetAllForMilestone(_context.Repository.Id, milestone.Number, startOptions);

        var skipStartOptions = new ApiOptions
        {
            PageSize = 1,
            PageCount = 1,
            StartPage = 2
        };

        var secondPage = await _issuesLabelsClient.GetAllForMilestone(_context.Repository.Id, milestone.Number, skipStartOptions);

        Assert.Equal(1, firstPage.Count);
        Assert.Equal(1, secondPage.Count);
        Assert.NotEqual(firstPage.First().Color, secondPage.First().Color);
    }
    public async Task CanListLabelsForAnMilestoneWithRepositoryId()
    {
        var newIssue = new NewIssue("A test issue") { Body = "A new unassigned issue" };
        var newLabel = new NewLabel("test label", "FFFFFF");
        var newMilestone = new NewMilestone("New Milestone");

        var label = await _issuesLabelsClient.Create(_context.Repository.Id, newLabel);
        var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);
        var milestone = await _issuesClient.Milestone.Create(_context.RepositoryOwner, _context.RepositoryName, newMilestone);
        
        var issueLabelsInfo = await _issuesLabelsClient.GetAllForMilestone(_context.Repository.Id, milestone.Number);
        Assert.Empty(issueLabelsInfo);

        var issueUpdate = new IssueUpdate { Milestone = milestone.Number };
        issueUpdate.AddLabel(label.Name);

        var updated = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, issueUpdate);
        Assert.NotNull(updated);

        issueLabelsInfo = await _issuesLabelsClient.GetAllForMilestone(_context.Repository.Id, milestone.Number);

        Assert.Equal(1, issueLabelsInfo.Count);
        Assert.Equal(label.Color, issueLabelsInfo[0].Color);
    }
    public async Task ReturnsCorrectCountOfIssueLabelsWithStartForAMilestoneWithRepositoryId()
    {
        var newMilestone = new NewMilestone("New Milestone");
        var milestone = await _issuesClient.Milestone.Create(_context.RepositoryOwner, _context.RepositoryName, newMilestone);

        for (int i = 0; i < 2; i++)
        {
            int k = i + 1;
            var newIssue = new NewIssue("A test issue " + k) { Body = "A new unassigned issue " + k };
            var newLabel = new NewLabel("test label " + k, "FFFFF" + k);

            var label = await _issuesLabelsClient.Create(_context.Repository.Id, newLabel);
            var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);

            var issueUpdate = new IssueUpdate { Milestone = milestone.Number };
            issueUpdate.AddLabel(label.Name);
            var updated = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, issueUpdate);
            Assert.NotNull(updated);
        }

        var options = new ApiOptions
        {
            PageCount = 1,
            PageSize = 1,
            StartPage = 2
        };

        var issueLabelsInfo = await _issuesLabelsClient.GetAllForMilestone(_context.Repository.Id, milestone.Number, options);

        Assert.Equal(1, issueLabelsInfo.Count);
    }
		private async Task CloseIssue(Issue issue)
		{
			var issueUpdate = new IssueUpdate { State = ItemState.Closed };
			Console.WriteLine("{0} - > Close issue", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
			await _gitHubClient.Issue.Update(_options.GitHubOwner, _options.GitHubRepository, issue.Number, issueUpdate);
		}
    public async Task ReturnsDistinctIssueLabelsBasedOnStartPageForAnIssue()
    {
        var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewIssue("A test issue") { Body = "A new unassigned issue" });
        var issueUpdate = new IssueUpdate();
        
        for (int i = 0; i < 2; i++)
        {
            var label = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewLabel("test label " + (i + 1), "FFFFF" + (i + 1)));
            issueUpdate.AddLabel(label.Name);
        }

        var issueLabelsInfo = await _issuesLabelsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
        Assert.Empty(issueLabelsInfo);

        var updated = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, issueUpdate);
        Assert.NotNull(updated);

        var startOptions = new ApiOptions
        {
            PageCount = 1,
            PageSize = 1,
            StartPage = 1
        };

        var firstPage = await _issuesLabelsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, startOptions);

        var skipStartOptions = new ApiOptions
        {
            PageSize = 1,
            PageCount = 1,
            StartPage = 2
        };

        var secondPage = await _issuesLabelsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, skipStartOptions);

        Assert.Equal(1, firstPage.Count);
        Assert.Equal(1, secondPage.Count);
        Assert.NotEqual(firstPage.First().Color, secondPage.First().Color);
    }
 public override void UpdateIssue(Repository repository, int id, IssueUpdate update)
 {
     Issue = new Issue(null, null, id, ItemState.Open, update.Title, update.Body, null, null, null, null, 0, null, null, DateTimeOffset.Now, null );
 }
Beispiel #18
0
        /// <summary>
        /// Updates an issue for the specified repository. Issue owners and users with push access can edit an issue.
        /// </summary>
        /// <remarks>https://developer.github.com/v3/issues/#edit-an-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>
        /// <param name="issueUpdate">An <see cref="IssueUpdate"/> instance describing the changes to make to the issue
        /// </param>
        /// <returns>The created <see cref="Task"/> representing the updated issue from the API.</returns>
        public Task<Issue> Update(string owner, string name, int number, IssueUpdate issueUpdate)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(issueUpdate, "issueUpdate");

            return ApiConnection.Patch<Issue>(ApiUrls.Issue(owner, name, number), issueUpdate);
        }
        public void UpdatesClientIssueIssue()
        {
            var issueUpdate = new IssueUpdate();
            var gitHubClient = Substitute.For<IGitHubClient>();
            var client = new ObservableIssuesClient(gitHubClient);

            client.Update("fake", "repo", 42, issueUpdate);

            gitHubClient.Issue.Received().Update("fake", "repo", 42, issueUpdate);
        }
        public override async void CloseIssue(Issue issue, string comment)
        {
            if (!string.IsNullOrWhiteSpace(comment))
                AddComment(issue, comment);

            if (Repository == null)
                return;

            var update = new IssueUpdate();
            update.State = ItemState.Closed;
            try
            {
                var updatedIssue = await _github.Issue.Update(Repository.Repository.Owner.Login, Repository.Repository.Name, issue.Number, update);
                if (updatedIssue.State == ItemState.Closed)
                {
                    AllIssues.Remove(issue);
                    Issue = null;
                    IssueMarkdown = string.Empty;
                }
            }
            catch ( Exception exception )
            {
                _log.Write(LogLevel.Error, "Failed to update issue.", exception );
            }
        }
Beispiel #21
0
		public async Task when_link_comes_from_task_list_then_does_not_process_it()
		{
			var github = new Mock<IGitHubClient>(MockBehavior.Strict);
			var task = new Issue
			{
				Number = 1,
				Title = "Issue with story link",
				Body = "- [ ] #2 A Story",
			};

			github.SetupGet(repository, task);

			var linker = new AutoTask(github.Object);
			var update = new IssueUpdate();

			await linker.ProcessAsync(new Octokit.Events.IssuesEvent
			{
				Action = IssuesEvent.IssueAction.Opened,
				Issue = task,
				Repository = repository,
				Sender = repository.Owner
			});
		}
Beispiel #22
0
		public async Task when_task_list_link_doesnt_exists_then_adds_it_automatically_integration()
		{
			var github = new GitHubClient(new ProductHeaderValue("octohook"), new InMemoryCredentialStore(credentials));
			var story = await github.Issue.Create("kzu", "sandbox", new NewIssue("Story"));
			var task = await github.Issue.Create("kzu", "sandbox", new NewIssue("Issue with story link")
			{
				Body = "Story #" + story.Number,
			});

			var expectedLink = OctoHook.Properties.Strings.FormatTask(" ", "#" + task.Number, task.Title);
			var linker = new AutoTask(github);
			var update = new IssueUpdate();

			await linker.ProcessAsync(new Octokit.Events.IssuesEvent
			{
				Action = IssuesEvent.IssueAction.Opened,
				Issue = task,
				Repository = new Repository
				{
					Name = "sandbox",
					Owner = new User { Login = "******" },
				},
				Sender = new User { Login = "******" }
			});

			var updated = await github.Issue.Get("kzu", "sandbox", story.Number);

			Assert.True(updated.Body.Contains(expectedLink));

			await github.Issue.Update("kzu", "sandbox", task.Number, new IssueUpdate { State = ItemState.Closed });
			await github.Issue.Update("kzu", "sandbox", story.Number, new IssueUpdate { State = ItemState.Closed });
		}
Beispiel #23
0
        public void MigrateToIssue(MigrateJiraIssuesToGithub.Models.Issue jiraIssue, List<MilestoneGitHub> milestones, List<LabelGitHub> labels, ref Issue githubIssue)
        {
            if (String.IsNullOrEmpty(jiraIssue.SprintName))
            {
                jiraIssue.SprintName = "1.0 Inicial";
            }

            if (githubIssue == null)
            {
                var newIssue = new NewIssue(jiraIssue.Title)
                {
                    Body = jiraIssue.Content,
                    Milestone = milestones.First(m => m.Title == jiraIssue.SprintName).Number
                };

                foreach (var label in jiraIssue.Labels)
                {
                    newIssue.Labels.Add(label);
                }

                var nIssue = newIssue;
                var taskResult = Task.Run<Octokit.Issue>(async () => await client.Issue.Create(githubOrganizationName, githubRepositoryName, nIssue));
                githubIssue = taskResult.Result;
            }

            //todo: archive...

            // obs.: atribuir usuário à tarefa
            /*if (issueYAA923.Assigned != null)
            {
                try
                {
                    client.Issue.Assignee.CheckAssignee(githubOrganizationName, githubRepositoryName, issueYAA923.Assigned.Name); //"gBritz"
                }
                catch (Exception ex)
                {
                    Log("ERROR: Não conseguiu atribuir ao usuário " + issueYAA923.Assigned.Name); //obs.: caso não exista no projeto, irá gerar erro ao cadastrar issue

                    var msg = String.Format("Originalmente atribuído para o {0} ({1}) no jira.", issueYAA923.Assigned.Name, issueYAA923.Assigned.Email);
                    client.Issue.Comment.Create(githubOrganizationName, githubRepositoryName, issueResult.Number, msg);
                }
            }*/

            var sbStatusComment = new StringBuilder();

            sbStatusComment.AppendFormat(@"
            **Status in Jira**
            {0} ({1}) `Created` at {1:dd/MM/yyyy hh:mm:ss}
            ", jiraIssue.Creator.Name, jiraIssue.Creator.Email, jiraIssue.CreateAt);

            if (jiraIssue.InProgress != null && jiraIssue.InProgressAt.HasValue)
            {
                sbStatusComment.AppendFormat(@"
            {0} ({1}) set `In Progress` at {2:dd/MM/yyyy hh:mm:ss}", jiraIssue.InProgress.Name, jiraIssue.InProgress.Email, jiraIssue.InProgressAt);
            }

            if (jiraIssue.Resolved != null && jiraIssue.ResolvedAt.HasValue)
            {
                sbStatusComment.AppendFormat(@"
            {0} ({1}) set `Resolved` at {2:dd/MM/yyyy hh:mm:ss}", jiraIssue.Resolved.Name, jiraIssue.Resolved.Email, jiraIssue.ResolvedAt);
            }

            if (jiraIssue.Closer != null && jiraIssue.ClosedAt.HasValue)
            {
                sbStatusComment.AppendFormat(@"
            {0} ({1}) set `Closed` at {2:dd/MM/yyyy hh:mm:ss}", jiraIssue.Closer.Name, jiraIssue.Closer.Email, jiraIssue.ClosedAt);
            }

            client.Issue.Comment.Create(githubOrganizationName, githubRepositoryName, githubIssue.Number, sbStatusComment.ToString());

            // obs.: adicionar comentários
            foreach (var comment in jiraIssue.Comments)
            {
                var commentAuthor = String.Format(@"
            **Commentary** by {0} ({1})
            ", comment.Creator.Name, comment.Creator.Email);
                client.Issue.Comment.Create(githubOrganizationName, githubRepositoryName, githubIssue.Number, commentAuthor + comment.Body);
            }

            // obs.: fechar issue
            if (jiraIssue.ClosedAt.HasValue)
            {
                var issueUpdate = new IssueUpdate
                {
                    State = ItemState.Closed
                };

                client.Issue.Update(githubOrganizationName, githubRepositoryName, githubIssue.Number, issueUpdate);
            }

            Log(String.Format("Info: Issue {0} created", jiraIssue.JiraKey));
        }
 public override async void UpdateIssue(Repository repository, int id, IssueUpdate update)
 {
     try
     {
         Issue issueUpdate = await _github.Issue.Update(repository.Owner.Login, repository.Name, id, update);
         if (Repository != null && repository.Id == Repository.Repository.Id)
         {
             foreach (var issue in AllIssues)
             {
                 if (issue.Number == issueUpdate.Number)
                 {
                     AllIssues.Remove(issue);
                     AllIssues.Insert(0, issueUpdate);
                     Issue = issueUpdate;
                     break;
                 }
             }
         }
     }
     catch ( Exception exception )
     {
         _log.Write(LogLevel.Error, "Failed to save issue.", exception);
     }
 }
            public void PostsToCorrectUrl()
            {
                var issueUpdate = new IssueUpdate();
                var connection = Substitute.For<IApiConnection>();
                var client = new IssuesClient(connection);

                client.Update("fake", "repo", 42, issueUpdate);

                connection.Received().Patch<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42"),
                    issueUpdate);
            }
        public void UpdatesClientIssueIssueWithRepositoryId()
        {
            var issueUpdate = new IssueUpdate();
            var gitHubClient = Substitute.For<IGitHubClient>();
            var client = new ObservableIssuesClient(gitHubClient);

            client.Update(1, 42, issueUpdate);

            gitHubClient.Issue.Received().Update(1, 42, issueUpdate);
        }
Beispiel #27
0
        /// <summary>
        /// Updates an issue for the specified repository. Any user with pull access to a repository can update an
        /// issue.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/issues/#edit-an-issue</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="number">The issue number</param>
        /// <param name="issueUpdate">An <see cref="IssueUpdate"/> instance describing the changes to make to the issue
        /// </param>
        public Task<Issue> Update(long repositoryId, int number, IssueUpdate issueUpdate)
        {
            Ensure.ArgumentNotNull(issueUpdate, "issueUpdate");

            return ApiConnection.Patch<Issue>(ApiUrls.Issue(repositoryId, number), issueUpdate);
        }
Beispiel #28
0
        /// <summary>
        /// Updates an issue for the specified repository. Any user with pull access to a repository can update an
        /// issue.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/issues/#edit-an-issue</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="number">The issue number</param>
        /// <param name="issueUpdate">An <see cref="IssueUpdate"/> instance describing the changes to make to the issue
        /// </param>
        public Task <Issue> Update(int repositoryId, int number, IssueUpdate issueUpdate)
        {
            Ensure.ArgumentNotNull(issueUpdate, "issueUpdate");

            return(ApiConnection.Patch <Issue>(ApiUrls.Issue(repositoryId, number), issueUpdate));
        }
Beispiel #29
0
        public IssueUpdate ToUpdate()
        {
            var milestoneId = Milestone == null
                ? new int?()
                : Milestone.Number;

            var assignee = Assignee == null
                ? null
                : Assignee.Name;

            var issueUpdate = new IssueUpdate
            {
                Assignee = assignee,
                Body = Body,
                Milestone = milestoneId,
                State = State,
                Title = Title
            };

            foreach (var label in Labels)
            {
                issueUpdate.Labels.Add(label.Name);
            }

            return issueUpdate;
        }
Beispiel #30
0
        public IssueUpdate ToUpdate()
        {
            var milestoneId = Milestone == null
                ? new int?()
                : Milestone.Number;

            var assignee = Assignee == null
                ? null
                : Assignee.Login;

            var issueUpdate = new IssueUpdate
            {
                Assignee = assignee,
                Body = Body,
                Milestone = milestoneId,
                State = State,
                Title = Title
            };

            return issueUpdate;
        }
 public abstract void UpdateIssue(Repository repository, int id, IssueUpdate update);