GitHub API Filtering commits based on path

I’m trying to get the commits within a certain time range that have files that have been changed in a certain path, but what I’m seeing is a bit perplexing.

The file [repo root]/some/path/to/edited/file.txt has been changed in a given commit.

When I use the API and pass the path as some/path/to/edited, I don’t get back any commits. When I instead pass some/path/to, I get back the expected commit that includes the change to file.txt.

The full curl command I’m using that’s getting results is:

curl -X GET -H “Content-Type: application/vnd.github.v3+json” -H “Authorization: token [some token here]” “https://github.internal.myorg.com/api/v3/repos/myorg/myrepo/commits?since=2021-11-10T17:48:22Z&until=2021-11-10T19:45:43Z&path=some%2Fpath%2Fto&per_page=100&page=0

The only thing I’ve changed that breaks the results is add %2Fedited to the end of the path.

Are there some settings somewhere that could make specific directories searchable with that API endpoint? I just really can’t think of anything else that could be causing this problem.

Thank you!

Hey there @gstilwellDO :wave:

Your question is curious, but since you’re referencing an instance of GitHub Enterprise, it would be best to discuss specific question with our Enterprise Support Team:

With a private discussion, you’ll be able to include details that aren’t safely shared with our larger community, here. Additionally, the version of GHE you’re running, will change certain behaviors that similarly aren’t as relevant to other users who might see this.

But for our documentation, our commits endpoint:

…doesn’t seem to list an edited parameter.

Though keep in mind I’m referencing 3.3, and I’m not sure if this is the version your Org is running, nor do I want to expose which version you’re running.

So again, Enterprise Support will likely be your best path to get the most accurate information, but for edited, I’m not sure that exists. Do you have a link to docs that reference that param?

Edit: or do I misunderstand your path? Is there simply a new edited path you’re referencing, and not using a literal edited? In that case, I’m wondering about branches. Did the edit make its way to the default branch?

Thank you for the reply! I’ll give enterprise support a shot.

To answer your questions, though, edited is part of the example path I was giving. It isn’t a parameter I was attempting to use.

The edit has made its way to the default branch, so it shouldn’t be getting excluded because it’s hiding on a branch. Good thoughts, though!

Again, your time is much appreciated. I’ll see what support can do :slight_smile:

1 Like

Thanks for clarifying! Off-hand, I can’t think of anything that would make an otherwise functional call return nothing, or error out, if that edited commit made its way to the default branch.

It’s likely you’ll need to collect logs from your Enterprise instance, to see the difference in responses.

Good luck!