octokit / octokit.js

The all-batteries-included GitHub SDK for Browsers, Node.js, and Deno.
MIT License
6.86k stars 1k forks source link

[FEAT]: allow to search text_matches with fragment length #2572

Closed md-robiul-hassan-kr closed 8 months ago

md-robiul-hassan-kr commented 8 months ago

Allow full code block search

(async () => {
  const response = await octokit.request('GET /search/code?q={q}&type={type}', {
    q: `jquery`,
    type: 'Code',
    headers: {
      'Accept': 'application/vnd.github.text-match+json'
    },
    per_page: 100
  }).then(res => res.data.items.map(r => r.text_matches));
  console.log('----------: ', response);
})();

in the return

 {
      object_url: '',
      object_type: 'FileContent',
      property: 'content',
      fragment: ' ',
      matches: [Array]
    }

allow to return fragment code for full block of code or allow a fixed length of code.

example if I have a <div class: 'my-header' > 3 line of code

block , and I want to be able to return the full code for that block when I search "my-header".

if there is already existing support already please share.

SDK Version

"octokit": "^2.0.14",

API Version

"octokit": "^2.0.14",

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 8 months ago

šŸ‘‹ Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! šŸš€

gr2m commented 8 months ago

Here is the documentation for the REST API in question: https://docs.github.com/en/free-pro-team@latest/rest/search/search?apiVersion=2022-11-28#search-code

There is no addiontal parameter that is not exposed in Octokit. If you would like to ask for a change of an existing REST API endpoint, the best place to ask is the community form at https://github.com/orgs/community/discussions/categories/api-and-webhooks