-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathcodeowners.go
More file actions
71 lines (59 loc) · 1.57 KB
/
Copy pathcodeowners.go
File metadata and controls
71 lines (59 loc) · 1.57 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"io"
"os"
"github.com/sourcegraph/sourcegraph/lib/errors"
"github.com/sourcegraph/src-cli/internal/clicompat"
"github.com/urfave/cli/v3"
)
const codeownersExamples = `'src codeowners' manages ingested code ownership data in a Sourcegraph instance.
Usage:
src codeowners [command options]
Examples:
$ src codeowners get -repo='github.com/sourcegraph/sourcegraph'
$ src codeowners create -repo='github.com/sourcegraph/sourcegraph' -f CODEOWNERS
$ src codeowners update -repo='github.com/sourcegraph/sourcegraph' -f CODEOWNERS
$ src codeowners delete -repo='github.com/sourcegraph/sourcegraph'
`
const codeownersFragment = `
fragment CodeownersFileFields on CodeownersIngestedFile {
contents
repository {
name
}
}
`
type CodeownersIngestedFile struct {
Contents string `json:"contents"`
Repository struct {
Name string `json:"name"`
} `json:"repository"`
}
var codeownersCommand = clicompat.Wrap(&cli.Command{
Name: "codeowners",
Aliases: []string{"codeowner"},
Usage: "manages ingested code ownership data",
UsageText: "src codeowners [command options]",
Description: codeownersExamples,
HideVersion: true,
Commands: []*cli.Command{
codeownersGetCommand,
codeownersCreateCommand,
codeownersUpdateCommand,
codeownersDeleteCommand,
},
})
func readFile(f string) ([]byte, error) {
if f == "-" {
return io.ReadAll(os.Stdin)
}
return os.ReadFile(f)
}
func requiresNotEmpty(errMsg string) func(string) error {
return func(value string) error {
if value == "" {
return errors.New(errMsg)
}
return nil
}
}