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();
}
}
}
}