From 02e57b65957e53a15a42ea575730e05284d8f20c Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Fri, 8 Mar 2024 17:21:35 +0100 Subject: [PATCH 1/2] Make Graphviz output more deterministic --- git_big_picture/_main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git_big_picture/_main.py b/git_big_picture/_main.py index 1f8811e..bfead4a 100755 --- a/git_big_picture/_main.py +++ b/git_big_picture/_main.py @@ -1036,7 +1036,7 @@ def label_gen(): if history_direction is not None: rankdir = RANKDIR_OF_HISTORY_DIRECTION[history_direction] dot_file_lines.append(f'\trankdir="{rankdir}";') - for sha_one, labels, color in label_gen(): + for sha_one, labels, color in sorted(label_gen()): label = '\\n'.join(labels + ((with_commit_messages or sha_ones_on_labels) and [ format_label(sha_one), ] or list())) @@ -1051,7 +1051,7 @@ def label_gen(): sha_label = format_label(sha_one) dot_file_lines.append(f'\t"{sha_one}"[label="{sha_label}"];') for child, self.parents in self.parents.items(): - for p in self.parents: + for p in sorted(self.parents): dot_file_lines.append(f'\t"{child}" -> "{p}";') dot_file_lines.append('}') return dot_file_lines From 325c7e0484b7ac67cf38b619e0f8152d8fcd6751 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Fri, 8 Mar 2024 18:07:05 +0100 Subject: [PATCH 2/2] run-tests-with-coverage.sh: Smoke-test for determinism --- run-tests-with-coverage.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/run-tests-with-coverage.sh b/run-tests-with-coverage.sh index 0d04ef7..854f1c0 100755 --- a/run-tests-with-coverage.sh +++ b/run-tests-with-coverage.sh @@ -68,6 +68,22 @@ except ImportError: pass SITECUSTOMIZE_PY_EOF +# Run smoke-test for determinism with real Git history; +# these modes are opposites of FILTER_DEFAULTS in _main.py . +for mode in \ + --all \ + --no-branches \ + --no-tags \ + --no-roots \ + --merges \ + --bifurcations \ + --commit-messages \ + ; do + git-big-picture --graphviz "${mode}" "${source_dir}" > 1.dot + git-big-picture --graphviz "${mode}" "${source_dir}" > 2.dot + diff -U 0 1.dot 2.dot # i.e. fail if there is any diff + rm 1.dot 2.dot +done # Actually run the tests exit_code=0