touchifyapp / vsts-changed-files

Azure DevOps pipeline task to get changed files since last succeeded build
MIT License
11 stars 5 forks source link

[Solution] bad objects and hasChanged always true #44

Open GedasFX opened 1 year ago

GedasFX commented 1 year ago

Not an issue, but rather a PSA to help others figure out the issues. Spent all day on this problem...

Starting from September 2022, Azure DevOps fetches only 1 commit by default in new pipelines. This means that by default, all commits would be squashed into 1, meaning all files in the repository would be marked as 'changed'.

This also means that if you merge with non-squash commits, due to the way the plugin performs the checking, it will get commit ids that the pipeline would have no idea about, leading to bad object errors.

Fix for this is quite simple:

Example:

jobs:
  - job: Check
    displayName: Verify files changed
    pool:
      vmImage: ubuntu-latest
    steps:
      - checkout: self
        fetchDepth: 2 # Set to 0 when merging with non Squash Commits
      - task: ChangedFiles@1
        name: CheckChanges
        displayName: Check Changed Files
        inputs:
          rules: ...
utk231 commented 1 month ago

@anthonyburdi Not working for me too.

This plugin always considers the whole repo files as changed object, Thereby not following the rule filter as that rule filter file (/azure-pipelines.yaml in this case)will always be part of the considered changes object even though there is no change on file.

Can this be fixed please, plugin seems to be of no use without this.

`2024-07-26T11:26:46.5149568Z [command]/usr/bin/git log -m -1 --name-only --pretty=format: 18145a3c9955a511b65e6e561b6fa798fdd 2024-07-26T11:26:46.5230716Z nonprod-main-account/azure-pipelines.yaml

2024-07-26T11:26:46.5234252Z > Executing: git log -m -1 --name-only --pretty=format: 94091bbccbd5c642c4c051a0be0ec458956d

2024-07-26T11:26:46.5247261Z [command]/usr/bin/git log -m -1 --name-only --pretty=format: 940915c642c4c051a0be0ec458956d 2024-07-26T11:26:46.5321292Z .gitignore 2024-07-26T11:26:46.5322236Z .pre-commit-config.yaml 2024-07-26T11:26:46.5322631Z .tflint.hcl 2024-07-26T11:26:46.5322856Z README.md 2024-07-26T11:26:46.5323234Z azure-pipelines.yml ... .... .... ... All Files of repository

2024-07-26T11:26:46.5451846Z > Executing: git log -m -1 --name-only --pretty=format: 3e78cabea87698260de05b3e517513c1b5ee 2024-07-26T11:26:46.5458943Z [command]/usr/bin/git log -m -1 --name-only --pretty=format: 3e78fbea87698260de05b3e517513c1b5ee 2024-07-26T11:26:46.5459435Z fatal: bad object 3e7848aea87698260de05b3e517513c1b5ee`