Get commits for a repository with date filter using gh api - github-api

I am trying to fetch the commits in a given time range using gh api.
In following command, what options I can use to get required commit details?
gh api repos/owner/repoName/commits .....

Since gh api command is only a way to wrap the GitHub API repo/commits call, all you need is add parameters to your GET query.
Minify your JSON date filer parameters:
{
"since": {
"date": "yyyy-mm-dd",
"time": "hh:mm:ss"
},
"until": {
"date": "yyyy-mm-dd",
"time": "hh:mm:ss"
}
}
And:
gh api repos/owner/repoName/commits -f '{"since":{"date":"yyyy-mm-dd","time":"hh:mm:ss"},"until":{"date":"yyyy-mm-dd","time":"hh:mm:ss"}}'

Related

Associated PXSelect/PXSelectReadOnly Returns Nothing on Sales Order Through OpenAPI

I've introduced a new DAC and a new field on the Sales Order associated to the new DAC key. When trying to retrieve the information through OpenAPI it comes back empty. I'd like to know why and how I can adjust my code to return the information. I've tried both PXSelect and PXSelectReadOnly
Declaring Statement on SOOrderEntry(extension):
public PXSelect<IOCSCompanyBrand, Where<IOCSCompanyBrand.companyBrandNbr,
Equal<Current<SOOrderExt.usrCompanyBrand>>>> CompanyBranding;
When I hit the URL: http://localhost/Acumatica21/entity/AcumaticaExtended21R1/20.200.001/SalesOrder?$select=OrderNbr,CompanyBranding,OrderType,CompanyBrand&$expand=CompanyBranding&$filter=OrderNbr%20eq%20'SO-030003'
This is the data that is returned:
[
{
"id": "f827cb43-9b8a-ec11-a481-747827c044c8",
"rowNumber": 1,
"note": {
"value": ""
},
"CompanyBrand": {
"value": "IO"
},
"CompanyBranding": null,
"OrderNbr": {
"value": "SO-030003"
},
"OrderType": {
"value": "SO"
},
"custom": {}
}
]
Acumatica Version: 21.205.0063
Here's the definition for SalesOrder in the endpoint (which was populated via the GUI)
I ended up opening a Acumatica Developer case and here is their response.
Hi Kyle,
Thanks for your time yesterday.
Endpoint mapping is valid but the fields in the view isn't fetch due the limitation of the filter parameter in the request. Filter parameter optimizes the data that are being fetch. In the case, the customer view isn't fetched. To workaround the limitation, instead of using filter, you can try something like below,
http://localhost/Acumatica/entity/AcumaticaExtended21R1/20.200.001/SalesOrder/SO/SO-030007?$expand=CompanyBranding
You can fetch the record and use expand to get the detail level fields. This way you can avoid the limitation of the filter.
Please check and let me know if you have any questions.
Regards,
Vignesh

Azure DevOps API TFS: How to get a file history if it was renamed and/or branched?

Is this possible somehow to get a file history (all related changesets) with API request if the file was branched or/and renamed?
For example, if I need to find a history of the object in Azure DevOps UI I can search this object in the project, in a certain path like this:
And if I need to find the first appearance of the object in a repository, I can get it by expanding a "branch and rename" history
There is a need to get this information via API requests.
I had tried to find some API requests which can do it, but found only the requests which can return only the changesets which are on the first picture, where the object has the same name and is located under the path defined in the search parameter - there is no information about renaming/branching operations.
GET https://dev.azure.com/Contoso/_apis/tfvc/changesets?api-version=6.0&searchCriteria.itemPath=$/Contoso/Trunk/Main/Metadata/Application_Ext_Contoso/Application_Ext_Contoso/AxSecurityPrivilege/Entity.xml
returns only 3 changesets - 2162, 2161, 391
POST https://dev.azure.com/Contoso/Contoso/_api/_versioncontrol/history?api-version=6.0
With the body request
{
"repositoryId":"",
"searchCriteria":"{\"itemPaths\":[\"$/Contoso/Trunk/Main/Metadata/Application_Ext_Contoso/Application_Ext_Contoso/AxSecurityPrivilege/Entity.xml\" ], \"followRenames\" : true ,\"top\":50}",
"includeSourceRename" : true
}
Also returns only 3 changesets, it only finds a specific item path, I tried to experiment with includeSourceRename and followRenames , but they do not work as I expected.
POST https://almsearch.dev.azure.com/Contoso/Contoso/_apis/search/codesearchresults?api-version=6.0-preview.1
with the body
{
"searchText": "Entity.xml",
"$skip": 0,
"$top": 25,
"filters": {
"Project": [
"Contoso"
],
"Repository": [
"$/Contoso"
],
"Path": [
"$/Contoso/"
]
},
"$orderBy": [
{
"field": "filename",
"sortOrder": "ASC"
}
],
"includeFacets": true
}
Also returns information only about 3 changesets.
Are there some approaches to get this information from the API request?

Azure DevOps RestAPI to change the User Access Level

I'm working on an automation to update the access level of the user from Basic to stakeholder using an Azure DevOps RestAPI.
I have tried following Rest API as per documentation but getting bad request.
https://vsaex.dev.azure.com/xxxxxxxx/_apis/userentitlements/d42xxxx-xxxxxxxx-xxxxxx-xxxxxxxxxx?api-version=6.0-preview.3
Input Json:
{
"from": "",
"op": "replace",
"path": "/accessLevel",
"value": {
"accountLicenseType": "stakeholder",
"licensingSource": "account"
}
}
As far as I can see, the body of the request you send is a JSON object, but the example in the documentation specifies the body as JSON array. Not sure if it's a strict requirement, but try wrapping the body into [].
Please use the following body which should work as expected.
[
{
"from":"",
"op":"replace",
"path":"/accessLevel",
"value":{
"accountLicenseType":"stakeholder",
"licensingSource":"account"
}
}
]
See: Examples for more details.

what will be the request body for create repository in azure devops?

I want to create a git repository in azure devops using rest api.
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories?api-version=5.1
Request body should be like this.
{
"name": "repo_name",
"teamProjectReference": {
"id": "azure_project_id"
}
}
Also, you can go through this link to know better https://learn.microsoft.com/en-us/rest/api/azure/devops/git/repositories/create?view=azure-devops-rest-5.1
You only need to pass the repository name and the project id within the body:
{
"name": "AnotherRepository",
"project": {
"id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c"
}
}
See also: Create a repository

How to retrieve Work Item linked to specific commit - Azure Devops REST API

I need to be able to retrieve the linked work item of any given specific commit. I'm currently using the following api call
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}?api-version=5.0
with the following response
{
"parents": [],
"treeId": "7fa1a3523ffef51c525ea476bffff7d648b8cb3d",
"push": {
"pushedBy": {
"id": "8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d",
"displayName": "Chuck Reinhart",
"uniqueName": "fabrikamfiber3#hotmail.com",
"url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d",
"imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d"
},
"pushId": 1,
"date": "2014-01-29T23:33:15.2434002Z"
},
"commitId": "be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4",
"author": {
"name": "Chuck Reinhart",
"email": "fabrikamfiber3#hotmail.com",
"date": "2014-01-29T23:32:09Z"
},
"committer": {
"name": "Chuck Reinhart",
"email": "fabrikamfiber3#hotmail.com",
"date": "2014-01-29T23:32:09Z"
},
"comment": "First cut\n",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4",
"remoteUrl": "https://dev.azure.com/fabrikam/_git/Fabrikam-Fiber-Git/commit/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4",
"_links": {
"self": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4"
},
"repository": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249"
},
"changes": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4/changes"
},
"web": {
"href": "https://dev.azure.com/fabrikam/_git/Fabrikam-Fiber-Git/commit/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4"
},
"tree": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/7fa1a3523ffef51c525ea476bffff7d648b8cb3d"
}
}
}
from https://learn.microsoft.com/en-us/rest/api/azure/devops/git/commits/get?view=azure-devops-rest-5.0 and am missing a way to see what work item its linked to or if it is linked at all. Does anyone know of a way to get this information? Thanks
You could use the Get Commits API, docs here. The base request looks like:
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits?api-version=5.0
You could then add the following parameters:
fromCommitId - string - If provided, a lower bound for filtering commits alphabetically
toCommitId - string - If provided, an upper bound for filtering commits alphabetically
includeWorkItems - boolean - Whether to include linked work items
So that your final query would look something like, with your toCommitId and fromCommitId parameters being your commit id that you are after (the documentation doesn't specificy whether these are inclusive or exclusive so your might have to tweak this slightly):
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits?includeWorkItems=true&.toCommitId={searchCriteria.toCommitId}&fromCommitId={searchCriteria.fromCommitId}&api-version=5.0
The result should contain a workItems property inside each commit object of the response as per this documentation.
Note:
Parameters that use the searchCriteria prefix in their name can be specified without it as query parameters, e.g. searchCriteria.$top -> $top
There is also:
ids - array - If provided, specifies the exact commit ids of the commits to fetch. May not be combined with other parameters.
Which could allow you to forgo passing in the to and from commit ids but the docs state that it May not be combined with other parameters - even though the example request does combine it with other parameters. I haven't tried this myself so please do comment when you find out whether you go with from-to id or just ids.
OPs action
The OP ended up using the following request as they didn't mind all commits being returned:
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits?includeWorkItems=true&api-version=5.0

Resources