ontodev / droid

DROID Reminds us that Ordinary Individuals can be Developers
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

DROID should not delete "default branch", i.e. master/main #127

Closed jamesaoverton closed 1 year ago

jamesaoverton commented 2 years ago

I was deleting some old checked-out branches from the main DROID server, and accidentally checked the "Also delete remote branch" when deleting the master branch of a repository. I was able to restore the branch by pushing it back to GitHub from another copy. I also (think that) I turned on branch protection on GitHub for that repo, which should prevent that mistake in the future for that repo. But it would be better if DROID didn't let me shoot myself with this footgun.

The simplest solution would be to match on master or main and not provide the "Also delete remote branch" checkbox.

A smarter solution would be to ask GitHub which is the default branch for the repository, not provide the checkbox for that branch, and also just refuse to call the GitHub API to delete the default branch.

lmcmicu commented 1 year ago

I've created a PR: https://github.com/ontodev/droid/pull/129 to address this. Note that I've implemented the "simplest" solution mentioned above, since in the current code we are already treating the names "master" and "main" as special. I.e., if we want to implement the smarter solution mentioned above, then we should also do the work to make the default branch more generic elsewhere. I'm not sure if this use case is common enough to be worth handling, though.