This commit is contained in:
Avram Lubkin 2023-06-06 14:17:04 -04:00 коммит произвёл Avram Lubkin
Родитель 6832081e64
Коммит 63e3b11c58
6 изменённых файлов: 33 добавлений и 43 удалений

Просмотреть файл

@ -15,8 +15,8 @@ from comma.downstream.monitor import monitor_downstream
from comma.upstream import process_commits
from comma.util import config
from comma.util.spreadsheet import export_commits, import_commits, update_commits
from comma.util.symbols import print_missing_symbols
from comma.util.tracking import print_tracked_paths
from comma.util.symbols import get_hyperv_patch_symbols, symbol_checker
from comma.util.tracking import get_tracked_paths
LOGGER = logging.getLogger(__name__.split(".", 1)[0])
@ -33,17 +33,23 @@ def run(args):
session.add_all(config.default_distros)
if session.query(MonitoringSubjects).first() is None:
session.add_all(config.default_monitoring_subjects)
if args.section:
config.sections = args.section
if args.print_tracked_paths:
print_tracked_paths()
for path in get_tracked_paths():
print(path)
if args.upstream:
print("Monitoring upstream...")
LOGGER.info("Starting patch scraping from files...")
LOGGER.info("Begin monitoring upstream")
process_commits(add_to_database=True)
print("Finishing monitoring upstream!")
LOGGER.info("Finishing monitoring upstream")
if args.downstream:
LOGGER.info("Begin monitoring downstream")
monitor_downstream()
LOGGER.info("Finishing monitoring downstream")
def spreadsheet(args):
@ -96,6 +102,16 @@ def add_kernel(args):
LOGGER.info("Successfully added new revision '%s' for distro '%s'", args.revision, args.name)
def print_missing_symbols(symbol_file):
"""
Utility function for printing missing symbols
"""
LOGGER.info("Starting Symbol Checker")
get_hyperv_patch_symbols()
print(f"Missing symbols:\n{symbol_checker(symbol_file)}")
def get_cli_options(args: Optional[str] = None) -> argparse.Namespace:
"""
Parse CLI options and return a namespace
@ -266,9 +282,7 @@ def main(args: Optional[str] = None) -> None:
config.since = args.since
config.fetch = not args.no_fetch
print("Welcome to Commit Analyzer!")
args.func(args)
print("Commit Analyzer completed!")
if __name__ == "__main__":

Просмотреть файл

@ -248,7 +248,6 @@ def monitor_downstream():
Cycle through downstream remotes and search for missing commits
"""
print("Monitoring downstream...")
repo = get_linux_repo()
# Add repos as a remote if not already added
@ -288,5 +287,3 @@ def monitor_downstream():
remote_ref,
)
monitor_subject(subject, repo, local_ref)
print("Finished monitoring downstream!")

Просмотреть файл

@ -97,8 +97,8 @@ def process_commits(
repo = get_linux_repo()
if commit_ids is None:
# We use `--min-parents=1 --max-parents=1` to avoid both
# merges and graft commits.
# We use `--min-parents=1 --max-parents=1` to avoid both merges and graft commits.
LOGGER.info("Determining commits from tracked files")
commits = repo.iter_commits(
rev=revision,
paths=get_tracked_paths(),

Просмотреть файл

@ -85,19 +85,19 @@ def import_commits(in_file: str) -> None:
upstream monitoring logic.
"""
print(f"Sorry, importing is not supported at this time! filename: {in_file}")
LOGGER.error("Importing is not supported at this time! filename: %s", in_file)
sys.exit(1)
# TODO (Issue 55): Implement import from database
# to the database, and therefore affect untracked paths.
# from comma.upstream import process_commits
# print(f"Importing commits from spreadsheet '{in_file}'...")
# LOGGER.info(f"Importing commits from spreadsheet '{in_file}'...")
# workbook, worksheet = get_workbook(in_file)
# wb_commits = get_wb_commits(worksheet)
# db_commits = get_db_commits()
# missing_commits = wb_commits - db_commits.keys()
# print(f"Adding {len(missing_commits)} commits to database...")
# LOGGER.info(f"Adding {len(missing_commits)} commits to database...")
# process_commits(commit_ids=missing_commits, add_to_database=True)
# print("Finished importing!")
# LOGGER.info("Finished importing!")
def include_commit(sha: str, repo: git.Repo, base_commit: git.Commit) -> bool:
@ -187,12 +187,12 @@ def export_commits(in_file: str, out_file: str) -> None:
# Append each missing commit as a new row to the commits
# worksheet.
print(f"Exporting {len(missing_commits)} commits to {out_file}...")
LOGGER.info("Exporting %d commits to %s", len(missing_commits), out_file)
for commit in missing_commits:
worksheet.append(create_commit_row(commit, repo, worksheet))
workbook.save(out_file)
print("Finished exporting!")
LOGGER.info("Finished exporting!")
def get_distros() -> List[str]:
@ -251,7 +251,7 @@ def update_commits(in_file: str, out_file: str) -> None:
try:
get_column(worksheet, distro)
except StopIteration:
print(f"No column with distro '{distro}', please fix spreadsheet!")
LOGGER.ERROR(f"No column with distro '{distro}', please fix spreadsheet!")
sys.exit(1)
commit_column = get_column(worksheet, "Commit ID").column_letter
@ -275,4 +275,4 @@ def update_commits(in_file: str, out_file: str) -> None:
get_cell(worksheet, distro, commit_cell.row).value = "Unknown"
workbook.save(out_file)
print("Finished updating!")
LOGGER.info("Finished updating!")

Просмотреть файл

@ -81,7 +81,7 @@ def get_hyperv_patch_symbols():
This function clones upstream and gets upstream commits, hyperV files
"""
with DatabaseDriver.get_session() as session:
# Only annoying thing with SQLAlchemy is this always returns tuples need to be unwrapped.
# SQLAlchemy returns tuples which need to be unwrapped
map_symbols_to_patch(
[
commit[0]
@ -108,15 +108,3 @@ def symbol_checker(symbol_file):
.all()
if len(set(symbols.split(" ")) - symbols_in_file) > 0
)
def print_missing_symbols(symbol_file):
"""
Utility function for printing missing symbols
"""
print("Starting the Symbol Checker...")
get_hyperv_patch_symbols()
missing_symbols = symbol_checker(symbol_file)
print("Missing symbols:")
print(*missing_symbols)

Просмотреть файл

@ -193,15 +193,6 @@ def get_tracked_paths(sections=config.sections) -> List[str]:
return sorted(paths)
def print_tracked_paths():
"""
Utility function for printing tracked paths
"""
for path in get_tracked_paths():
print(path)
class GitProgressPrinter(git.RemoteProgress):
"""
Simple status printer for GitPython