[elbe-devel] [PATCH 1/8] elbepack: db: remove set_project_version()

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Aug 13 09:31:17 CEST 2024


This function is not reachable by the user, only internal commands.
Drop it and the corresponding internal command.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 docs/elbe-db.rst        |  4 ----
 elbepack/commands/db.py |  8 --------
 elbepack/db.py          | 33 ---------------------------------
 3 files changed, 45 deletions(-)

diff --git a/docs/elbe-db.rst b/docs/elbe-db.rst
index ebf1759f30ef..4a44f10cf8d3 100644
--- a/docs/elbe-db.rst
+++ b/docs/elbe-db.rst
@@ -23,7 +23,6 @@ SYNOPSIS
       elbe db [options] print_version_xml <project_dir> <version>
       elbe db [options] init
       elbe db [options] del_user <userid>
-      elbe db [options] set_project_version <project_dir> <version>
       elbe db [options] add_user <username>
       elbe db [options] list_versions <project_dir>
       elbe db [options] del_versions <project_dir> <version>
@@ -117,9 +116,6 @@ COMMANDS
    has been aborted and the project is set ``busy`` in in the database
    obstructing future actions on this project. Options: clean[=False].
 
-*set_project_version* <project_dir> <version>
-   Sets the project version of project <project_dir> to <version>.
-
 *list_versions* <project_dir>
    Lists all versions of project <project_dir>.
 
diff --git a/elbepack/commands/db.py b/elbepack/commands/db.py
index 9d0d34eb1a2a..1b9d1bb4aaf5 100644
--- a/elbepack/commands/db.py
+++ b/elbepack/commands/db.py
@@ -136,13 +136,6 @@ def _reset_project(args):
     db.reset_project(args.project_dir, args.clean)
 
 
- at add_argument('project_dir')
- at add_argument('version')
-def _set_project_version(args):
-    db = ElbeDB()
-    db.set_project_version(args.project_dir, args.version)
-
-
 @add_argument('project_dir')
 def _list_versions(args):
     db = ElbeDB()
@@ -190,7 +183,6 @@ _actions = {
     'build':               _build,
     'get_files':           _get_files,
     'reset_project':       _reset_project,
-    'set_project_version': _set_project_version,
     'list_versions':       _list_versions,
     'save_version':        _save_version,
     'del_versions':        _del_version,
diff --git a/elbepack/db.py b/elbepack/db.py
index 0ea698046fd4..c1bd9b5cf1d9 100644
--- a/elbepack/db.py
+++ b/elbepack/db.py
@@ -6,7 +6,6 @@
 import errno
 import glob
 import os
-import re
 import warnings
 from contextlib import contextmanager
 from datetime import datetime
@@ -432,38 +431,6 @@ class ElbeDB:
 
             return int(p.owner_id)
 
-    def set_project_version(self, builddir, new_version=None):
-        if new_version == '':
-            raise ElbeDBError('version number must not be empty')
-
-        if not re.match('^[A-Za-z0-9_.-]{1,25}$', new_version):
-            raise ElbeDBError(
-                'version number must contain valid characters [A-Za-z0-9_-.]')
-
-        with session_scope(self.session) as s:
-            try:
-                p = s.query(Project).filter(Project.builddir == builddir).\
-                    one()
-            except NoResultFound:
-                raise ElbeDBError(
-                    f'project {builddir} is not registered in the database')
-
-            if p.status == 'empty_project' or p.status == 'busy':
-                raise ElbeDBError(
-                    'project: ' +
-                    builddir +
-                    ' set_project_version: invalid status: ' +
-                    p.status)
-
-            xmlpath = os.path.join(builddir, 'source.xml')
-            xml = ElbeXML(xmlpath, url_validation=ValidationMode.NO_CHECK)
-
-            if new_version is not None:
-                xml.node('/project/version').set_text(new_version)
-                xml.xml.write(xmlpath)
-
-            p.version = xml.text('/project/version')
-
     def list_project_versions(self, builddir):
         with session_scope(self.session) as s:
             try:

-- 
2.46.0



More information about the elbe-devel mailing list