Debian Codegraph @

github/repos_codeowners.go

raw
1 // Copyright 2022 The go-github AUTHORS. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file.
5
6 package github
7
8 import (
9 "context"
10 "fmt"
11 )
12
13 // GetCodeownersErrorsOptions specifies the optional parameters to the
14 // RepositoriesService.GetCodeownersErrors method.
15 type GetCodeownersErrorsOptions struct {
16 // A branch, tag or commit name used to determine which version of the CODEOWNERS file to use.
17 // Default: the repository's default branch (e.g. main).
18 Ref string `url:"ref,omitempty"`
19 }
20
21 // CodeownersErrors represents a list of syntax errors detected in the CODEOWNERS file.
22 type CodeownersErrors struct {
23 Errors []*CodeownersError `json:"errors"`
24 }
25
26 // CodeownersError represents a syntax error detected in the CODEOWNERS file.
27 type CodeownersError struct {
28 Line int `json:"line"`
29 Column int `json:"column"`
30 Kind string `json:"kind"`
31 Source string `json:"source"`
32 Suggestion *string `json:"suggestion,omitempty"`
33 Message string `json:"message"`
34 Path string `json:"path"`
35 }
36
37 // GetCodeownersErrors lists any syntax errors that are detected in the CODEOWNERS file.
38 //
39 // GitHub API docs: https://docs.github.com/rest/repos/repos#list-codeowners-errors
40 //
41 //meta:operation GET /repos/{owner}/{repo}/codeowners/errors
42 func (s *RepositoriesService) GetCodeownersErrors(ctx context.Context, owner, repo string, opts *GetCodeownersErrorsOptions) (*CodeownersErrors, *Response, error) {
43 u := fmt.Sprintf("repos/%v/%v/codeowners/errors", owner, repo)
44 u, err := addOptions(u, opts)
45 if err != nil {
46 return nil, nil, err
47 }
48
49 req, err := s.client.NewRequest("GET", u, nil)
50 if err != nil {
51 return nil, nil, err
52 }
53
54 codeownersErrors := &CodeownersErrors{}
55 resp, err := s.client.Do(ctx, req, codeownersErrors)
56 if err != nil {
57 return nil, resp, err
58 }
59
60 return codeownersErrors, resp, nil
61 }