Add --force flag to rerun
This commit is contained in:
parent
032387d81c
commit
086fc2ff3e
16
README.md
16
README.md
@ -90,6 +90,22 @@ To sync repositories and generate a report once:
|
|||||||
python aocsync.py --once
|
python aocsync.py --once
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Force Rerun All Days
|
||||||
|
|
||||||
|
To force rerun all days even if repositories haven't changed:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python aocsync.py --once --force
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python aocsync.py --once --rerun-all
|
||||||
|
```
|
||||||
|
|
||||||
|
This is useful for refreshing all data or testing changes to the script.
|
||||||
|
|
||||||
### Continuous Polling
|
### Continuous Polling
|
||||||
|
|
||||||
To continuously poll repositories (default):
|
To continuously poll repositories (default):
|
||||||
|
|||||||
17
aocsync.py
17
aocsync.py
@ -907,11 +907,12 @@ class HTMLGenerator:
|
|||||||
class AOCSync:
|
class AOCSync:
|
||||||
"""Main synchronization orchestrator"""
|
"""Main synchronization orchestrator"""
|
||||||
|
|
||||||
def __init__(self, config_path: str = "config.yaml"):
|
def __init__(self, config_path: str = "config.yaml", force_rerun: bool = False):
|
||||||
self.config = Config(config_path)
|
self.config = Config(config_path)
|
||||||
self.db = Database(os.path.join(self.config.data_dir, 'results.db'))
|
self.db = Database(os.path.join(self.config.data_dir, 'results.db'))
|
||||||
self.html_gen = HTMLGenerator(self.config.output_dir)
|
self.html_gen = HTMLGenerator(self.config.output_dir)
|
||||||
self.git_manager = GitManager()
|
self.git_manager = GitManager()
|
||||||
|
self.force_rerun = force_rerun
|
||||||
|
|
||||||
def process_repository(self, repo_config: dict, user_name: str):
|
def process_repository(self, repo_config: dict, user_name: str):
|
||||||
"""Process a single repository configuration"""
|
"""Process a single repository configuration"""
|
||||||
@ -922,7 +923,10 @@ class AOCSync:
|
|||||||
url = repo_config['url']
|
url = repo_config['url']
|
||||||
local_path = repo_config['local_path']
|
local_path = repo_config['local_path']
|
||||||
|
|
||||||
if self.git_manager.has_changes(url, local_path):
|
if self.force_rerun or self.git_manager.has_changes(url, local_path):
|
||||||
|
if self.force_rerun:
|
||||||
|
logger.info(f"Force rerun enabled, processing repository {user_name}...")
|
||||||
|
else:
|
||||||
logger.info(f"Repository {user_name} has changes, updating...")
|
logger.info(f"Repository {user_name} has changes, updating...")
|
||||||
if self.git_manager.clone_or_update_repo(url, local_path):
|
if self.git_manager.clone_or_update_repo(url, local_path):
|
||||||
repo_path = Path(local_path)
|
repo_path = Path(local_path)
|
||||||
@ -963,7 +967,10 @@ class AOCSync:
|
|||||||
url = year_config['url']
|
url = year_config['url']
|
||||||
local_path = year_config['local_path']
|
local_path = year_config['local_path']
|
||||||
|
|
||||||
if self.git_manager.has_changes(url, local_path):
|
if self.force_rerun or self.git_manager.has_changes(url, local_path):
|
||||||
|
if self.force_rerun:
|
||||||
|
logger.info(f"Force rerun enabled, processing repository {user_name} year {year}...")
|
||||||
|
else:
|
||||||
logger.info(f"Repository {user_name} year {year} has changes, updating...")
|
logger.info(f"Repository {user_name} year {year} has changes, updating...")
|
||||||
if self.git_manager.clone_or_update_repo(url, local_path):
|
if self.git_manager.clone_or_update_repo(url, local_path):
|
||||||
repo_path = Path(local_path)
|
repo_path = Path(local_path)
|
||||||
@ -1034,10 +1041,12 @@ def main():
|
|||||||
parser = argparse.ArgumentParser(description='AOC Sync - Poll and compare AOC implementations')
|
parser = argparse.ArgumentParser(description='AOC Sync - Poll and compare AOC implementations')
|
||||||
parser.add_argument('--config', default='config.yaml', help='Path to config file')
|
parser.add_argument('--config', default='config.yaml', help='Path to config file')
|
||||||
parser.add_argument('--once', action='store_true', help='Run once instead of continuously')
|
parser.add_argument('--once', action='store_true', help='Run once instead of continuously')
|
||||||
|
parser.add_argument('--force', '--rerun-all', action='store_true', dest='force_rerun',
|
||||||
|
help='Force rerun all days even if repository has not changed')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
sync = AOCSync(args.config)
|
sync = AOCSync(args.config, force_rerun=args.force_rerun)
|
||||||
|
|
||||||
if args.once:
|
if args.once:
|
||||||
sync.sync_all()
|
sync.sync_all()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user