Skip to content

Commit

Permalink
Add action to compare generated files against git repository
Browse files Browse the repository at this point in the history
  • Loading branch information
kvid committed Jul 20, 2020
1 parent d4feae6 commit 64f6507
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/wireviz/build_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

input_extensions = ['.yml']
generated_extensions = ['.gv', '.png', '.svg', '.html', '.bom.tsv']
extensions_not_from_graphviz = [ext for ext in generated_extensions if ext[-1] == 'v']
readme = 'readme.md'


Expand Down Expand Up @@ -86,6 +87,18 @@ def clean_examples():
os.remove(filename)


def compare_generated(include_from_graphviz = False):
compare_extensions = generated_extensions if include_from_graphviz else extensions_not_from_graphviz
for key, value in paths.items():
# collect files to compare
filename_list = collect_filenames('Comparing', key, compare_extensions, readme)
# compare files
for filename in filename_list:
cmd = f'git --no-pager diff {filename}'
print(f' {cmd}')
os.system(cmd)


def restore_generated():
for key, value in paths.items():
# collect input YAML files
Expand Down Expand Up @@ -119,6 +132,8 @@ def main():
build('tutorial', build_readme = True, include_source = True, include_readme = True)
elif args.action == 'clean':
clean_examples()
elif args.action == 'compare':
compare_generated()
elif args.action == 'restore':
restore_generated()

Expand Down

0 comments on commit 64f6507

Please sign in to comment.