From 090f6d3cf20f13803bc7499d79b72611a07fd3ad Mon Sep 17 00:00:00 2001 From: Vadim Troshchinskiy Date: Wed, 3 Sep 2025 13:35:32 +0200 Subject: [PATCH] refs #2705: fix commit message in image creation --- ogclient/interfaceAdm/CrearImagenGit | 8 ++++---- ogclient/interfaceAdm/ModificarImagenGit | 2 +- ogclient/lib/python3/GitLib/__init__.py | 8 ++++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ogclient/interfaceAdm/CrearImagenGit b/ogclient/interfaceAdm/CrearImagenGit index 87c66ee..585abc7 100755 --- a/ogclient/interfaceAdm/CrearImagenGit +++ b/ogclient/interfaceAdm/CrearImagenGit @@ -35,7 +35,7 @@ class OgLogger(logging.StreamHandler): -def create_image(disk_num, partition_num, repo, image_name): +def create_image(disk_num, partition_num, repo, image_name, commit_message): ntfs_impl = NTFSImplementation.NTFS3G og_git = OpengnsysGitLibrary(ntfs_implementation = ntfs_impl) @@ -45,7 +45,7 @@ def create_image(disk_num, partition_num, repo, image_name): if device is None: sys.exit(SystemLib.ogRaiseError([], ogGlobals.OG_ERR_FORMAT, f"Failed to translate disk {disk_num} partition {partition_num} to a device")) - if og_git.initRepo(device, image_name): + if og_git.initRepo(device, image_name, message = commit_message): return 0 else: return 1 @@ -73,7 +73,7 @@ def main(): parser.add_argument("--repository", type=str, metavar="REPO", required=True, help="Address of the Git repository to clone") parser.add_argument("--image-name", type=str, metavar="REPO", required=True, help="Name of the new image at the repository") parser.add_argument("--tag", type=str, metavar="TAG", required=False, help="Tag to automatically create") - parser.add_argument("--message", type=str, metavar="MSG", required=False, help="Commit message") + parser.add_argument("--message", type=str, metavar="MSG", required=False, default="", help="Commit message") parser.add_help = True @@ -106,7 +106,7 @@ def main(): # repo = repositorio, oggit@server.com:/oggit # image = nombre repo - retval = create_image(args.disk, args.partition, args.repository, args.image_name) + retval = create_image(args.disk, args.partition, args.repository, args.image_name, args.message) diff --git a/ogclient/interfaceAdm/ModificarImagenGit b/ogclient/interfaceAdm/ModificarImagenGit index 4e99a03..b517099 100755 --- a/ogclient/interfaceAdm/ModificarImagenGit +++ b/ogclient/interfaceAdm/ModificarImagenGit @@ -110,7 +110,7 @@ def main(): parser.add_argument("--branch", type=str, metavar="BRANCH", required=False, help="Branch to automatically create") parser.add_argument("--options", type=str, metavar="OPTS", required=False, help="Options to branch creation (forcepush)") - parser.add_argument("--message", type=str, metavar="MSG", required=False, help="Commit message") + parser.add_argument("--message", type=str, metavar="MSG", required=False, default="", help="Commit message") parser.add_help = True diff --git a/ogclient/lib/python3/GitLib/__init__.py b/ogclient/lib/python3/GitLib/__init__.py index c86afc1..01d371a 100755 --- a/ogclient/lib/python3/GitLib/__init__.py +++ b/ogclient/lib/python3/GitLib/__init__.py @@ -1254,7 +1254,7 @@ class OpengnsysGitLibrary: repo.config_writer().add_value("push", "followTags", "true").release() - def initRepo(self, device, repo_name): + def initRepo(self, device, repo_name, message = None): """ Initialize a Git repository on a specified device. @@ -1396,7 +1396,11 @@ class OpengnsysGitLibrary: self.logger.info("Committing") - repo.index.commit("Initialize repository") + + if message: + repo.index.commit(message) + else: + repo.index.commit("Initialize repository") # Restaurar cosas modificadas para git self._restore_metadata(path, destructive_only=True, set_device_uuids=False)