First tests

This commit is contained in:
alexey
2025-03-18 00:10:53 +03:00
parent ecf3d47392
commit 4cc0477e39
4 changed files with 105 additions and 7 deletions

View File

@@ -333,6 +333,7 @@ class ProjectsActions
if active_build
@error = "Нельзя удалить git репозиторий с незавершенными сборками"
else
proj_path = get_project_path(prj_id)
git_name = @db.get_repo_info_by_id(git_id)
git_source = File.join(proj_path, PROJECTS_STRUCTURE[:SRC], git_name[:reponame])
FileUtils.rm_rf(git_source, secure: true)
@@ -340,4 +341,29 @@ class ProjectsActions
end
@error
end
def delete_project(prj_id)
@error = nil
builds_lst = db.get_builds_for_project(prj_id)
active_build = false
builds_lst.each do |item|
if item[:state] == 0
active_build = true
break
end
end
if active_build
@error = "Нельзя удалить git репозиторий с незавершенными сборками"
else
linked = @db.projects_with_current_as_link(prj_id)
if linked.nil?
proj_path = get_project_path(prj_id)
FileUtils.rm_rf(proj_path, secure: true)
@db.delete_project(prj_id, git_id)
else
@error = "На текущий проект ссылаются другие проекты. Удаление запрещено"
end
end
@error
end
end