-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathfeatures.go
More file actions
56 lines (51 loc) · 1.99 KB
/
Copy pathfeatures.go
File metadata and controls
56 lines (51 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package batches
import (
"github.com/sourcegraph/sourcegraph/lib/errors"
"github.com/sourcegraph/src-cli/internal/api"
)
// FeatureFlags represent features that are only available on certain
// Sourcegraph versions and we therefore have to detect at runtime.
type FeatureFlags struct {
AllowArrayEnvironments bool
IncludeAutoAuthorDetails bool
UseGzipCompression bool
AllowTransformChanges bool
AllowWorkspaces bool
BatchChanges bool
AllowConditionalExec bool
AllowOptionalPublished bool
ServerSideBatchChanges bool
BitbucketCloud bool
}
func (ff *FeatureFlags) SetFromVersion(version string) error {
for _, feature := range []struct {
flag *bool
constraint string
minDate string
}{
// NOTE: It's necessary to include a "-0" prerelease suffix on each constraint so that
// prereleases of future versions are still considered to satisfy the constraint.
//
// For example, the version "3.35.1-rc.3" is not considered to satisfy the constraint
// ">= 3.23.0". However, the same version IS considered to satisfy the constraint
// "3.23.0-0". See
// https://github.com/Masterminds/semver#working-with-prerelease-versions for more.
{&ff.AllowArrayEnvironments, ">= 3.23.0-0", "2020-11-24"},
{&ff.IncludeAutoAuthorDetails, ">= 3.20.0-0", "2020-09-10"},
{&ff.UseGzipCompression, ">= 3.21.0-0", "2020-10-12"},
{&ff.AllowTransformChanges, ">= 3.23.0-0", "2020-12-11"},
{&ff.AllowWorkspaces, ">= 3.25.0-0", "2021-01-29"},
{&ff.BatchChanges, ">= 3.26.0-0", "2021-03-07"},
{&ff.AllowConditionalExec, ">= 3.28.0-0", "2021-05-05"},
{&ff.AllowOptionalPublished, ">= 3.30.0-0", "2021-06-21"},
{&ff.ServerSideBatchChanges, ">= 3.37.0-0", "2022-02-08"},
{&ff.BitbucketCloud, ">= 3.40.0-0", "2022-04-20"},
} {
value, err := api.CheckSourcegraphVersion(version, feature.constraint, feature.minDate)
if err != nil {
return errors.Wrap(err, "failed to check version returned by Sourcegraph")
}
*feature.flag = value
}
return nil
}