aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntonin Delpeuch <antonin@delpeuch.eu>2023-09-20 10:45:10 +0200
committerAntonin Delpeuch <antonin@delpeuch.eu>2023-09-22 13:32:26 +0200
commita31c37c07ba6ccd093961fb5b7aec252f2851008 (patch)
tree8cc9d333b7987f0ae23c912c1a43dfce59f5d3ca
parent669a4cbf3580d6300a32391a634c3d10b4e3432a (diff)
downloadgit-deps-a31c37c07ba6ccd093961fb5b7aec252f2851008.tar.gz
Fix deps fetching on the root commit
Closes #125.
-rw-r--r--git_deps/detector.py6
-rw-r--r--tests/expected_outputs/recursive_deps_4f27a1e29
-rwxr-xr-xtests/self_test.sh8
3 files changed, 38 insertions, 5 deletions
diff --git a/git_deps/detector.py b/git_deps/detector.py
index ce73762..1836a56 100644
--- a/git_deps/detector.py
+++ b/git_deps/detector.py
@@ -118,8 +118,10 @@ class DependencyDetector(object):
self.notify_listeners('new_commit', dependent)
- parent = dependent.parents[0]
- self.find_dependencies_with_parent(dependent, parent)
+ if dependent.parents: # the root commit does not have parents
+ parent = dependent.parents[0]
+ self.find_dependencies_with_parent(dependent, parent)
+
self.done.append(dependent_sha1)
self.done_d[dependent_sha1] = True
self.logger.info(" Found all dependencies for %s" %
diff --git a/tests/expected_outputs/recursive_deps_4f27a1e b/tests/expected_outputs/recursive_deps_4f27a1e
new file mode 100644
index 0000000..087137c
--- /dev/null
+++ b/tests/expected_outputs/recursive_deps_4f27a1e
@@ -0,0 +1,29 @@
+2a05400e232e14f0d4c1cbfb548a0871ea57bd44 3374b8419a45d91d3c0631be11c8cf893b272217
+2a05400e232e14f0d4c1cbfb548a0871ea57bd44 b144bfd5feb327ef7ce0c26bbfb6f4da573abfe5
+2ebcb2b6081e32e9a463519525bd432287b24520 3a1dd42fd6114a634ba7cf037ce61e2aee76db73
+2ebcb2b6081e32e9a463519525bd432287b24520 acc24a404d82061bbc6db5afb146d83bf131830b
+3374b8419a45d91d3c0631be11c8cf893b272217 3a1dd42fd6114a634ba7cf037ce61e2aee76db73
+3374b8419a45d91d3c0631be11c8cf893b272217 b144bfd5feb327ef7ce0c26bbfb6f4da573abfe5
+3374b8419a45d91d3c0631be11c8cf893b272217 b1967573e81a8100a4cc778936de0ba0a8a8f5cb
+3a1dd42fd6114a634ba7cf037ce61e2aee76db73 b144bfd5feb327ef7ce0c26bbfb6f4da573abfe5
+3a1dd42fd6114a634ba7cf037ce61e2aee76db73 b1967573e81a8100a4cc778936de0ba0a8a8f5cb
+4f27a1ee2b5fd63a58311a20e2aed0a24eda8da2 3374b8419a45d91d3c0631be11c8cf893b272217
+4f27a1ee2b5fd63a58311a20e2aed0a24eda8da2 3a1dd42fd6114a634ba7cf037ce61e2aee76db73
+4f27a1ee2b5fd63a58311a20e2aed0a24eda8da2 5ec5ccbdff508014c61ae9d18f3366a15c0f2689
+4f27a1ee2b5fd63a58311a20e2aed0a24eda8da2 80c247fd21a1e7f476d1c8ba289498e216eff3dc
+4f27a1ee2b5fd63a58311a20e2aed0a24eda8da2 b144bfd5feb327ef7ce0c26bbfb6f4da573abfe5
+4f27a1ee2b5fd63a58311a20e2aed0a24eda8da2 b1967573e81a8100a4cc778936de0ba0a8a8f5cb
+4f27a1ee2b5fd63a58311a20e2aed0a24eda8da2 f7bf058439fd7499aad7a10418a9f516e6949fbc
+5ec5ccbdff508014c61ae9d18f3366a15c0f2689 3374b8419a45d91d3c0631be11c8cf893b272217
+5ec5ccbdff508014c61ae9d18f3366a15c0f2689 b144bfd5feb327ef7ce0c26bbfb6f4da573abfe5
+80c247fd21a1e7f476d1c8ba289498e216eff3dc 2ebcb2b6081e32e9a463519525bd432287b24520
+80c247fd21a1e7f476d1c8ba289498e216eff3dc 3a1dd42fd6114a634ba7cf037ce61e2aee76db73
+80c247fd21a1e7f476d1c8ba289498e216eff3dc acc24a404d82061bbc6db5afb146d83bf131830b
+80c247fd21a1e7f476d1c8ba289498e216eff3dc b1967573e81a8100a4cc778936de0ba0a8a8f5cb
+acc24a404d82061bbc6db5afb146d83bf131830b 3a1dd42fd6114a634ba7cf037ce61e2aee76db73
+acc24a404d82061bbc6db5afb146d83bf131830b b144bfd5feb327ef7ce0c26bbfb6f4da573abfe5
+b144bfd5feb327ef7ce0c26bbfb6f4da573abfe5 b1967573e81a8100a4cc778936de0ba0a8a8f5cb
+f7bf058439fd7499aad7a10418a9f516e6949fbc 2a05400e232e14f0d4c1cbfb548a0871ea57bd44
+f7bf058439fd7499aad7a10418a9f516e6949fbc 80c247fd21a1e7f476d1c8ba289498e216eff3dc
+f7bf058439fd7499aad7a10418a9f516e6949fbc b144bfd5feb327ef7ce0c26bbfb6f4da573abfe5
+f7bf058439fd7499aad7a10418a9f516e6949fbc b1967573e81a8100a4cc778936de0ba0a8a8f5cb
diff --git a/tests/self_test.sh b/tests/self_test.sh
index c2ddfb1..a0b2272 100755
--- a/tests/self_test.sh
+++ b/tests/self_test.sh
@@ -16,8 +16,10 @@ git-deps 4f27a1e^! | sort | diff tests/expected_outputs/deps_4f27a1e -
echo "* Dependencies of 1ba7ad5, a merge commit"
git-deps 1ba7ad5^! | sort | diff tests/expected_outputs/deps_1ba7ad5 -
-# Currently failing:
-#echo "* Dependencies of the root commit"
-# git-deps b196757^! | sort # | diff tests/expected_outputs/deps_b196757 -
+echo "* Dependencies of the root commit"
+git-deps b196757^! | sort | diff tests/expected_outputs/deps_b196757 -
+
+echo "* Recursive dependencies of a4f27a1e, a regular commit"
+git-deps -r 4f27a1e^! | sort | diff tests/expected_outputs/recursive_deps_4f27a1e -
echo "All tests passed!"