Skip to content

Commit

Permalink
Make commit message configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
jherbel committed May 13, 2024
1 parent d133151 commit 0413a61
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions checkmk_weblate_syncer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class PotModeConfig(BaseConfig, frozen=True):
Path, AfterValidator(_validate_path_is_relative)
]
locale_pot_path: Annotated[Path, AfterValidator(_validate_path_is_relative)]
commit_message: str


class PoFilePair(BaseModel, frozen=True):
Expand All @@ -39,3 +40,4 @@ class PoFilePair(BaseModel, frozen=True):

class PoModeConfig(BaseConfig, frozen=True):
po_file_pairs: Sequence[PoFilePair]
commit_message: str
7 changes: 4 additions & 3 deletions checkmk_weblate_syncer/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ def _repository_in_clean_state(path: Path, branch: str) -> Repo:

def commit_and_push_files(
repo: Repo,
files_to_push_to_repo: Sequence[Path],
files: Sequence[Path],
commit_message: str,
) -> None:
try:
repo.index.add(files_to_push_to_repo)
repo.index.commit("Updating files")
repo.index.add(files)
repo.index.commit(commit_message)
repo.remotes.origin.push()
except CalledProcessError as e:
LOGGER.error(
Expand Down
3 changes: 2 additions & 1 deletion checkmk_weblate_syncer/po.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def run(config: PoModeConfig) -> int:
LOGGER.info("Committing and pushing .po files to checkmk repository")
commit_and_push_files(
repo=checkmk_repo,
files_to_push_to_repo=[success.path for success in successes],
files=[success.path for success in successes],
commit_message=config.commit_message,
)
else:
LOGGER.info("No changes in checkmk repository.")
Expand Down
3 changes: 2 additions & 1 deletion checkmk_weblate_syncer/pot.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def run(config: PotModeConfig) -> int:
LOGGER.info("Committing and pushing pot file to locale repository")
commit_and_push_files(
repo=locale_repo,
files_to_push_to_repo=[path_pot_file],
files=[path_pot_file],
commit_message=config.commit_message,
)
return 0

0 comments on commit 0413a61

Please sign in to comment.