Skip to content

Commit 7c7d300

Browse files
committed
Version pom using elementTree
1 parent 9db8326 commit 7c7d300

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

developers_chamber/version_utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ def _write_version_to_file(file, new_version, file_type=None):
106106
ET.register_namespace("", "http://maven.apache.org/POM/4.0.0")
107107
tree = ET.parse(f)
108108
root = tree.getroot()
109-
properties = root.find("{http://maven.apache.org/POM/4.0.0}properties")
110-
r = properties.find("{http://maven.apache.org/POM/4.0.0}revision")
111-
r.text = str(new_version)
109+
version = root.find("{http://maven.apache.org/POM/4.0.0}version")
110+
version.text = str(new_version)
112111
tree.write(full_file_path, xml_declaration=True, encoding="utf-8", method="xml")
113112
else:
114113
raise BadParameter(f'Invalid version type "{file_type}"')
@@ -179,8 +178,7 @@ def read_version_from_pom(file="pom.xml"):
179178
try:
180179
tree = ET.parse(full_file_path)
181180
root = tree.getroot()
182-
properties = root.find("{http://maven.apache.org/POM/4.0.0}properties")
183-
r = properties.find("{http://maven.apache.org/POM/4.0.0}revision")
184-
return r.text
181+
version = root.find("{http://maven.apache.org/POM/4.0.0}version")
182+
return version.text
185183
except KeyError:
186184
raise BadParameter("Could not find revision in pom.xml")

0 commit comments

Comments
 (0)