Change behaviour of the extension based on GitLab version
Problem to solve
Currently we support all GitLab versions from 13.5 onwards 1. But sometimes we either need to introduce a new feature that's only supported in newer versions of GitLab or we need to fix a bug (#397 (closed)) in different ways for the latest GitLab version and the older versions.
Proposal
We are parsing the version for the GitLab instance since !252 (merged). We can reuse this logic and create a branching based on it:
function getSnippetContent(){
if (semver.lte(version, '14.1.0') {
return getSnippetContentLegacy();
}
return getSnippetContentNew();
}
/* REMOVE AT 14.1.x: deprecated, doesn't work for versions lower than 14.1.0, remove when we stop supporting 14.0.x */
function getSnippetContentLegacy(){
}
Further details
This might be tricky when we change GraphQL queries to match the new functionality. When GraphQL receives a query for a parameter that doesn't exist, it errors out instead of ignoring that parameter. This is going to be problem if we want to only introduce a feature for newer GitLab versions but the older instances would start returning errors for the whole query.