Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pkg/cmd/repo/edit/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(options *EditOptions) error) *cobr
return cmdutil.FlagErrorf("use of --visibility flag requires --accept-visibility-change-consequences flag")
}

if opts.Edits.Visibility != nil && !opts.InteractiveMode {
apiClient := api.NewClientFromHTTP(opts.HTTPClient)
repo, err := api.FetchRepository(apiClient, opts.Repository, []string{"isFork"})
if err != nil {
return err
}
if repo.IsFork {
return fmt.Errorf("changing visibility of a forked repository is not supported")
}
}

if opts.Edits.squashMergeCommitMsg != nil {
if opts.Edits.EnableSquashMerge == nil {
return cmdutil.FlagErrorf("--squash-merge-commit-message requires --enable-squash-merge")
Expand Down Expand Up @@ -257,6 +268,7 @@ func editRun(ctx context.Context, opts *EditOptions) error {
// TODO: GitHub Enterprise Server does not support has_discussions yet
// "hasDiscussionsEnabled",
"homepageUrl",
"isFork",
"isInOrganization",
"isTemplate",
"mergeCommitAllowed",
Expand Down Expand Up @@ -453,6 +465,9 @@ func interactiveRepoEdit(opts *EditOptions, r *api.Repository) error {
}
opts.Edits.EnableProjects = &a
case optionVisibility:
if r.IsFork {
return fmt.Errorf("changing visibility of a forked repository is not supported")
}
cs := opts.IO.ColorScheme()
fmt.Fprintf(opts.IO.ErrOut, "%s Danger zone: changing repository visibility can have unexpected consequences; consult https://gh.io/setting-repository-visibility before continuing.\n", cs.WarningIcon())

Expand Down