Setup source fetching in main, setup logger format, basic workflow ready

This commit is contained in:
Xevion
2022-06-18 15:52:04 -05:00
parent 6e78e19963
commit d6e5b6a5c4

17
main.py
View File

@@ -6,14 +6,15 @@ from rich.logging import RichHandler
from database import Database from database import Database
from models import Commit 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(), RichHandler(),
TimedRotatingFileHandler(filename='recommit-log', backupCount=25) TimedRotatingFileHandler(filename='recommit-log', backupCount=25)
]) ])
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
sources = [Gitlab()] 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.""" """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.') logger.info('Starting recommit.')
sources: List[CommitSource] = [Gitlab()]
commits: List[Commit] = [] commits: List[Commit] = []
db = Database() 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: Fetch all commits from the available sources
# TODO: Check that the commit has been written # TODO: Check that the commit has been written
# TODO: Write commits into the git log # TODO: Write commits into the git log