Open marc-wilson opened 11 months ago
This issue has had no activity in 90 days. Please comment if it is not actually stale
not stale
This issue has had no activity in 90 days. Please comment if it is not actually stale
FileDiff function gives absolutely non relatable output, I have tried all possible ways to find a solution. Nothing works. Any possible solutions please need some pointers. Thank you.
Indeed FileDiff
is not useful and I cannot find any guidance on getChanges
. While I was able to replicate the results from the "hacks" posted in the initial issue, it requires using an undocumented API so there is no way to clearly define/modify the API call e.g. to retrieve batches / diffs for multiple files etc. The work-around is unfortunately extremely inefficient for large sample sizes and not transparent to me.
The ItemContent
documented in the Azure DevOps API documentation reads like it would indeed provide a diff. It would be very useful if this could be retrieved directly over the API. Kindly let me know if anyone finds a solution. Cheers!
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/diffs/get?view=azure-devops-rest-7.0&tabs=HTTP#gitchange this restpi api endpoint still doesn't return newContent in GitChange object
The rest API is still not populating the newContent, do we have a fix date for this yet?
Hi, I was able to find a solution for this, a workaround. There is no way Azure will provide a raw diff text, however, my case was I need to run some checks during a pull request, a CI/CD on a cloud machine (agent).
So I wrote a shell script to run on an agent to get the diff text by:
The full command is like this:
rm -rf diff_logic && mkdir diff_logic && cd diff_logic && git clone ${process.env.CURRENT_REPO_ACCESS_GIT_URL} && cd $(basename ${process.env.CURRENT_REPO_ACCESS_GIT_URL} .git) && git checkout ${targetBranch} && git checkout ${sourceBranch} && git diff ${targetBranch}..${sourceBranch} > diff.txt && mv diff.txt ../..
CURRENT_REPO_ACCESS_GIT_URL = The current project repository access git URL, usually it contains read/write access token, something like this: https://${PAT}@dev.azure.com/organization/project/_git/repo targetBranch = PRDetailsJSON.targetRefName.replace("refs/heads/", ""); sourceBranch = PRDetailsJSON.sourceRefName.replace("refs/heads/", "");
Hi, I was able to find a solution for this, a workaround. There is no way Azure will provide a raw diff text
Why? GitHub Api does it. It looks like your script ultimately downloads a repo and compares two branches manually. There's no reason why the Azure Api can't do this. A few endpoint suggest that it's possible but just doesn't seem to work.
Hi, I was able to find a solution for this, a workaround. There is no way Azure will provide a raw diff text
Why? GitHub Api does it. It looks like your script ultimately downloads a repo and compares two branches manually. There's no reason why the Azure Api can't do this. A few endpoint suggest that it's possible but just doesn't seem to work.
@marc-wilson Yeah I know Github does that, also BitBucket API as well, my case is different, I have a SaaS that should work with git services, everything in place but Azure DevOps, I have this workaround for it only. The others are just fine
Environment
Node version: 18.13 Npm version: 8.19.3 OS and version: azure-devops-node-api version: ^12.1.0
Issue Description
I am trying to get the raw diff text of a given commit. If it were GitHub, you would do this by sending a GET request to commits/sha with the header
application/vnd.github.diff
. Azure DevOps doesn't seem to have a similar concept.The closest thing I can find are the below methods:
getFileDiffs
gives some relative information with line counts, but not enough info to come up with an actual diff.getChanges
returnsGitCommitDiffs
which is ultimately a wrapper aroundGitChange[]
. In the documentation, it states thatGitChange
has some interesting properties that appear to do what I need. But, they are never defined. Is there some header or different method I need to call in order to get a git diff given a commit and/or file path?GitChange https://learn.microsoft.com/en-us/rest/api/azure/devops/git/diffs/get?view=azure-devops-rest-7.2&tabs=HTTP#gitchange
newContent
ItemContent
Content of the item after the change.
Expected behaviour
There should be a way to obtain raw diff text from the api. I am trying to create automated release notes but I need the raw diff text in order to do so.
Actual behaviour
There are methods that lead you to believe you can come up with enough information to figure out exact differences and compile the diff text on your own, but they all ultimately lead to a dead end.
There are few hacks/workaround posted out there but none seem to work: