diff --git a/updatebot.py b/updatebot.py index 8edfe53..945d28d 100644 --- a/updatebot.py +++ b/updatebot.py @@ -224,19 +224,25 @@ class Arguments: projects: list[str] -def update_project(repo: git.Repo, name: str, project: Project) -> git.Commit: +def update_project( + repo: git.Repo, name: str, project: Project +) -> Optional[git.Commit]: basedir = Path(repo.working_dir) log.debug('Checking for latest version of %s', name) latest = project.source.get_latest_version() log.info('Found version %s for %s', latest, name) log.debug('Applying update for %s version %s', name, latest) path = basedir / (project.path or name) - log.debug('Committing changes to %s', path) project.apply_update(path, latest) - repo.index.add(str(path)) - c = repo.index.commit(f'{name}: Update to {latest}') - log.info('Commited %s %s', str(c)[:7], c.summary) - return c + if repo.index.diff(None): + log.debug('Committing changes to %s', path) + repo.index.add(str(path)) + c = repo.index.commit(f'{name}: Update to {latest}') + log.info('Commited %s %s', str(c)[:7], c.summary) + return c + else: + log.info('No changes to commit') + return None def parse_args() -> Arguments: @@ -309,7 +315,7 @@ def main() -> None: title = None for project in projects: commit = update_project(repo, project, config.projects[project]) - if not title: + if commit and not title: if not isinstance(commit.summary, str): title = bytes(commit.summary).decode( 'utf-8', errors='replace' @@ -317,6 +323,7 @@ def main() -> None: else: title = commit.summary if not title: + log.info('No changes made') return repo.head.reference.set_tracking_branch( git.RemoteReference(