Added projects. Part 5

This commit is contained in:
alexey
2025-02-28 00:13:04 +03:00
parent 34a69e1a1d
commit 77f9fa7da2
7 changed files with 121 additions and 7 deletions

View File

@@ -37,6 +37,10 @@ class DBase
Repos.where(reponame: repo_name)
end
def get_repo_info_by_id(id)
Repos[id]
end
def get_recips()
result = []
Recips.order(:id).map do |item|
@@ -49,7 +53,7 @@ class DBase
unless rep_id[:id].nil?
id = rep_id[:id]
RepocRecips.where(repo_id: id).delete
Repos.where(id: id).delete
ReposProjects.where(repo_id: id).delete
end
end
@@ -147,4 +151,12 @@ class DBase
end
result
end
def save_git_project(prj_id, git_id)
result = ReposProjects.where(proj_id: prj_id, repo_id: git_id).first
if result.nil?
id = ReposProjects.insert(proj_id: prj_id, repo_id: git_id)
@last_id = id
end
end
end

View File

@@ -148,4 +148,32 @@ class GitRepo
end
end
end
def get_repo_short_info_by_id(id)
@db.get_repo_info_by_id(id)
end
def clone_repo_master(id, path)
@error = nil
repo_info = @db.get_repo_info_by_id(id)
unless repo_info.nil?
File.open("locks/gitcreate", "r") do |f|
f.flock(File::LOCK_SH)
git_path = File.join(@path, repo_info[:reponame] + ".git")
if File.exist?(git_path)
repo = Rugged::Repository.new(git_path)
if repo.empty?
@error = "Репозиторий пустой, нельзя добавить в проект пустой репозиторий"
else
#TODO clone repo
end
else
@error = "Файла репозитория не существует"
end
end
else
@error = "Нет информации о репозитории"
end
@error
end
end

View File

@@ -90,4 +90,8 @@ class ProjectsActions
def get_project_gits(id)
@db.get_gits_for_projects(id)
end
def add_git_to_project(prj_id, git_id)
@db.save_git_project(prj_id, git_id)
end
end