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

Function NewCmdEdit

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

Source from the content-addressed store, hash-verified

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