Added projects. Part 6

This commit is contained in:
alexey
2025-03-01 00:07:20 +03:00
parent 77f9fa7da2
commit c61763ba56
5 changed files with 121 additions and 10 deletions

View File

@@ -165,7 +165,11 @@ class GitRepo
if repo.empty?
@error = "Репозиторий пустой, нельзя добавить в проект пустой репозиторий"
else
#TODO clone repo
if File.exist?(path)
FileUtils.rm_rf(path, secure: true)
end
Dir.mkdir(path)
Rugged::Repository.clone_at(repo.path, path)
end
else
@error = "Файла репозитория не существует"
@@ -176,4 +180,18 @@ class GitRepo
end
@error
end
def is_repos_sync(repo_name, prj_repo_path)
res = false
repo = Rugged::Repository.new(prj_repo_path)
File.open("locks/gitcreate", "r") do |f|
f.flock(File::LOCK_SH)
git_path = File.join(@path, repo_name + ".git")
bare_repo = Rugged::Repository.new(git_path)
pp bare_repo.head
pp repo.head
res = (bare_repo.head.oid == repo.head.oid)
end
res
end
end