Added delete of items.Part 1
This commit is contained in:
@@ -65,6 +65,11 @@ class ProjectsActions
|
||||
fname
|
||||
end
|
||||
|
||||
def get_project_repo(id)
|
||||
proj_path = get_project_path(id)
|
||||
File.join(proj_path, PROJECTS_STRUCTURE[:REPO])
|
||||
end
|
||||
|
||||
def get_project_path_git(id, gitname)
|
||||
proj_path = get_project_path(id)
|
||||
File.join(proj_path, PROJECTS_STRUCTURE[:SRC], gitname)
|
||||
@@ -314,4 +319,25 @@ class ProjectsActions
|
||||
end
|
||||
bld_id
|
||||
end
|
||||
|
||||
def delete_git_from_project(prj_id, git_id)
|
||||
@error = nil
|
||||
builds_lst = db.get_builds_for_project_git(prj_id, git_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
|
||||
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)
|
||||
@db.delete_git_from_project(prj_id, git_id)
|
||||
end
|
||||
@error
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user