Добавлена возможность инициализации репозитория с перезаписью существующего через флаг force

This commit is contained in:
Alexander Zhirov 2025-05-27 00:12:43 +03:00
parent 35a7b26a4a
commit db9a6be9f4
Signed by: alexander
GPG key ID: C8D8BE544A27C511
2 changed files with 14 additions and 4 deletions

View file

@ -44,13 +44,18 @@ class Snag {
return result;
}
void initialize() {
void initialize(bool force) {
auto result = execute(_baseCommand ~ ["rev-parse", "--git-dir"]);
!result.status &&
!force && !result.status &&
throw new SnagException(
"The Git repository has already been initialized: "
~ result.output.strip('\n')
);
force && _config.git.exists
&& _config.git.isDir
&& _config.git.rmdirRecurse;
git(
["init", "--initial-branch=default"],
"A Git repository initialization error occurred"