MCPcopy Create free account
hub / github.com/cli/cli / RepositoryFeatures

Method RepositoryFeatures

internal/featuredetection/feature_detection.go:271–306  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

269}
270
271func (d *detector) RepositoryFeatures() (RepositoryFeatures, error) {
272 if !ghauth.IsEnterprise(d.host) {
273 return allRepositoryFeatures, nil
274 }
275
276 features := RepositoryFeatures{}
277
278 var featureDetection struct {
279 Repository struct {
280 Fields []struct {
281 Name string
282 } `graphql:"fields(includeDeprecated: true)"`
283 } `graphql:"Repository: __type(name: \"Repository\")"`
284 }
285
286 gql := api.NewClientFromHTTP(d.httpClient)
287
288 err := gql.Query(d.host, "Repository_fields", &featureDetection, nil)
289 if err != nil {
290 return features, err
291 }
292
293 for _, field := range featureDetection.Repository.Fields {
294 if field.Name == "pullRequestTemplates" {
295 features.PullRequestTemplateQuery = true
296 }
297 if field.Name == "visibility" {
298 features.VisibilityField = true
299 }
300 if field.Name == "autoMergeAllowed" {
301 features.AutoMerge = true
302 }
303 }
304
305 return features, nil
306}
307
308const (
309 enterpriseProjectsV1Removed = "3.17.0"

Callers 1

TestRepositoryFeaturesFunction · 0.95

Calls 2

NewClientFromHTTPFunction · 0.92
QueryMethod · 0.65

Tested by 1

TestRepositoryFeaturesFunction · 0.76