MCPcopy
hub / github.com/cli/cli / NewCmdEdit

Function NewCmdEdit

pkg/cmd/repo/edit/edit.go:103–233  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(options *EditOptions) error)

Source from the content-addressed store, hash-verified

101}
102
103func NewCmdEdit(f *cmdutil.Factory, runF func(options *EditOptions) error) *cobra.Command {
104 opts := &EditOptions{
105 IO: f.IOStreams,
106 Prompter: f.Prompter,
107 }
108
109 cmd := &cobra.Command{
110 Use: "edit [<repository>]",
111 Short: "Edit repository settings",
112 Annotations: map[string]string{
113 "help:arguments": heredoc.Doc(`
114 A repository can be supplied as an argument in any of the following formats:
115 - "OWNER/REPO"
116 - by URL, e.g. "https://github.com/OWNER/REPO"
117 `),
118 },
119 Long: heredoc.Docf(`
120 Edit repository settings.
121
122 To toggle a setting off, use the %[1]s--<flag>=false%[1]s syntax.
123
124 Changing repository visibility can have unexpected consequences including but not limited to:
125
126 - Losing stars and watchers, affecting repository ranking
127 - Detaching public forks from the network
128 - Disabling push rulesets
129 - Allowing access to GitHub Actions history and logs
130
131 When the %[1]s--visibility%[1]s flag is used, %[1]s--accept-visibility-change-consequences%[1]s flag is required.
132
133 For information on all the potential consequences, see <https://gh.io/setting-repository-visibility>.
134
135 When the %[1]s--enable-squash-merge%[1]s flag is used, %[1]s--squash-merge-commit-message%[1]s
136 can be used to change the default squash merge commit message behavior:
137
138 - %[1]s%[2]s%[1]s: uses commit title and message for 1 commit, or pull request title and list of commits for 2 or more
139 - %[1]s%[3]s%[1]s: uses pull request title
140 - %[1]s%[4]s%[1]s: uses pull request title and list of commits
141 - %[1]s%[5]s%[1]s: uses pull request title and description
142 `, "`", squashMsgDefault, squashMsgPRTitle, squashMsgPRTitleCommits, squashMsgPRTitleDescription),
143 Args: cobra.MaximumNArgs(1),
144 Example: heredoc.Doc(`
145 # Enable issues and wiki
146 $ gh repo edit --enable-issues --enable-wiki
147
148 # Disable projects
149 $ gh repo edit --enable-projects=false
150 `),
151 RunE: func(cmd *cobra.Command, args []string) error {
152 if len(args) > 0 {
153 var err error
154 opts.Repository, err = ghrepo.FromFullName(args[0])
155 if err != nil {
156 return err
157 }
158 } else {
159 var err error
160 opts.Repository, err = f.BaseRepo()

Callers 1

TestNewCmdEditFunction · 0.70

Calls 11

FromFullNameFunction · 0.92
FlagErrorfFunction · 0.92
NilStringFlagFunction · 0.92
NilBoolFlagFunction · 0.92
transformSquashMergeOptsFunction · 0.85
hasSecurityEditsFunction · 0.85
CanPromptMethod · 0.80
editRunFunction · 0.70
BaseRepoMethod · 0.65

Tested by 1

TestNewCmdEditFunction · 0.56