dynamist / subgit

Sub-git repo handler
Apache License 2.0
0 stars 0 forks source link

Implement "subgit delete" #22

Closed Grokzen closed 1 year ago

Grokzen commented 2 years ago

Implement subgit delete command. We want to have a new command that when run should wipe and delete either the selected repos, or all repos defined in the configuration file.

Precaution steps that should be taken is that it should always ask for user confirmation if it should delete a folder and the entire git tree. Secondly it should either prevent it completley to be deleted if the user has any dirty files or unstaged files or uncommited files that might be lost. A possible third precaution would be to diff any local branches with remote branches to see if there is any unpushed commits that might be lost, this could be put into the future tho.

We also probably want to implement options for -y, --yes and/or -f, --force or something to allow for automation of this step for cases like CI

CLI command to implement would be something like

subgit delete (<repo>...) (-y) (-f)

Where if no repo is set, it means all repos, if one or more repos is explicitly set, then work only on them.

Most usefull use-case for this is ci-cd scenarios where you might clone the repos, make some operation and it might add in files etc into the cloned folders and you want to wipe it all and restart the next run or within the same run.

Integration test this against existing repos and implement light unittests for this

Grokzen commented 1 year ago

There is an open question still remaining to be decided what we do. If we are going to check that all local branches match the remote branches so there is no unpushed commits before we delete, should we run a fetch before we delete or should we let the user decide if they want to run that first? fetching git changes is generally safe and cause no issues per say, but this would cause more magic to happen the to just say that the user has to run subgit fetch first manually, then run subgit delete after it.

We have arguments on both sides of this and we need to settle on either way. The checks might still needs to be done, but the fetch should not be run.