Improved set-version tool & set version

This commit is contained in:
Sven Heidemann 2022-12-03 23:42:23 +01:00
parent 099a51ed93
commit b02aebef35
15 changed files with 65 additions and 50 deletions

View File

@ -3,8 +3,8 @@
"Name": "cpl-cli",
"Version": {
"Major": "2022",
"Minor": "10",
"Micro": "1.post1"
"Minor": "12",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",
@ -16,7 +16,7 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl-core>=2022.10.0"
"cpl-core>=2022.12.0"
],
"DevDependencies": [],
"PythonVersion": ">=3.10",

View File

@ -3,8 +3,8 @@
"Name": "cpl-core",
"Version": {
"Major": "2022",
"Minor": "10",
"Micro": "0.post9"
"Minor": "12",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -16,12 +16,12 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl-core>=2022.10.0",
"discord.py==2.0.1",
"cpl-query>=2022.10.0"
"cpl-core>=2022.12.0",
"discord.py==2.1.0",
"cpl-query>=2022.12.0"
],
"DevDependencies": [
"cpl-cli>=2022.10.0"
"cpl-cli>=2022.12.0"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},

View File

@ -3,8 +3,8 @@
"Name": "cpl-query",
"Version": {
"Major": "2022",
"Minor": "10",
"Micro": "0.post2"
"Minor": "12",
"Micro": "0"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -16,10 +16,10 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl-core>=2022.10.0"
"cpl-core>=2022.12.0"
],
"DevDependencies": [
"cpl-cli>=2022.10.0"
"cpl-cli>=2022.12.0"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {

View File

@ -3,7 +3,7 @@
"Name": "set-pip-urls",
"Version": {
"Major": "2022",
"Minor": "6",
"Minor": "12",
"Micro": "0"
},
"Author": "Sven Heidemann",
@ -16,7 +16,7 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl-core>=2022.10.0"
"cpl-core>=2022.12.0"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},

View File

@ -1,6 +1,7 @@
import os
import traceback
from cpl_cli.configuration import ProjectSettings
from cpl_core.utils import String
from cpl_cli.configuration.version_settings_name_enum import VersionSettingsNameEnum
@ -45,51 +46,64 @@ class Application(ApplicationABC):
return
if len(args) == 1:
suffix = f'.{args[0]}'
suffix = args[0]
try:
branch = self._git_service.get_active_branch_name()
Console.write_line(f'Found branch: {branch}')
except Exception as e:
Console.error('Branch could not be found', traceback.format_exc())
Console.error('Branch not found', traceback.format_exc())
return
try:
if branch.startswith('#'):
self._configuration.add_json_file(self._workspace.projects[self._workspace.default_project], optional=False, output=False)
ps: ProjectSettings = self._configuration.get_configuration(ProjectSettings)
version[VersionSettingsNameEnum.major.value] = ps.version.major
version[VersionSettingsNameEnum.minor.value] = ps.version.minor
version[VersionSettingsNameEnum.micro.value] = f'dev{branch.split("#")[1]}'
else:
version[VersionSettingsNameEnum.major.value] = branch.split('.')[0]
version[VersionSettingsNameEnum.minor.value] = branch.split('.')[1]
if len(branch.split('.')) == 2:
version[VersionSettingsNameEnum.micro.value] = f'0{suffix}'
if suffix == '':
suffix = '0'
version[VersionSettingsNameEnum.micro.value] = f'{suffix}'
else:
branch_version = branch.split(".")[2]
if '-#' in branch_version:
branch_version = branch_version.split('-#')[0]
version[VersionSettingsNameEnum.micro.value] = f'{branch_version}{suffix}'
if not suffix.startswith('.') and suffix != '':
suffix = f'.{suffix}'
version[VersionSettingsNameEnum.micro.value] = f'{branch.split(".")[2]}{suffix}'
except Exception as e:
Console.error(f'Branch {branch} does not contain valid version')
return
diff_paths = []
for file in self._git_service.get_diff_files():
if file.startswith('tools'):
continue
if '/' in file:
diff_paths.append(file.split('/')[1])
file = file.split('/')[1]
else:
diff_paths.append(os.path.basename(os.path.dirname(file)))
file = os.path.basename(os.path.dirname(file))
if file in diff_paths:
continue
diff_paths.append(file)
try:
skipped = []
for project in self._workspace.projects:
if project not in diff_paths and String.convert_to_snake_case(project) not in diff_paths and not force:
Console.write_line(f'Skipping {project} due to missing changes')
# Console.write_line(f'Skipping {project} due to missing changes')
skipped.append(project)
continue
Console.write_line(f'Set dependencies {self._version_pipe.transform(version)} for {project}')
self._version_setter.set_dependencies(self._workspace.projects[project], version, 'Dependencies', skipped=skipped)
self._version_setter.set_dependencies(self._workspace.projects[project], version, 'DevDependencies', skipped=skipped)
if not project.startswith('cpl') and not project.startswith('unittest'):
Console.write_line(f'Skipping {project}')
continue
Console.write_line(f'Set version {self._version_pipe.transform(version)} for {project}')
self._version_setter.set_version(self._workspace.projects[project], version)

View File

@ -1,6 +1,7 @@
from git import Repo, DiffIndex
import os
from cpl_core.environment import ApplicationEnvironmentABC
from git import Repo
class GitService:

View File

@ -3,7 +3,7 @@
"Name": "set-version",
"Version": {
"Major": "2022",
"Minor": "7",
"Minor": "12",
"Micro": "0"
},
"Author": "Sven Heidemann",
@ -16,7 +16,7 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl-core>=2022.10.0",
"cpl-core>=2022.12.0",
"gitpython==3.1.27"
],
"PythonVersion": ">=3.10.4",

View File

@ -3,7 +3,7 @@
"Name": "unittests",
"Version": {
"Major": "2022",
"Minor": "10",
"Minor": "12",
"Micro": "0"
},
"Author": "",
@ -16,7 +16,7 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.10.0"
"cpl-core>=2022.12.0"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},

View File

@ -3,7 +3,7 @@
"Name": "unittest_cli",
"Version": {
"Major": "2022",
"Minor": "10",
"Minor": "12",
"Micro": "0"
},
"Author": "",
@ -16,8 +16,8 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.10.0",
"cpl-cli>=2022.10.0"
"cpl-core>=2022.12.0",
"cpl-cli>=2022.12.0"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},

View File

@ -3,7 +3,7 @@
"Name": "unittest_core",
"Version": {
"Major": "2022",
"Minor": "10",
"Minor": "12",
"Micro": "0"
},
"Author": "",
@ -16,7 +16,7 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.10.0"
"cpl-core>=2022.12.0"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},

View File

@ -3,7 +3,7 @@
"Name": "unittest_query",
"Version": {
"Major": "2022",
"Minor": "10",
"Minor": "12",
"Micro": "0"
},
"Author": "",
@ -16,8 +16,8 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.10.0",
"cpl-query>=2022.10.0"
"cpl-core>=2022.12.0",
"cpl-query>=2022.12.0"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},

View File

@ -3,7 +3,7 @@
"Name": "unittest_shared",
"Version": {
"Major": "2022",
"Minor": "10",
"Minor": "12",
"Micro": "0"
},
"Author": "",
@ -16,7 +16,7 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.10.0"
"cpl-core>=2022.12.0"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},

View File

@ -3,7 +3,7 @@
"Name": "unittests_translation",
"Version": {
"Major": "2022",
"Minor": "10",
"Minor": "12",
"Micro": "0"
},
"Author": "",
@ -16,11 +16,11 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.10.0",
"cpl-translation>=2022.10.0"
"cpl-core>=2022.12.0",
"cpl-translation>=2022.12.0"
],
"DevDependencies": [
"cpl-cli>=2022.10.0"
"cpl-cli>=2022.12.0"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},