refs #3767 - partial v2
parent
e9efb641b6
commit
877bc16d28
|
@ -4,6 +4,8 @@ import resource
|
|||
import logging
|
||||
import subprocess
|
||||
|
||||
sys.path.insert(0, "/opt/opengnsys/lib/python3-test")
|
||||
|
||||
import NetLib
|
||||
import ogGlobals
|
||||
import SystemLib
|
||||
|
|
|
@ -1499,7 +1499,7 @@ class OpengnsysGitLibrary:
|
|||
Info: Logs the start of the cloning process.
|
||||
Debug: Logs the repository URL, EFI compatibility of the repository and the system.
|
||||
"""
|
||||
self.logger.info(f"Cloning repo: {repo_name} => {destination}")
|
||||
self.logger.info(f"Cloning repo : {repo_name} => {destination}")
|
||||
|
||||
|
||||
repo_url = self._getOgRepository(repo_name)
|
||||
|
@ -1513,8 +1513,8 @@ class OpengnsysGitLibrary:
|
|||
self.logger.info("There is an existing repository, but a full reset will be done")
|
||||
repo = None
|
||||
else:
|
||||
self.logger.info("Verifying existing repository at %s", destination)
|
||||
repo = git.Repo(destination)
|
||||
self.logger.info("Verifying existing repository at %s", real_git_dir)
|
||||
repo = git.Repo.init(real_git_dir, bare=True)
|
||||
|
||||
if "origin" in repo.remotes:
|
||||
if repo_url in repo.remotes.origin.urls:
|
||||
|
@ -1531,8 +1531,6 @@ class OpengnsysGitLibrary:
|
|||
os._exit(10)
|
||||
shutil.rmtree(real_git_dir)
|
||||
|
||||
os._exit(10)
|
||||
|
||||
all_metadata = self._get_repo_metadata(repo_name)
|
||||
metadata = all_metadata["metadata.json"]
|
||||
fs_data = all_metadata["filesystems.json"]
|
||||
|
@ -1554,6 +1552,7 @@ class OpengnsysGitLibrary:
|
|||
raise RequirementException("Repositorio usa sistema de arranque incompatible con sistema actual")
|
||||
|
||||
if repo is None or format_existing:
|
||||
self.logger.info("Creating a new filesystem at %s")
|
||||
self.fs.unmount(device = destination)
|
||||
|
||||
filesystem_map = {"/" : destination}
|
||||
|
@ -1565,6 +1564,32 @@ class OpengnsysGitLibrary:
|
|||
self.fs.mount(destination, destination_dir)
|
||||
|
||||
self._delete_contents(destination_dir)
|
||||
else:
|
||||
destination_dir = "/mnt/repo-" + repo_name
|
||||
self.logger.info("Mounting existing filesystem %s at %s", destination, destination_dir)
|
||||
self.fs.unmount(device = destination)
|
||||
self.fs.mount(destination, destination_dir)
|
||||
|
||||
# Change from bare repo to our checked out repo
|
||||
self.logger.info("Opening repo from %s now", destination_dir)
|
||||
|
||||
git_dotdir = os.path.join(destination, ".git")
|
||||
if os.path.exists(git_dotdir):
|
||||
self.logger.debug("Replacing .git directory, gitpython doesn't like the file method")
|
||||
os.unlink(git_dotdir)
|
||||
os.symlink(src = real_git_dir, dst = git_dotdir)
|
||||
|
||||
self.logger.info("Re-opening git repo at %s", destination_dir)
|
||||
repo = git.Repo(destination_dir)
|
||||
|
||||
self.logger.info("Forcing git repo to non-bare status")
|
||||
repo.config_writer().set_value("core", "bare", "false").release()
|
||||
|
||||
self.logger.info("Re-opening git repo again after non-bare adjustment at %s", destination_dir)
|
||||
repo = git.Repo(destination_dir)
|
||||
|
||||
self.logger.info("New repo is %s", repo)
|
||||
|
||||
|
||||
|
||||
if repo is None:
|
||||
|
@ -1579,7 +1604,7 @@ class OpengnsysGitLibrary:
|
|||
self.logger.debug("Cloning repo %s", repo_url)
|
||||
repo = git.Repo.clone_from(repo_url, destination_dir, multi_options = [f"--separate-git-dir={real_git_dir}"], progress=self.progress_callback)
|
||||
else:
|
||||
self.logger.info("Fetching updates from remote")
|
||||
self.logger.info("Fetching updates from remote in %s", repo)
|
||||
for remote in repo.remotes:
|
||||
remote.fetch()
|
||||
|
||||
|
@ -1601,8 +1626,8 @@ class OpengnsysGitLibrary:
|
|||
local_ref = repo.create_head(branch, remote_branch_ref)
|
||||
local_ref.set_tracking_branch(remote_branch_ref)
|
||||
|
||||
self.logger.debug("Checking out local branch %s", branch)
|
||||
local_ref.checkout()
|
||||
self.logger.debug("Checking out local branch %s", branch)
|
||||
local_ref.checkout()
|
||||
|
||||
|
||||
self.fs.mklostandfound(destination_dir)
|
||||
|
|
Loading…
Reference in New Issue