pb33f / openapi-changes

The world's sexiest OpenAPI breaking changes detector. Discover what changed between two OpenAPI specs, or a single spec over time. Supports OpenAPI 3.1, 3.0 and Swagger
https://pb33f.io/openapi-changes/
Other
180 stars 16 forks source link

Fix reading with limit and global-revisions #164

Open felixjung opened 1 week ago

felixjung commented 1 week ago

I think I introduced a bug with #158. This should address it.

When processing the earliest commit of the commit history, no file content outside the history is present. This means that no changes can be calculated for the earliest commit.

This issue was likely always present but surfaced by the introduction of the --global-revisions flag. Previously, the issue would only appear when reaching the commit that introduced a file or the end of the repository's history.

To address the problem, we now read the file's content at the previous commit in the repo. The code fails gracefully, if git returns an error when attempting to read the file.

felixjung commented 1 week ago

This works for me locally, but it somehow fails in GitHub actions. Going to debug before asking to merge this.

Error: unable to read git repository './' (are you sure it's a git repo?): exit status 128
daveshanley commented 1 week ago

This works for me locally, but it somehow fails in GitHub actions. Going to debug before asking to merge this.

Error: unable to read git repository './' (are you sure it's a git repo?): exit status 128

I have no idea what is going on here. Could be a depth cloning issue.

I had to add fetch-depth to vacuum the other day.

    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 50
          fetch-tags: true
          show-progress: true
felixjung commented 6 days ago

It was indeed the fetch depth. Pretty annoying. I still ended up adding some code that I think makes the parsing of positional args a bit more robust. I see that code is duplicated across the different commands. Should I extract into a function and apply it everywhere?

daveshanley commented 3 days ago

It was indeed the fetch depth. Pretty annoying. I still ended up adding some code that I think makes the parsing of positional args a bit more robust. I see that code is duplicated across the different commands. Should I extract into a function and apply it everywhere?

If you have the time? Always appreciated.