File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -398,7 +398,7 @@ public function getJsonData(): array
398398 }
399399
400400 foreach (Hooks::getValidHooks () as $ hook => $ value ) {
401- if ($ this ->hooks [$ hook ]->hasActions ()) {
401+ if ($ this ->hooks [$ hook ]->hasLocalActions ()) {
402402 $ data [$ hook ] = $ this ->hooks [$ hook ]->getJsonData ();
403403 }
404404 }
Original file line number Diff line number Diff line change @@ -96,6 +96,24 @@ public function hasActions(): bool
9696 return !empty ($ this ->actions );
9797 }
9898
99+ /**
100+ * Check if a hook config has local actions that were not loaded from other config files
101+ *
102+ * @return bool
103+ */
104+ public function hasLocalActions (): bool
105+ {
106+ if (!$ this ->hasActions ()) {
107+ return false ;
108+ }
109+ foreach ($ this ->actions as $ action ) {
110+ if (!$ action ->isIncluded ()) {
111+ return true ;
112+ }
113+ }
114+ return false ;
115+ }
116+
99117 /**
100118 * Add an action to the list
101119 *
Original file line number Diff line number Diff line change @@ -53,6 +53,27 @@ public function testAddAction(): void
5353 $ this ->assertCount (1 , $ config ['actions ' ]);
5454 }
5555
56+ public function testCanDetermineIfItHasActionsThatWereNotIncluded (): void
57+ {
58+ $ localAction = new Action ('\\Foo \\Bar ' );
59+ $ includedAction = new Action ('\\Foo \\Bar ' );
60+ $ includedAction ->markIncluded ();
61+
62+ $ hook = new Hook ('pre-commit ' );
63+ $ hook ->addAction ($ localAction , $ includedAction );
64+ $ this ->assertTrue ($ hook ->hasLocalActions ());
65+ }
66+
67+ public function testCanDetermineIfItHasIncludedActionsOnly (): void
68+ {
69+ $ includedAction = new Action ('\\Foo \\Bar ' );
70+ $ includedAction ->markIncluded ();
71+
72+ $ hook = new Hook ('pre-commit ' );
73+ $ hook ->addAction ($ includedAction );
74+ $ this ->assertFalse ($ hook ->hasLocalActions ());
75+ }
76+
5677 public function testAddMultiAction (): void
5778 {
5879 $ hook = new Hook ('pre-commit ' );
You can’t perform that action at this time.
0 commit comments