Added logic to change version only for projects with changes

This commit is contained in:
Sven Heidemann 2022-05-26 16:25:15 +02:00
parent ddff9dec11
commit def92c78c8
13 changed files with 34 additions and 26 deletions

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "6",
"Micro": "17.dev5"
"Micro": "17"
},
"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.6.17.dev5"
"cpl-core>=2022.6.17"
],
"PythonVersion": ">=3.10",
"PythonPath": {},

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "6",
"Micro": "17.dev5"
"Micro": "17"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "6",
"Micro": "17.dev5"
"Micro": "17"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -16,7 +16,7 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl-core>=2022.6.17.dev5"
"cpl-core>=2022.6.17"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},

View File

@ -1,3 +1,4 @@
import os
import traceback
from cpl_cli.configuration.version_settings_name_enum import VersionSettingsNameEnum
@ -27,6 +28,7 @@ class Application(ApplicationABC):
def main(self):
Console.write_line('Set versions:')
args = self._configuration.additional_arguments
version = {}
branch = ""
@ -53,8 +55,15 @@ class Application(ApplicationABC):
Console.error(f'Branch {branch} does not contain valid version')
return
diff_paths = []
for file in self._git_service.get_diff_files():
diff_paths.append(os.path.basename(os.path.dirname(file)))
try:
for project in self._workspace.projects:
if project not in diff_paths:
continue
Console.write_line(f'Set dependencies {self._version_pipe.transform(version)} for {project}')
self._version_setter.set_dependencies(self._workspace.projects[project], version)
if not project.startswith('cpl') and not project.startswith('unittest'):

View File

@ -1,4 +1,4 @@
import os
from git import Repo, DiffIndex
from cpl_core.environment import ApplicationEnvironmentABC
@ -7,12 +7,11 @@ class GitService:
def __init__(self, env: ApplicationEnvironmentABC):
self._env = env
self._repo = Repo(env.working_directory)
def get_active_branch_name(self) -> str:
head_dir = os.path.join(self._env.working_directory, '.git/HEAD')
with open(head_dir, 'r') as f:
content = f.read().splitlines()
branch = self._repo.active_branch
return branch.name
for line in content:
if line[0:4] == "ref:":
return line.partition("refs/heads/")[2]
def get_diff_files(self) -> list[str]:
return [item.a_path for item in self._repo.index.diff(None)]

View File

@ -16,7 +16,7 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl-core>=2022.6.17.dev5",
"cpl-core>=2022.6.17",
"gitpython==3.1.27"
],
"PythonVersion": ">=3.10.4",

View File

@ -25,7 +25,7 @@ class Startup(StartupABC):
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
services.add_pipes()
services.add_transient(GitService)
services.add_singleton(GitService)
services.add_transient(VersionSetterService)
return services.build_service_provider()

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "6",
"Micro": "17.dev5"
"Micro": "17.dev6"
},
"Author": "",
"AuthorEmail": "",
@ -16,7 +16,7 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.6.17.dev5"
"cpl-core>=2022.6.17.dev6"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "6",
"Micro": "17.dev5"
"Micro": "17.dev6"
},
"Author": "",
"AuthorEmail": "",
@ -16,8 +16,8 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.6.17.dev5",
"cpl-cli>=2022.6.17.dev5"
"cpl-core>=2022.6.17.dev6",
"cpl-cli>=2022.6.17.dev6"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "6",
"Micro": "17.dev5"
"Micro": "17.dev6"
},
"Author": "",
"AuthorEmail": "",
@ -16,7 +16,7 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.6.17.dev5"
"cpl-core>=2022.6.17.dev6"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "6",
"Micro": "17.dev5"
"Micro": "17.dev6"
},
"Author": "",
"AuthorEmail": "",
@ -16,8 +16,8 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.6.17.dev5",
"cpl-query>=2022.6.17.dev5"
"cpl-core>=2022.6.17.dev6",
"cpl-query>=2022.6.17.dev6"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "6",
"Micro": "17.dev5"
"Micro": "17.dev6"
},
"Author": "",
"AuthorEmail": "",
@ -16,7 +16,7 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.6.17.dev5"
"cpl-core>=2022.6.17.dev6"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {