Github multi-dimensional query - github

I am trying to query the Github RestAPI v. X-GitHub-Api-Version to find line changes (addition, deletions), user, date, repository_name for any repositories in an organization that have files of a particular file extension. Not seeing a clear path forward with this, do I need to file all files using {{baseUrl}}/search/code?q=org:{{org}}+extension:tf, then take those outputs iterating over and querying commits for a file and then extract the details from the commit details?

Related

Is it possible to fetch commit changes (diff only) via api?

I am trying to pull commit changes via api and all i get is the path to the file itself, as in the whole file.
What I want to achieve is to see the changes (diff only) for a single file per commit.
E.g:
If i query the same using Github i get the diff like so:
"## -1 +0,0 ##\n- console.log(\"Blasting!\")"
Is there a similar solution in Azure-devops?
Thanks!
What I want to achieve is to see the changes (diff only) for a single file per commit.
There is no existing Rest API to meet your needs. But you could refer to the following steps to get the content of the git diff.
Step1: You could use the Rest API to get the commit id.
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits?api-version=5.0
Step2: You could use the Rest API to get the commit by commit id.
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}?api-version=5.0
In the Rest API Result, you need to record the value of parentsid.
Step3: You could use the Rest API to Get the file path.
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}/changes?api-version=6.0
Step4: You could use the following API to get the diff content.
Post https://dev.azure.com/Organization/Project /_api/_versioncontrol/fileDiff?__v=5&diffParameters={value}&repositoryId={repositoryid}
The {value} is Json type.
Here is an example:
{"originalPath":"filepath","originalVersion":"Parentsid","modifiedPath":"filepath","modifiedVersion":"commitid","partialDiff":true,"includeCharDiffs":true}
You could add the value to the API URL.
Then run the API and the result will contains the git diff content. (2 means remove, 1 means add)
Here is a result sample:
Here is the ticket, you could refer to it.

How to paginate affected files in a commit using GitHub API?

When getting the files affected by a commit, I noticed that there is a limit in the files array, which lists only the first 301 files.
For instance, the following commit has more than 6 thousand affected files, but only the first 301 are listed in the files json array:
https://api.github.com/repos/aleberringer/loja350/commits/e9c301b1e5a2cfed9bf05e9f9429ae81ad0d1ebd
How can I get all the affected files of this commit? I tried to paginate using &per_page and &page parameters, but it didn't work out.

Is there a way to download all release data of a github repository?

This picture shows few releases from a project. To see more, one has to press "Next" button.
Is it possible to get data (commit hash tag, date) about all releases preferably in a excel, csv, json file format or at least in a single web page.
The list releases API endpoint will provide data about each release in a repository in JSON format:
GET /repos/:owner/:repo/releases
The target_commitish field returned in the response is the nearest thing to a commit hash that is returned by this API, but you can then use the the Git Data API to return the commit SHA:
GET /repos/:owner/:repo/git/tags/:sha
Where :sha can be the string returned in target_commitish. The result of this request will give you the matching commit SHA in the sha field.

Github API: Check if a branch or repository contains a commit

Can I use the Github API to check if a certain repository contains a certain commit?
At first glance, it seems that the get a single commit API call should work, returning 404 if there is no such commit in the repository. But that is not true: It seems that this call will run successful on commits that are present in forked repositories (possibly due to a pull request). (This effect can also be observed in the regular web interface; this particular commit has not been pulled into that repository yet.)
Api GitHub search
For searching other repositories one can use the api, which finds commits via various criteria. (This method returns up to 100 results per page.):
https://developer.github.com/v3/search/#search-commits
Only the default branch is considered, mostly master
Api usage
GET /search/commits
q can be any kind of search term combination: https://help.github.com/articles/searching-commits/
Example parameters for q
hash:124a9a0ee1d8f1e15e833aff432fbb3b02632105
Matches commits with the hash 124a9a0ee1d8f1e15e833aff432fbb3b02632105.
parent:124a9a0ee1d8f1e15e833aff432fbb3b02632105
Matches children of 124a9a0ee1d8f1e15e833aff432fbb3b02632105.
further parameters, like sorting, ordering can be found in the documentation above.
Usage example per hash:
example call https://api.github.com/search/commits?q=<searchterm>+<searchterm2>
specific call: https://api.github.com/search/commits?q=repo:adejoux/kitchen-wpar+hash:0a3a228e5b250daf06f933b35b3f0eafc715be4f
You need to add an special header, because the api is available for developers to preview
header to add: application/vnd.github.cloak-preview

update merge path in word doc

I have 2000 documents which were created by an incorrectly configured application which now uses an invalid merge data path.
e.g. c:\APPNAME\WP\MERGE.TXT
The files now live in H:\MERGE.TXT so all users can access them.
Is there a way to update this path without opening each file in MS Word and reselecting the data source?
Looking forward to your replies.