/// <summary> /// Removes a label from an issue /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue">API documentation</a> for more information. /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The number of the issue</param> /// <param name="labelName">The name of the label to remove</param> public IObservable <Unit> RemoveFromIssue(string owner, string name, int number, string labelName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(labelName, "labelName"); return(_client.RemoveFromIssue(owner, name, number, labelName).ToObservable()); }
/// <summary> /// Removes a label from an issue /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue">API documentation</a> for more information. /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The number of the issue</param> /// <param name="labelName">The name of the label to remove</param> public IObservable <Label> RemoveFromIssue(string owner, string name, int number, string labelName) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(labelName, nameof(labelName)); return(_client.RemoveFromIssue(owner, name, number, labelName) .ToObservable() .SelectMany(x => x)); // HACK: DELETE is not compatible with GetAndFlattenPages }
public async Task CanRemoveFromIssue() { var newIssue = new NewIssue("A test issue") { Body = "A new unassigned issue" }; var newLabel = new NewLabel("test label 1b", "FFFFFF"); var label = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newLabel); Assert.NotNull(label); var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); Assert.NotNull(issue); await _issuesLabelsClient.AddToIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new [] { label.Name }); await _issuesLabelsClient.RemoveFromIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, label.Name); var labels = await _issuesLabelsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.Empty(labels); }
private async Task UpdateIssueLabelsAsync(PortingInfo ruleToPort, Issue existingIssue) { var existingLabelNames = new Collection <string>(existingIssue.Labels.Select(label => label.Name).ToList()); var labelNamesToAdd = new Collection <string>(); var labelNamesToRemove = new Collection <string>(); AddLabel(FxCopPortLabel, labelNamesToAdd, existingLabelNames); if (ruleToPort.Soon) { AddLabel(UrgencySoonLabel, labelNamesToAdd, existingLabelNames); } else { RemoveLabel(UrgencySoonLabel, labelNamesToRemove, existingLabelNames); } switch (ruleToPort.Disposition) { case Disposition.NeedsReview: AddLabel(NeedsReviewLabel, labelNamesToAdd, existingLabelNames); RemoveLabel(CutLabel, labelNamesToRemove, existingLabelNames); RemoveLabel(PortedLabel, labelNamesToRemove, existingLabelNames); break; case Disposition.Port: RemoveLabel(NeedsReviewLabel, labelNamesToRemove, existingLabelNames); RemoveLabel(CutLabel, labelNamesToRemove, existingLabelNames); RemoveLabel(PortedLabel, labelNamesToRemove, existingLabelNames); break; case Disposition.Cut: AddLabel(CutLabel, labelNamesToAdd, existingLabelNames); RemoveLabel(NeedsReviewLabel, labelNamesToRemove, existingLabelNames); RemoveLabel(PortedLabel, labelNamesToRemove, existingLabelNames); break; case Disposition.Ported: AddLabel(PortedLabel, labelNamesToAdd, existingLabelNames); RemoveLabel(CutLabel, labelNamesToRemove, existingLabelNames); RemoveLabel(NeedsReviewLabel, labelNamesToRemove, existingLabelNames); break; } RemoveAreaLabels(existingLabelNames, labelNamesToRemove); AddAreaLabel(ruleToPort, labelNamesToAdd); if (_options.DryRun) { _log.Info(Resources.InfoDryRunLabelsNotUpdated); } else { if (labelNamesToAdd.Any()) { await _issuesLabelsClient.AddToIssue( _options.RepoOwner, _options.RepoName, existingIssue.Number, labelNamesToAdd.ToArray()); } // Take care not to remove any labels we've just added. // // For some reason the "Remove" API doesn't take an array. foreach (string labelName in labelNamesToRemove.Except(labelNamesToAdd)) { await _issuesLabelsClient.RemoveFromIssue( _options.RepoOwner, _options.RepoName, existingIssue.Number, labelName); } } }
/// <summary> /// Removes a label from an issue /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue">API documentation</a> for more information. /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="repo">The name of the repository</param> /// <param name="number">The number of the issue</param> /// <param name="label">The name of the label to remove</param> /// <returns></returns> public IObservable <Unit> RemoveFromIssue(string owner, string repo, int number, string label) { return(_client.RemoveFromIssue(owner, repo, number, label).ToObservable()); }