ibvhefe / SelectiveCheckout

2 stars 0 forks source link

Sparse checkout based on commit and not based source branch #8

Open Khayoann2 opened 1 month ago

Khayoann2 commented 1 month ago

Hello,

We facing an issue with this ado extension. Let me summarize it. Imagine that your CI CD pipeline is triggered for the commit xxx and between the moment you triggered the pipeline and the moment you checkout for building your stuffs, you pass a PR, it can be really inconsistent.

Imagine this change is spread all over the solution and you build muiltiple artifacts. Depending on the timing, you will have some artifacts that will take commit xxx because last during the run, and some will take commit yyy because last at this moment.

I think it can be really complicated to manage depending of your way of working but it could be good to have the possibility to give Build.SourceVersion and filter

git clone --filter=tree:0 --no-checkout --depth $fetchDepth --sparse --no-tags --progress --no-recurse-submodules https://$accessToken@$repositoryUri .

git sparse-checkout set --sparse-index $pathsToCheckout

git fetch origin ${sourceCommit}

git checkout FETCH_HEAD

This is working! So like this, you are sure that the contract between the pipeline execution and the checkout process is consistent.