From d6e5b6a5c4f42987625807625b08d4e0655c41cb Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 18 Jun 2022 15:52:04 -0500 Subject: [PATCH] Setup source fetching in main, setup logger format, basic workflow ready --- main.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 190e240..a12a0ac 100644 --- a/main.py +++ b/main.py @@ -6,14 +6,15 @@ from rich.logging import RichHandler from database import Database from models import Commit -from sources import Gitlab +from sources import CommitSource, Gitlab -logging.basicConfig(level=logging.WARNING, handlers=[ +logging.basicConfig(level=logging.WARNING, format='%(message)s', datefmt="[%X]", handlers=[ RichHandler(), TimedRotatingFileHandler(filename='recommit-log', backupCount=25) ]) logger = logging.getLogger(__name__) +logger.setLevel(logging.DEBUG) sources = [Gitlab()] @@ -21,9 +22,21 @@ def main() -> None: """The main method for this application. When executed, it will use all available sources and create commits to act as contributions.""" logger.info('Starting recommit.') + sources: List[CommitSource] = [Gitlab()] commits: List[Commit] = [] db = Database() + logger.debug(f'{len(sources)} sources available.') + logger.info('Ready.') + + for source in sources: + new_commits: List[Commit] = source.fetch(db.check_exists) + commits.extend(new_commits) + + logger.debug(f'{len(new_commits)} new commits from {source.name.upper()}.') + + logger.info(f'{len(commits)} commits found.') + # TODO: Fetch all commits from the available sources # TODO: Check that the commit has been written # TODO: Write commits into the git log