Skip to content
Snippets Groups Projects
Commit 46ad8cc3 authored by s200545's avatar s200545
Browse files

Updated evaluation, and name fixes

parent 50f554a7
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,6 @@ How to run:
pdm run regit -vv --repo "C:\Users\boran\OneDrive\DTU\BSc Thesis\babyrepos\onlinebookstore" -o "C:\Users\boran\OneDrive\DTU\BSc Thesis\babyrepos\onlinebookstore_ast10" -p '**\*.java' -m mapping.csv -- formast --writeast --overwrite {}
pdm run python .\formast\commitdif.py -w "C:\Users\boran\OneDrive\DTU\BSc Thesis\babyrepos\onlinebookstore" output_nws.csv
pdm run python .\formast\commitdiff.py -w "C:\Users\boran\OneDrive\DTU\BSc Thesis\babyrepos\onlinebookstore" output_nws.csv
```
This diff is collapsed.
import csv
import git
import click
from tqdm import tqdm
@click.command()
@click.argument("repo")
@click.argument("output")
@click.option("-w","--ignore-all-space", is_flag=True, help="Ignore whitespace when comparing the parent commit and the current commit")
def main(repo, output, ignore_all_space):
# Open the output CSV file for writing
with open(output, "w") as f:
repo = git.Repo(repo)
writer = csv.writer(f)
# Write the header row
writer.writerow(["commit_hash", "num_additions", "num_deletions", "filename"])
# Loop through the commits and get the diff stats
for commit in tqdm(list(repo.iter_commits())):
if len(parrent := commit.parents) != 1:
continue
# Option to ignore-all-space
diff = repo.git.diff(parrent, commit, numstat=True, ignore_all_space=ignore_all_space)
for line in diff.splitlines():
num_additions, num_deletions, filename = line.split("\t")
writer.writerow([commit.hexsha, num_additions, num_deletions, filename])
if __name__ == "__main__":
main()
\ No newline at end of file
......@@ -31,6 +31,7 @@ JAVA_LANGUAGE = Language(str(language_file), 'java')
@click.option("--overwrite", is_flag=True, help="Overwrite the original .java file with the new content")
@click.option("-v", "--verbose", count=True, help="Increase output verbosity")
@click.argument("file_path", type=click.Path(exists=True))
## Formast
def formast(file_path, writetoken, writeast, writerelativeast, writecompast, overwrite, verbose):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment