public async Task CanUpdateIssueLabel() { var newLabel = new NewLabel("test label", "FFFFFF") { Description = "Test label description." }; var label = await _issuesLabelsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newLabel); Assert.NotNull(label); var labelUpdate = new LabelUpdate("test label", "000000") { Description = "Updated label description." }; label = await _issuesLabelsClient.Update(_context.RepositoryOwner, _context.RepositoryName, labelUpdate.Name, labelUpdate); Assert.NotNull(label); var issueLabelLookupByName = await _issuesLabelsClient.Get(_context.RepositoryOwner, _context.RepositoryName, label.Name); Assert.Equal(labelUpdate.Name, issueLabelLookupByName.Name); Assert.Equal(labelUpdate.Color, issueLabelLookupByName.Color); Assert.Equal(labelUpdate.Description, issueLabelLookupByName.Description); }
public async Task EnsuresNonNullArguments() { var client = new IssuesLabelsClient(Substitute.For <IApiConnection>()); var labelUpdate = new LabelUpdate("name", "FF0000"); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update(null, "name", "labelName", labelUpdate)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update("owner", null, "labelName", labelUpdate)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update("owner", "name", null, labelUpdate)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update("owner", "name", "labelName", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update(1, null, labelUpdate)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update(1, "labelName", null)); await Assert.ThrowsAsync <ArgumentException>(() => client.Update("", "name", "labelName", labelUpdate)); await Assert.ThrowsAsync <ArgumentException>(() => client.Update("owner", "", "labelName", labelUpdate)); await Assert.ThrowsAsync <ArgumentException>(() => client.Update("owner", "name", "", labelUpdate)); await Assert.ThrowsAsync <ArgumentException>(() => client.Update(1, "", labelUpdate)); }
private void Main_Load(object sender, EventArgs e) { lbl_ConnStatus.Text = "Not Connected"; lbl_ConnStatus.ForeColor = Color.Red; LabelUpdate.Start(); CleanOutTemp(); }
/// <summary> /// Updates a label. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#update-a-label">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="labelName">The name of the label</param> /// <param name="labelUpdate">The data for the label to be updated</param> public IObservable <Label> Update(long repositoryId, string labelName, LabelUpdate labelUpdate) { Ensure.ArgumentNotNullOrEmptyString(labelName, nameof(labelName)); Ensure.ArgumentNotNull(labelUpdate, nameof(labelUpdate)); return(_client.Update(repositoryId, labelName, labelUpdate).ToObservable()); }
public static async Task CreateOrUpdateLabelAsync(this GitHubClient client, RepositoryInfo repository, Models.Objects.Label label) { IssuesLabelsClient ilc = new IssuesLabelsClient(new ApiConnection(client.Connection)); Colorizer.WriteLine("Creating or updating label [Cyan!{0}] in repo [Yellow!{1}]", $"Title: {label.Title}, Description: {label.Description}, Color: {label.Color}", repository); try { Label existingLabel = await ilc.Get(repository.Owner, repository.Name, label.Title); // try to update the label Colorizer.WriteLine("Label found, updating"); LabelUpdate updateOperation = new LabelUpdate(label.Title, label.Color); updateOperation.Description = label.Description; await ilc.Update(repository.Owner, repository.Name, label.Title, updateOperation); Colorizer.WriteLine("[Green!Success]"); } catch (NotFoundException ex) { if (ex.StatusCode == System.Net.HttpStatusCode.NotFound) { Colorizer.WriteLine("Label not found, creating"); // try to create the label await CreateLabelAsync(client, repository, label); Colorizer.WriteLine("[Green!Success]"); } } }
/// <inheritdoc /> public async Task <Label> UpdateLabelAsync( long repositoryId, string labelName, LabelUpdate labelUpdate) { return(await gitHubClient.Issue.Labels.Update( repositoryId, labelName, labelUpdate)); }
/// <summary> /// Update a single label /// </summary> /// <param name="label">label to update</param> /// <returns>Updated label</returns> public async Task <Label> UpdateLabelAsync(Label label) { Arguments.CheckNotNull(label, nameof(label)); var labelUpdate = new LabelUpdate { Properties = label.Properties }; return(await UpdateLabelAsync(label.Id, labelUpdate)); }
public void UpdatesCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssuesLabelsClient(gitHubClient); var labelUpdate = new LabelUpdate("name", "FF0000"); client.Update(1, "labelName", labelUpdate); gitHubClient.Received().Issue.Labels.Update(1, "labelName", labelUpdate); }
public void UpdatesCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new IssuesLabelsClient(connection); var labelUpdate = new LabelUpdate("name", "FF0000"); client.Update(1, "labelName", labelUpdate); connection.Received().Post <Label>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/labels/labelName"), labelUpdate); }
public void UpdatesCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new IssuesLabelsClient(connection); var labelUpdate = new LabelUpdate("name", "FF0000"); client.Update("fake", "repo", "labelName", labelUpdate); connection.Received().Post <Label>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/labels/labelName"), labelUpdate, "application/vnd.github.symmetra-preview+json"); }
private async Task UpdateLabelAsync(Repository repoItem, Label labelItem) { LabelUpdate labelUpdate = new LabelUpdate(labelItem.Name, labelItem.Color) { Description = labelItem.Description }; await GitHubClient.Issue .Labels .Update(repoItem.Id, labelItem.Name, labelUpdate) .ConfigureAwait(false); WriteLog($"Updated label {labelItem.Name} in Repo: {repoItem.Name}", ConsoleColor.Cyan); }
public void EnsuresNonNullArguments() { var client = new ObservableIssuesLabelsClient(Substitute.For <IGitHubClient>()); var labelUpdate = new LabelUpdate("name", "FF0000"); Assert.Throws <ArgumentNullException>(() => client.Update(null, "name", "labelName", labelUpdate)); Assert.Throws <ArgumentNullException>(() => client.Update("owner", null, "labelName", labelUpdate)); Assert.Throws <ArgumentNullException>(() => client.Update("owner", "name", null, labelUpdate)); Assert.Throws <ArgumentNullException>(() => client.Update("owner", "name", "labelName", null)); Assert.Throws <ArgumentNullException>(() => client.Update(1, null, labelUpdate)); Assert.Throws <ArgumentNullException>(() => client.Update(1, "labelName", null)); Assert.Throws <ArgumentException>(() => client.Update("", "name", "labelName", labelUpdate)); Assert.Throws <ArgumentException>(() => client.Update("owner", "", "labelName", labelUpdate)); Assert.Throws <ArgumentException>(() => client.Update("owner", "name", "", labelUpdate)); Assert.Throws <ArgumentException>(() => client.Update(1, "", labelUpdate)); }
public static async Task <bool> EnsureLabelUpToDate(GitHubClient client, Label fromLabel, string toOrg, string toRepo) { var label = await client.Issue.Labels.Get(toOrg, toRepo, fromLabel.Name); // If the labels differs even a bit, update it! if (!(label.Name.Equals(fromLabel.Name) && label.Description.Equals(fromLabel.Description) && label.Color.Equals(fromLabel.Color))) { var newLabel = new LabelUpdate(fromLabel.Name, fromLabel.Color) { Description = fromLabel.Description }; await client.Issue.Labels.Update(toOrg, toRepo, fromLabel.Name, newLabel); return(true); } return(false); }
/// <inheritdoc/> protected override async Task <object> CallGitHubApi(DialogContext dc, Octokit.GitHubClient gitHubClient, CancellationToken cancellationToken = default(CancellationToken)) { if (Owner != null && Name != null && LabelName != null && LabelUpdate != null) { var ownerValue = Owner.GetValue(dc.State); var nameValue = Name.GetValue(dc.State); var labelNameValue = LabelName.GetValue(dc.State); var labelUpdateValue = LabelUpdate.GetValue(dc.State); return(await gitHubClient.Issue.Labels.Update(ownerValue, nameValue, labelNameValue, labelUpdateValue).ConfigureAwait(false)); } if (RepositoryId != null && LabelName != null && LabelUpdate != null) { var repositoryIdValue = RepositoryId.GetValue(dc.State); var labelNameValue = LabelName.GetValue(dc.State); var labelUpdateValue = LabelUpdate.GetValue(dc.State); return(await gitHubClient.Issue.Labels.Update((Int64)repositoryIdValue, labelNameValue, labelUpdateValue).ConfigureAwait(false)); } throw new ArgumentNullException("Required [labelName,labelUpdate] arguments missing for GitHubClient.Issue.Labels.Update"); }
/// <summary> /// Updates a label. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#update-a-label">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="name">The name of the label</param> /// <param name="labelUpdate">The data for the label to be updated</param> /// <returns>The updated label</returns> public IObservable<Label> Update(string owner, string repo, string name, LabelUpdate labelUpdate) { return _client.Update(owner, repo, name, labelUpdate).ToObservable(); }
/// <summary> /// Updates a label. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#update-a-label">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="labelName">The name of the label</param> /// <param name="labelUpdate">The data for the label to be updated</param> public IObservable<Label> Update(long repositoryId, string labelName, LabelUpdate labelUpdate) { Ensure.ArgumentNotNullOrEmptyString(labelName, "labelName"); Ensure.ArgumentNotNull(labelUpdate, "labelUpdate"); return _client.Update(repositoryId, labelName, labelUpdate).ToObservable(); }
public async Task EnsuresNonNullArguments() { var client = new IssuesLabelsClient(Substitute.For<IApiConnection>()); var labelUpdate = new LabelUpdate("name", "FF0000"); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(null, "name", "labelName", labelUpdate)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", null, "labelName", labelUpdate)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", "name", null, labelUpdate)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", "name", "labelName", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(1, null, labelUpdate)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(1, "labelName", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.Update("", "name", "labelName", labelUpdate)); await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "", "labelName", labelUpdate)); await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "name", "", labelUpdate)); await Assert.ThrowsAsync<ArgumentException>(() => client.Update(1, "", labelUpdate)); }
/// <summary> /// Updates a label. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#update-a-label">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="labelName">The name of the label</param> /// <param name="labelUpdate">The data for the label to be updated</param> public IObservable<Label> Update(string owner, string name, string labelName, LabelUpdate labelUpdate) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(labelName, "labelName"); Ensure.ArgumentNotNull(labelUpdate, "labelUpdate"); return _client.Update(owner, name, labelName, labelUpdate).ToObservable(); }
/// <summary> /// Update a single label /// </summary> /// <param name="labelId">ID of label to update</param> /// <param name="labelUpdate">label update</param> /// <returns>Updated label</returns> public async Task <Label> UpdateLabelAsync(string labelId, LabelUpdate labelUpdate) { return(await _service.PatchLabelsIDAsync(labelId, labelUpdate).ContinueWith(t => t.Result.Label)); }
public void UpdatesCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new IssuesLabelsClient(connection); var labelUpdate = new LabelUpdate("name", "FF0000"); client.Update(1, "labelName", labelUpdate); connection.Received().Post<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels/labelName"), labelUpdate); }
internal void RaiseLabelUpdated() { LabelUpdate?.Invoke(this, EventArgs.Empty); }
public void UpdatesCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservableIssuesLabelsClient(gitHubClient); var labelUpdate = new LabelUpdate("name", "FF0000"); client.Update(1, "labelName", labelUpdate); gitHubClient.Received().Issue.Labels.Update(1, "labelName", labelUpdate); }
/// <summary> /// Updates a label. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#update-a-label">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="name">The name of the label</param> /// <param name="labelUpdate">The data for the label to be updated</param> /// <returns>The updated label</returns>' public IObservable <Label> Update(string owner, string repo, string name, LabelUpdate labelUpdate) { return(_client.Update(owner, repo, name, labelUpdate).ToObservable()); }
public void EnsuresNonNullArguments() { var client = new ObservableIssuesLabelsClient(Substitute.For<IGitHubClient>()); var labelUpdate = new LabelUpdate("name", "FF0000"); Assert.Throws<ArgumentNullException>(() => client.Update(null, "name", "labelName", labelUpdate)); Assert.Throws<ArgumentNullException>(() => client.Update("owner", null, "labelName", labelUpdate)); Assert.Throws<ArgumentNullException>(() => client.Update("owner", "name", null, labelUpdate)); Assert.Throws<ArgumentNullException>(() => client.Update("owner", "name", "labelName", null)); Assert.Throws<ArgumentNullException>(() => client.Update(1, null, labelUpdate)); Assert.Throws<ArgumentNullException>(() => client.Update(1, "labelName", null)); Assert.Throws<ArgumentException>(() => client.Update("", "name", "labelName", labelUpdate)); Assert.Throws<ArgumentException>(() => client.Update("owner", "", "labelName", labelUpdate)); Assert.Throws<ArgumentException>(() => client.Update("owner", "name", "", labelUpdate)); Assert.Throws<ArgumentException>(() => client.Update(1, "", labelUpdate)); }
/// <summary> /// Update a single label /// </summary> /// <param name="labelId">ID of label to update</param> /// <param name="labelUpdate">label update</param> /// <returns>Updated label</returns> public async Task <Label> UpdateLabelAsync(string labelId, LabelUpdate labelUpdate) { var response = await _service.PatchLabelsIDAsync(labelId, labelUpdate).ConfigureAwait(false); return(response.Label); }
/// <summary> /// Update a single label /// </summary> /// <param name="labelId">ID of label to update</param> /// <param name="labelUpdate">label update</param> /// <returns>Updated label</returns> public async Task <Label> UpdateLabelAsync(string labelId, LabelUpdate labelUpdate) { return((await _service.PatchLabelsIDAsync(labelId, labelUpdate)).Label); }
/// <summary> /// Updates a label. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#update-a-label">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="labelName">The name of the label</param> /// <param name="labelUpdate">The data for the label to be updated</param> public IObservable <Label> Update(string owner, string name, string labelName, LabelUpdate labelUpdate) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(labelName, nameof(labelName)); Ensure.ArgumentNotNull(labelUpdate, nameof(labelUpdate)); return(_client.Update(owner, name, labelName, labelUpdate).ToObservable()); }