Added projects. Part 6
This commit is contained in:
@@ -7,6 +7,7 @@ PROJECTS_STRUCTURE = {
|
||||
:CONFIGS => "configs",
|
||||
:SRCPRP => "srcprp",
|
||||
:SIGNED => "signed",
|
||||
:SRC => "src",
|
||||
}
|
||||
|
||||
class ProjectsActions
|
||||
@@ -46,6 +47,18 @@ class ProjectsActions
|
||||
prj
|
||||
end
|
||||
|
||||
def get_project_path(id)
|
||||
@error = nil
|
||||
fname = nil
|
||||
prj = @db.proj(id)
|
||||
if prj.nil?
|
||||
@error = "Проекта с id = #{id} не существует"
|
||||
else
|
||||
fname = File.expand_path("#{prj[:projname]}.prj", @path)
|
||||
end
|
||||
fname
|
||||
end
|
||||
|
||||
def create_project(name, description, configuration)
|
||||
@error = nil
|
||||
ret_val = 0
|
||||
@@ -87,11 +100,43 @@ class ProjectsActions
|
||||
ret_val
|
||||
end
|
||||
|
||||
def get_project_gits(id)
|
||||
@db.get_gits_for_projects(id)
|
||||
def get_project_gits(id, repo)
|
||||
res = []
|
||||
File.open("locks/prjcreate", "r") do |f|
|
||||
f.flock(File::LOCK_EX)
|
||||
res = @db.get_gits_for_projects(id)
|
||||
res_sync = res.map do |item|
|
||||
prj_p = get_project_path(id)
|
||||
path = File.join(prj_p, PROJECTS_STRUCTURE[:SRC], item[:reponame])
|
||||
item[:is_repo_synced] = repo.is_repos_sync(item[:reponame], path)
|
||||
item
|
||||
end
|
||||
end
|
||||
res
|
||||
end
|
||||
|
||||
def add_git_to_project(prj_id, git_id)
|
||||
@db.save_git_project(prj_id, git_id)
|
||||
def add_git_to_project(prj_id, git_id, repo, git_name)
|
||||
path = get_project_path(prj_id)
|
||||
if @error.nil?
|
||||
path = File.join(path, PROJECTS_STRUCTURE[:SRC], git_name)
|
||||
err = repo.clone_repo_master(git_id, path)
|
||||
if err.nil?
|
||||
@db.save_git_project(prj_id, git_id)
|
||||
end
|
||||
else
|
||||
err = @error
|
||||
end
|
||||
err
|
||||
end
|
||||
|
||||
def renew_git_to_project(prj_id, git_id, repo, git_name)
|
||||
path = get_project_path(prj_id)
|
||||
if @error.nil?
|
||||
path = File.join(path, PROJECTS_STRUCTURE[:SRC], git_name)
|
||||
err = repo.clone_repo_master(git_id, path)
|
||||
else
|
||||
err = @error
|
||||
end
|
||||
err
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user