How should we handle not having any changes?
leonardochaia opened this issue · 3 comments
Currently the tool just outputs nothing:
dotnet affected generate --verbose --output /tmp/tobuild.proj --to <redacted> --from <redacted>
Finding all csproj at /var/jenkins_home/workspace/<redacted>
Building Dependency Graph
Found 92 projects
Finding changes from <redacted> against <redacted>
Found 24 changed files inside 0 projects.
Files inside these projects have changed:
These projects are affected by those changes:
Generating Traversal SDK Project
Creating file at /tmp/tobuild.proj
Should we exit with > 0?
At least improve presentation messages
Generally a non-zero exit code means an error of some sort. However, that is not necessarily the case here. So I guess add some kind of message and maybe only create the traversal project file when there is something to add to it?
I'm thinking that, when 0 projects are affected by the changes:
- Commands should
exit
with a custom status code generate
should not create an empty file
We may wanna toggle the entire behavior with an argument; perhaps your next step in the pipeline expect the (empty) file to be there
That being said, being able to exit with a custom code would allow you to detect that and not execute your next steps in the pipeline.
i.e
dotnet affected [...]
if [ $? -eq <some custom code> ]; then
echo "##vso[task.setvariable variable=NEEDS_TO_BUILD;]0"
exit 0
fi
You could then use NEEDS_TO_BUILD
in a pipline step
condition
to prevent executing dotnet build/restore/test
if there's no need to and save more build time.
I am too late to the party, so I left a comment on the commit, though is already merged.