has-changed-path
has-changed-path copied to clipboard
Does this handle pushing multiple commits at once? If so, how?
Hi,
Thank you for this awesome project.
Does this support pushing multiple commits at once? This code suggest it does not:
const exitCode = await exec.exec('git', [
'diff',
'--quiet',
'HEAD~1',
'HEAD',
'--',
...paths,
], {
ignoreReturnCode: true,
silent: false,
cwd: getCWD()
})
Any plans to add support for this feature?
(I guess the next question would be: how to know which git ref to use, i.e. when was the last push to that branch?)
The approach I can think of for this would be to use:
on:
pull_request:
types:
- closed
and then run the job conditionally on if: github.event.pull_request.merged == true
which gives you access to github.event.pull_request.commits
which would be great if we could then do:
- uses: marceloprado/has-changed-path@v1
id: changed-service
with:
commit_count: github.event.pull_request.commits
paths: thepath
and the code above would be updated to:
const exitCode = await exec.exec('git', [
'diff',
'--quiet',
'HEAD~${commit_count}',
'HEAD',
'--',
...paths,
], {
ignoreReturnCode: true,
silent: false,
cwd: getCWD()
})
and default the value to 1.
I decided to just roll my own check command instead which looks like this:
- name: Check for Changes
id: changes
run: |
echo ::set-output name=HAS_CHANGES::$(git diff --quiet HEAD~${{ github.event.pull_request.commits }} HEAD -- path/here || echo $?)
then later just do
if: steps.changes.outputs.HAS_CHANGES == '1'