Skip to content

Commit

Permalink
Add support for code searches without a search term (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsplaisted authored and shiftkey committed Jun 3, 2016
1 parent 85a87da commit f05f6dc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Octokit.Tests.Integration/Clients/SearchClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ public async Task SearchForFileNameInCode()
Assert.NotEmpty(repos.Items);
}

[IntegrationTest]
public async Task SearchForFileNameInCodeWithoutTerm()
{
var request = new SearchCodeRequest()
{
FileName = "readme.md",
Repos = new RepositoryCollection { "octokit/octokit.net" }
};

var repos = await _gitHubClient.Search.SearchCode(request);

Assert.NotEmpty(repos.Items);
}

[IntegrationTest]
public async Task SearchForWordInCode()
{
Expand Down
9 changes: 8 additions & 1 deletion Octokit/Models/Request/BaseSearchRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ private string TermAndQualifiers
get
{
var mergedParameters = string.Join("+", MergedQualifiers());
return Term + (mergedParameters.IsNotBlank() ? "+" + mergedParameters : "");
if (string.IsNullOrEmpty(Term))
{
return mergedParameters;
}
else
{
return Term + (mergedParameters.IsNotBlank() ? "+" + mergedParameters : "");
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions Octokit/Models/Request/SearchCodeRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ namespace Octokit
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class SearchCodeRequest : BaseSearchRequest
{
/// <summary>
/// Initializes a new instance of the <see cref="SearchCodeRequest"/> class.
/// </summary>
public SearchCodeRequest() : base()
{
Repos = new RepositoryCollection();
}

/// <summary>
/// Initializes a new instance of the <see cref="SearchCodeRequest"/> class.
/// </summary>
Expand Down

0 comments on commit f05f6dc

Please sign in to comment.