Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont follow redirects on repo delete #7106

Merged
merged 3 commits into from Mar 13, 2023
Merged

Dont follow redirects on repo delete #7106

merged 3 commits into from Mar 13, 2023

Conversation

samcoe
Copy link
Contributor

@samcoe samcoe commented Mar 8, 2023

Don't follow redirects when trying to do repo deletion. This prevents accidentally deleting repos that have transferred ownership.

@samcoe samcoe requested a review from a team as a code owner March 8, 2023 01:48
@samcoe samcoe self-assigned this Mar 8, 2023
@samcoe samcoe requested review from vilmibm and removed request for a team March 8, 2023 01:48
@cliAutomation cliAutomation added this to Needs review 🤔 in The GitHub CLI Mar 8, 2023
pkg/cmd/repo/delete/http.go Show resolved Hide resolved
@samcoe samcoe requested a review from mislav March 9, 2023 01:53
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work to prevent a redirected repo from getting deleted, but the error message as surfaced to the user will be confusing:

HTTP 301: Moved Permanently

Based on this alone, I don't think the user will know what they did wrong. I think a better error message would print the new full name of the repo and ask the user, if they are still sure they want to delete it, to specify the new name.

pkg/cmd/repo/delete/http.go Outdated Show resolved Hide resolved
@samcoe samcoe requested a review from mislav March 12, 2023 23:54
statusCode == http.StatusTemporaryRedirect ||
statusCode == http.StatusPermanentRedirect {
cs := opts.IO.ColorScheme()
fmt.Fprintf(opts.IO.ErrOut, "%s Failed to delete repository: %s has changed name or transfered ownership\n", cs.FailureIcon(), fullName)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with this error message as the redirect response from the server does not give the new repository name just an ID.

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!

The GitHub CLI automation moved this from Needs review 🤔 to Needs to be merged 🎉 Mar 13, 2023
@samcoe samcoe merged commit f7930a4 into trunk Mar 13, 2023
10 checks passed
The GitHub CLI automation moved this from Needs to be merged 🎉 to Pending Release 🥚 Mar 13, 2023
@samcoe samcoe deleted the delete-redirect branch March 13, 2023 17:38
@github-actions github-actions bot moved this from Pending Release 🥚 to Done 💤 in The GitHub CLI Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
The GitHub CLI
  
Done 💤
Development

Successfully merging this pull request may close these issues.

None yet

3 participants