owncloud-ci / drone-skip-pipeline

Drone plugin to skip pipelines based on changed files
https://hub.docker.com/r/owncloudci/drone-skip-pipeline
Apache License 2.0
1 stars 1 forks source link

Remove quotes surrounding changed files #37

Closed phil-davis closed 2 years ago

phil-davis commented 2 years ago

The normal git diff output gives a list of changed files:

$ git diff --name-only c8323a8a5b0d438ef651ad427f0b88d5828f7248..134a982e89441825f1219a91517e6bc857e6d988
changelog/unreleased/40155
core/js/sharedialogview.js

But if a file name has special characters then it is surrounded by double-quotes:

$ git diff --name-only 46de3c5cf386ba5c99e3309bad12655dbb74c073..a1bdb4f87c09f4484b3a6be32ea18fbda65db5c7
"tests/acceptance/fixtures/\340\244\270\340\244\277\340\244\256\340\244\270\340\244\277\340\244\256\340\245\207-\340\244\252\340\244\276\340\244\250\340\245\200.png"

Examples are from ownclud/core

I noticed this because the acceptance tests were all skipped in https://github.com/owncloud/core/pull/40200 even though a file in tests/acceptance had changed.

The regex comparison is looking for files with paths starting with tests/acceptance but this starts with "tests/acceptance

This PR adds code to trim off the double-quotes at the end of any entries in the list of changed files. That will allow them to match the typical regexes that are used, that start with some "ordinary-named" path.

Note: if someone really wants to exactly match some path+file that has strange characters in the name, then they will still have to do some hard work to find the string that git diff produces and make sure that their regex will match it - but that is a different challenge.

wkloucek commented 2 years ago

The normal git diff output gives a list of changed files:

This project doesn't use any "normal git". It's 100% based on github.com/go-git/go-git/v5

But what bugs me the most is the output of these pipelines (eg. https://drone.owncloud.com/owncloud/core/36297/36/3):

latest: Pulling from owncloudci/drone-skip-pipeline
Digest: sha256:7eb8fc9c9f92bc1457bd640a20cc14e3fe0f54178b7a3dd8b1f3e2cb07f49d83
Status: Image is up to date for owncloudci/drone-skip-pipeline:latest
DRONE_COMMIT_BEFORE:  46de3c5cf386ba5c99e3309bad12655dbb74c073
DRONE_COMMIT_AFTER:  a1bdb4f87c09f4484b3a6be32ea18fbda65db5c7
### changed files ###

There are no files supposed to be changed... But if one diffs the two commits referenced, one will clearly see the changes.

phil-davis commented 2 years ago

There are no files supposed to be changed... But if one diffs the two commits referenced, one will clearly see the changes.

Hmmm - that's trickier. If github.com/go-git/go-git/v5 does not find changed files with "special names" then it's going to be difficult.

Maybe I should look upstream to see if it is easily fixed...

wkloucek commented 2 years ago

I found it https://github.com/go-git/go-git/blob/bc1f419cebcf7505db31149fa459e9e3f8260e00/plumbing/object/patch.go#L306-L309

wkloucek commented 2 years ago

fix in https://github.com/owncloud-ci/drone-skip-pipeline/pull/38