Do not create pipeline for tags if no target commit exists
What does this MR do and why?
Do not create pipeline for tags if no target commit exists
Git allows users to tag tree and blob objects. Gitlab accepts these objects when being pushed but we do not handle them correctly when triggering pipelines.
When dereferenced_target is nil tag_commit ends up pointing to root_ref
as that's the value used when calling project.commit(nil)
This means we trigger a pipeline for the tag but using HEAD SHA of the root ref. This is incorrect, we can't run a pipeline against a single tree or blob so we should skip these instead. We also can't display these in the UI because we don't have the sha of the dereferenced_target.
This change ensures we skip pipelines for tags without a dereferenced_target.
Related to Tagging a blob or tree results in weird behavior (#579813 - closed)
Changelog: fixed
References
Tagging a blob or tree results in weird behavior (#579813 - closed)
How to set up and validate locally
- Fetch the oid of a blob or tree using
git ls-tree HEAD - Create a tag for a tree or blob using
git tag my_tag -m 'This tag references a blob or tree' {oid} - Push it to GDK and then go to the project's pipeline page and check that no pipelines were created