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

Method RepositoryFeatures

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

Source from the content-addressed store, hash-verified

300}
301
302func (d *detector) RepositoryFeatures() (RepositoryFeatures, error) {
303 if !ghauth.IsEnterprise(d.host) {
304 return allRepositoryFeatures, nil
305 }
306
307 features := RepositoryFeatures{}
308
309 var featureDetection struct {
310 Repository struct {
311 Fields []struct {
312 Name string
313 } `graphql:"fields(includeDeprecated: true)"`
314 } `graphql:"Repository: __type(name: \"Repository\")"`
315 }
316
317 gql := api.NewClientFromHTTP(d.httpClient)
318
319 err := gql.Query(d.host, "Repository_fields", &featureDetection, nil)
320 if err != nil {
321 return features, err
322 }
323
324 for _, field := range featureDetection.Repository.Fields {
325 if field.Name == "pullRequestTemplates" {
326 features.PullRequestTemplateQuery = true
327 }
328 if field.Name == "visibility" {
329 features.VisibilityField = true
330 }
331 if field.Name == "autoMergeAllowed" {
332 features.AutoMerge = true
333 }
334 }
335
336 return features, nil
337}
338
339const (
340 enterpriseProjectsV1Removed = "3.17.0"

Callers 1

TestRepositoryFeaturesFunction · 0.95

Calls 2

NewClientFromHTTPFunction · 0.92
QueryMethod · 0.65

Tested by 1

TestRepositoryFeaturesFunction · 0.76