Git Product home page Git Product logo

Comments (8)

mmitrik avatar mmitrik commented on August 20, 2024

It's not obvious from the docs, but you need to use the PR Iterations API. Use this to list the iterations in the PR, then you want to get the number of the latest iteration. Then, you can use PR Iteration Changes to get the list of changes for an iteration, or between two iterations. If you want all changes, use the latest iteration and set the compareTo=0.

Once you have the list of changes, you need to use the Items API to get the actual contents.

Hopefully that helps until we can get some better samples posted.

cc @steved0x

from vsts-rest-api-specs.

ankitbko avatar ankitbko commented on August 20, 2024

@mmitrik Thanks. I can get list of files changed in the PR using iteration changes. But I am still not able to get the diff between files. The Items api just returns be the file for a given commit. Is there a way I can see what changed in a file (lines added/removed/modified)?

from vsts-rest-api-specs.

ankitbko avatar ankitbko commented on August 20, 2024

So I was working on trying to create an extension for vscode that integrates with AZDO and wanted to get the diff of the files before I landed on this issue. Don't even remember when I raised it ๐Ÿ˜ธ. Well anyways, is there an update for this? @mmitrik You would have moved on to other roles so can you recommend someone I can connect with directly?

cc: @tedchamb since you are the top contributor.

from vsts-rest-api-specs.

mmitrik avatar mmitrik commented on August 20, 2024

Not positive of the best person for this. @aaronhallberg might be able to advise.

from vsts-rest-api-specs.

tedchamb avatar tedchamb commented on August 20, 2024

@goflores, who would be the best person to help with this REST API question?

from vsts-rest-api-specs.

alexanderkovshov avatar alexanderkovshov commented on August 20, 2024

@ankitbko Try to swap target and base versions, that will do the trick. But it won't show you the diff, only path of changed and change type, you can check samples here

Use this to get diff:
Step1: Use the Rest API to get commit id from PR.

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/diffs/commits?api-version=6.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}?changeCount={changeCount}&api-version=5.0
In the Rest API Result, you need to record the value of โ€œparentsidโ€, โ€œpathโ€.

Step3: 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.

from vsts-rest-api-specs.

ankitbko avatar ankitbko commented on August 20, 2024

Thank you. I didnt see fileDiff api in the documentation though.

from vsts-rest-api-specs.

AshwaniT avatar AshwaniT commented on August 20, 2024

_api/_versioncontrol/fileDif is giving 404 for my instance.

from vsts-rest-api-specs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.