Allow fully qualified or short references to be used to generate "reference" Uri (#2110)

Co-authored-by: Brian <brian.hart@xylogix.net>
This commit is contained in:
Brendan Forster
2020-02-25 18:24:42 -04:00
committed by GitHub
parent a5b27c315c
commit 65bb8d57d7
5 changed files with 297 additions and 37 deletions
@@ -146,7 +146,12 @@ namespace Octokit.Reactive
/// <param name="name">The name of the repository</param>
/// <param name="subNamespace">The sub-namespace to get references for</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
/// <remarks>
/// The subNamespace parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
public IObservable<Reference> GetAllForSubNamespace(string owner, string name, string subNamespace, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
@@ -154,6 +159,11 @@ namespace Octokit.Reactive
Ensure.ArgumentNotNullOrEmptyString(subNamespace, nameof(subNamespace));
Ensure.ArgumentNotNull(options, nameof(options));
if (subNamespace.StartsWith("refs/"))
{
subNamespace = subNamespace.Replace("refs/", string.Empty);
}
return _connection.GetAndFlattenAllPages<Reference>(ApiUrls.Reference(owner, name, subNamespace), options);
}
@@ -180,12 +190,22 @@ namespace Octokit.Reactive
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="subNamespace">The sub-namespace to get references for</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
/// <remarks>
/// The subNamespace parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
public IObservable<Reference> GetAllForSubNamespace(long repositoryId, string subNamespace, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(subNamespace, nameof(subNamespace));
Ensure.ArgumentNotNull(options, nameof(options));
if (subNamespace.StartsWith("refs/"))
{
subNamespace = subNamespace.Replace("refs/", string.Empty);
}
return _connection.GetAndFlattenAllPages<Reference>(ApiUrls.Reference(repositoryId, subNamespace), options);
}
@@ -298,4 +318,4 @@ namespace Octokit.Reactive
return _reference.Delete(repositoryId, reference).ToObservable();
}
}
}
}
@@ -179,6 +179,13 @@ public class ReferencesClientTests : IDisposable
Assert.NotEmpty(list);
}
[IntegrationTest]
public async Task CanGetListOfReferencesInNamespaceWithRefsIncluded()
{
var list = await _fixture.GetAllForSubNamespace("octokit", "octokit.net", "refs/heads");
Assert.NotEmpty(list);
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfReferencesInNamespaceWithStart()
{
@@ -503,6 +510,42 @@ public class ReferencesClientTests : IDisposable
Assert.Empty(all.Where(r => r.Ref == "heads/develop"));
}
[IntegrationTest]
public async Task CanDeleteAReferenceUsingRefs()
{
var blob = new NewBlob
{
Content = "Hello World!",
Encoding = EncodingType.Utf8
};
var blobResult = await _github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob);
var newTree = new NewTree();
newTree.Tree.Add(new NewTreeItem
{
Mode = FileMode.File,
Type = TreeType.Blob,
Path = "README.md",
Sha = blobResult.Sha
});
var treeResult = await _github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree);
var newCommit = new NewCommit("This is a new commit", treeResult.Sha);
var commitResult = await _github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit);
var newReference = new NewReference("heads/develop", commitResult.Sha);
await _fixture.Create(_context.RepositoryOwner, _context.RepositoryName, newReference);
await _fixture.Delete(_context.RepositoryOwner, _context.RepositoryName, "refs/heads/develop");
var all = await _fixture.GetAll(_context.RepositoryOwner, _context.RepositoryName);
Assert.Empty(all.Where(r => r.Ref == "heads/develop"));
}
[IntegrationTest]
public async Task CanDeleteAReferenceWithRepositoryId()
{
+67 -1
View File
@@ -47,6 +47,17 @@ namespace Octokit.Tests.Clients
connection.Received().Get<Reference>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads/develop"));
}
[Fact]
public async Task RequestsCorrectUrlWithRef()
{
var connection = Substitute.For<IApiConnection>();
var client = new ReferencesClient(connection);
await client.Get("owner", "repo", "refs/heads/develop");
connection.Received().Get<Reference>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads/develop"));
}
[Fact]
public async Task RequestsCorrectUrlWithRepositoryId()
{
@@ -57,6 +68,17 @@ namespace Octokit.Tests.Clients
connection.Received().Get<Reference>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/git/refs/heads/develop"));
}
[Fact]
public async Task RequestsCorrectUrlWithRepositoryIdAndRefs()
{
var connection = Substitute.For<IApiConnection>();
var client = new ReferencesClient(connection);
await client.Get(1, "refs/heads/develop");
connection.Received().Get<Reference>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/git/refs/heads/develop"));
}
}
public class TheGetAllMethod
@@ -150,6 +172,17 @@ namespace Octokit.Tests.Clients
connection.Received().GetAll<Reference>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads"), Args.ApiOptions);
}
[Fact]
public async Task RequestsCorrectUrlWithRef()
{
var connection = Substitute.For<IApiConnection>();
var client = new ReferencesClient(connection);
await client.GetAllForSubNamespace("owner", "repo", "refs/heads");
connection.Received().GetAll<Reference>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads"), Args.ApiOptions);
}
[Fact]
public async Task RequestsCorrectUrlWithRepositoryId()
{
@@ -160,6 +193,17 @@ namespace Octokit.Tests.Clients
connection.Received().GetAll<Reference>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/git/refs/heads"), Args.ApiOptions);
}
[Fact]
public async Task RequestsCorrectUrlWithRepositoryIdAndRefs()
{
var connection = Substitute.For<IApiConnection>();
var client = new ReferencesClient(connection);
await client.GetAllForSubNamespace(1, "refs/heads");
connection.Received().GetAll<Reference>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/git/refs/heads"), Args.ApiOptions);
}
}
public class TheCreateMethod
@@ -282,6 +326,17 @@ namespace Octokit.Tests.Clients
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads/develop"));
}
[Fact]
public async Task RequestsCorrectUrlWithRefs()
{
var connection = Substitute.For<IApiConnection>();
var client = new ReferencesClient(connection);
await client.Delete("owner", "repo", "refs/heads/develop");
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads/develop"));
}
[Fact]
public async Task RequestsCorrectUrlWithRepositoryId()
{
@@ -292,6 +347,17 @@ namespace Octokit.Tests.Clients
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/git/refs/heads/develop"));
}
[Fact]
public async Task RequestsCorrectUrlWithRepositoryIdAndRefs()
{
var connection = Substitute.For<IApiConnection>();
var client = new ReferencesClient(connection);
await client.Delete(1, "refs/heads/develop");
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/git/refs/heads/develop"));
}
}
}
}
}
+72 -17
View File
@@ -20,8 +20,13 @@ namespace Octokit
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <returns></returns>
/// <param name="reference">The reference name</param>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "Method makes a network request")]
Task<Reference> Get(string owner, string name, string reference);
@@ -33,8 +38,13 @@ namespace Octokit
/// http://developer.github.com/v3/git/refs/#get-a-reference
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <returns></returns>
/// <param name="reference">The reference name</param>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "Method makes a network request")]
Task<Reference> Get(long repositoryId, string reference);
@@ -92,7 +102,12 @@ namespace Octokit
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="subNamespace">The sub-namespace to get references for</param>
/// <returns></returns>
/// <remarks>
/// The subNamespace parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
Task<IReadOnlyList<Reference>> GetAllForSubNamespace(string owner, string name, string subNamespace);
/// <summary>
@@ -105,7 +120,12 @@ namespace Octokit
/// <param name="name">The name of the repository</param>
/// <param name="subNamespace">The sub-namespace to get references for</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
/// <remarks>
/// The subNamespace parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
Task<IReadOnlyList<Reference>> GetAllForSubNamespace(string owner, string name, string subNamespace, ApiOptions options);
/// <summary>
@@ -116,7 +136,12 @@ namespace Octokit
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="subNamespace">The sub-namespace to get references for</param>
/// <returns></returns>
/// <remarks>
/// The subNamespace parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
Task<IReadOnlyList<Reference>> GetAllForSubNamespace(long repositoryId, string subNamespace);
/// <summary>
@@ -128,7 +153,12 @@ namespace Octokit
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="subNamespace">The sub-namespace to get references for</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
/// <remarks>
/// The subNamespace parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
Task<IReadOnlyList<Reference>> GetAllForSubNamespace(long repositoryId, string subNamespace, ApiOptions options);
/// <summary>
@@ -140,7 +170,12 @@ namespace Octokit
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="reference">The reference to create</param>
/// <returns></returns>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
Task<Reference> Create(string owner, string name, NewReference reference);
/// <summary>
@@ -162,9 +197,14 @@ namespace Octokit
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <param name="reference">The reference name</param>
/// <param name="referenceUpdate">The updated reference data</param>
/// <returns></returns>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
Task<Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate);
/// <summary>
@@ -174,9 +214,14 @@ namespace Octokit
/// http://developer.github.com/v3/git/refs/#update-a-reference
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <param name="reference">The reference name</param>
/// <param name="referenceUpdate">The updated reference data</param>
/// <returns></returns>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
Task<Reference> Update(long repositoryId, string reference, ReferenceUpdate referenceUpdate);
/// <summary>
@@ -187,8 +232,13 @@ namespace Octokit
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <returns></returns>
/// <param name="reference">The reference name</param>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
Task Delete(string owner, string name, string reference);
/// <summary>
@@ -198,8 +248,13 @@ namespace Octokit
/// http://developer.github.com/v3/git/refs/#delete-a-reference
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <returns></returns>
/// <param name="reference">The reference name</param>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
Task Delete(long repositoryId, string reference);
}
}
+92 -16
View File
@@ -28,14 +28,24 @@ namespace Octokit
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <returns></returns>
/// <param name="reference">The reference name</param>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
public Task<Reference> Get(string owner, string name, string reference)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
if (reference.StartsWith("refs/"))
{
reference = reference.Replace("refs/", string.Empty);
}
return ApiConnection.Get<Reference>(ApiUrls.Reference(owner, name, reference));
}
@@ -46,12 +56,22 @@ namespace Octokit
/// http://developer.github.com/v3/git/refs/#get-a-reference
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <returns></returns>
/// <param name="reference">The reference name</param>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
public Task<Reference> Get(long repositoryId, string reference)
{
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
if (reference.StartsWith("refs/"))
{
reference = reference.Replace("refs/", string.Empty);
}
return ApiConnection.Get<Reference>(ApiUrls.Reference(repositoryId, reference));
}
@@ -142,7 +162,12 @@ namespace Octokit
/// <param name="name">The name of the repository</param>
/// <param name="subNamespace">The sub-namespace to get references for</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
public Task<IReadOnlyList<Reference>> GetAllForSubNamespace(string owner, string name, string subNamespace, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
@@ -150,7 +175,10 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(subNamespace, nameof(subNamespace));
Ensure.ArgumentNotNull(options, nameof(options));
// TODO: Handle 404 when subNamespace cannot be found
if (subNamespace.StartsWith("refs/"))
{
subNamespace = subNamespace.Replace("refs/", string.Empty);
}
return ApiConnection.GetAll<Reference>(ApiUrls.Reference(owner, name, subNamespace), options);
}
@@ -178,13 +206,21 @@ namespace Octokit
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="subNamespace">The sub-namespace to get references for</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
/// <remarks>
/// The subNamespace parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
public Task<IReadOnlyList<Reference>> GetAllForSubNamespace(long repositoryId, string subNamespace, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(subNamespace, nameof(subNamespace));
Ensure.ArgumentNotNull(options, nameof(options));
// TODO: Handle 404 when subNamespace cannot be found
if (subNamespace.StartsWith("refs/"))
{
subNamespace = subNamespace.Replace("refs/", string.Empty);
}
return ApiConnection.GetAll<Reference>(ApiUrls.Reference(repositoryId, subNamespace), options);
}
@@ -232,9 +268,14 @@ namespace Octokit
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <param name="reference">The reference name</param>
/// <param name="referenceUpdate">The updated reference data</param>
/// <returns></returns>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
public Task<Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
@@ -242,6 +283,11 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
Ensure.ArgumentNotNull(referenceUpdate, nameof(referenceUpdate));
if (reference.StartsWith("refs/"))
{
reference = reference.Replace("refs/", string.Empty);
}
return ApiConnection.Patch<Reference>(ApiUrls.Reference(owner, name, reference), referenceUpdate);
}
@@ -252,14 +298,24 @@ namespace Octokit
/// http://developer.github.com/v3/git/refs/#update-a-reference
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <param name="reference">The reference name</param>
/// <param name="referenceUpdate">The updated reference data</param>
/// <returns></returns>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
public Task<Reference> Update(long repositoryId, string reference, ReferenceUpdate referenceUpdate)
{
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
Ensure.ArgumentNotNull(referenceUpdate, nameof(referenceUpdate));
if (reference.StartsWith("refs/"))
{
reference = reference.Replace("refs/", string.Empty);
}
return ApiConnection.Patch<Reference>(ApiUrls.Reference(repositoryId, reference), referenceUpdate);
}
@@ -271,14 +327,24 @@ namespace Octokit
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <returns></returns>
/// <param name="reference">The reference name</param>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
public Task Delete(string owner, string name, string reference)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
if (reference.StartsWith("refs/"))
{
reference = reference.Replace("refs/", string.Empty);
}
return ApiConnection.Delete(ApiUrls.Reference(owner, name, reference));
}
@@ -289,12 +355,22 @@ namespace Octokit
/// http://developer.github.com/v3/git/refs/#delete-a-reference
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param>
/// <returns></returns>
/// <param name="reference">The reference name</param>
/// <remarks>
/// The reference parameter supports either the fully-qualified ref
/// (prefixed with "refs/", e.g. "refs/heads/master" or
/// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g.
/// "heads/master" or "tags/release-1")
/// </remarks>
public Task Delete(long repositoryId, string reference)
{
Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
if (reference.StartsWith("refs/"))
{
reference = reference.Replace("refs/", string.Empty);
}
return ApiConnection.Delete(ApiUrls.Reference(repositoryId, reference));
}
}