konveyor / kai

Konveyor AI - static code analysis driven migration to new targets via Generative AI
Apache License 2.0
23 stars 28 forks source link

:ghost: Remove static reports #319

Closed JonahSussman closed 2 weeks ago

JonahSussman commented 2 weeks ago

The static reports are clogging up the repo. Let's remove them.

You can verify that all the commits are correct by copying the following script in the project's root and running it:

import os
import itertools
import logging

logging.basicConfig(level=logging.INFO)
# logging.basicConfig(level=logging.DEBUG)  # uncomment to enable debug logging

MAIN_COMMIT = os.popen("git rev-parse main").read().strip()
logging.debug(f"MAIN_COMMIT: {MAIN_COMMIT}")

for i in itertools.count(0):
    # Get the commit hash of the commit i and i+1 commits ago
    this_commit = os.popen(f"git rev-parse HEAD~{i}").read().strip()
    prev_commit = os.popen(f"git rev-parse HEAD~{i+1}").read().strip()
    logging.debug(f"this_commit: {this_commit}")
    logging.debug(f"prev_commit: {prev_commit}")

    if this_commit == MAIN_COMMIT:
        break

    # Get the commit message of the commit
    commit_msg = os.popen(f"git log --pretty=format:%s -n 1 {this_commit}").read().strip()
    logging.debug(f"commit_msg: {commit_msg}")
    if commit_msg == "Removed static-report removal script":  # Skip this commit
        continue

    # Get the directory that was removed
    removed_directory = commit_msg.removeprefix("Removed ").removeprefix("/")
    logging.debug(f"removed_directory: {removed_directory}")

    # Get all the files that were deleted between prev_commit and this_commit
    deleted_files = os.popen(f"git diff --diff-filter=D --name-only {prev_commit}..{this_commit}").read().strip().split("\n")
    for deleted_file in deleted_files:
        if not deleted_file.startswith(removed_directory):
            logging.error(f"ERROR: File was deleted but not in the directory")
            logging.error(f"  - deleted_file:      {deleted_file}")
            logging.error(f"  - removed_directory: {removed_directory}")
            logging.error(f"  - startswith:        {deleted_file.startswith(removed_directory)}")
            exit(1)

logging.info("All files were deleted in the correct directory :-)")
dymurray commented 2 weeks ago

+1 this has also been a pain for me when the reports are modified and I have to checkout/stash all the changes