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

fix always skipping of binary file changes and submodule refs updates #38

Closed wkloucek closed 2 years ago

wkloucek commented 2 years ago

Before this PR, changed binary files and submodule ref updates wouldn't be accounted as changed (even they did change).

Now they are also counted as change and therefore can be used for skipping / not skipping a pipeline.

Example before this PR on the owncloud/core repository:

DRONE_COMMIT_BEFORE:  46de3c5cf386ba5c99e3309bad12655dbb74c073
DRONE_COMMIT_AFTER:  a1bdb4f87c09f4484b3a6be32ea18fbda65db5c7
### changed files ###

While git diff --name-only 46de3c5cf386ba5c99e3309bad12655dbb74c073...a1bdb4f87c09f4484b3a6be32ea18fbda65db5c7 returns:

"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"

Same example after this PR:

DRONE_COMMIT_BEFORE:  46de3c5cf386ba5c99e3309bad12655dbb74c073
DRONE_COMMIT_AFTER:  a1bdb4f87c09f4484b3a6be32ea18fbda65db5c7
### changed files ###
 tests/acceptance/fixtures/सिमसिमे-पानी.png | 0 
### check if changed files are on allowed skip list ###
 - 'tests/acceptance/fixtures/सिमसिमे-पानी.png' is not allowed to be skipped
### check if disallowed file was changed ###
 - no file disallowed to be skipped was changed

Reported in https://github.com/owncloud-ci/drone-skip-pipeline/pull/37

wkloucek commented 2 years ago

Looks OK. Is there a way to contribute this sort of change upstream? Or is it going to break lots of other uses of getFileStatsFromFilePatches?

I'll look into it. Actually it's more about the diff.Stats() function I removed in this PR. getFileStatsFromFilePatches is a private function that nobody external can use.

I don't think that the behaviour of diff.Stats() can be altered but one could introduce a diff.AllStats()