Skip to content

Commit 54422a7

Browse files
Add branch condition shorthands
1 parent d8d995f commit 54422a7

File tree

5 files changed

+60
-5
lines changed

5 files changed

+60
-5
lines changed

src/Hook/Condition/Branch/NotOn.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@
1818
use SebastianFeldmann\Git\Repository;
1919

2020
/**
21-
* NotOn condition
21+
* NotOn Branch condition
22+
*
23+
* Example configuration:
24+
* <code>
25+
* {
26+
* "action": "some-action",
27+
* "conditions": [
28+
* {
29+
* "exec": "CaptainHook.Status.NotOnBranch",
30+
* "args": ["not-on-this-branch"]
31+
* }
32+
* ]
33+
* }
34+
* </code>
2235
*
2336
* @package CaptainHook
2437
* @author Sebastian Feldmann <sf@sebastian-feldmann.info>

src/Hook/Condition/Branch/NotOnMatching.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@
1818
use SebastianFeldmann\Git\Repository;
1919

2020
/**
21-
* NotOnMatching condition
21+
* NotOnMatching Branch condition
22+
*
23+
* Example configuration:
24+
* <code>
25+
* {
26+
* "action": "some-action",
27+
* "conditions": [
28+
* {
29+
* "exec": "CaptainHook.Status.NotOnMatchingBranch",
30+
* "args": ["#^branches-names/not-matching[0-9]+-this-regex$#i"]
31+
* }
32+
* ]
33+
* }
34+
* </code>
2235
*
2336
* @package CaptainHook
2437
* @author Sebastian Feldmann <sf@sebastian-feldmann.info>

src/Hook/Condition/Branch/On.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@
1818
use SebastianFeldmann\Git\Repository;
1919

2020
/**
21-
* On condition
21+
* On Branch condition
22+
*
23+
* Example configuration:
24+
* <code>
25+
* {
26+
* "action": "some-action",
27+
* "conditions": [
28+
* {
29+
* "exec": "CaptainHook.Status.OnBranch",
30+
* "args": ["only-on-this-branch"]
31+
* }
32+
* ]
33+
* }
34+
* </code>
2235
*
2336
* @package CaptainHook
2437
* @author Sebastian Feldmann <sf@sebastian-feldmann.info>

src/Hook/Condition/Branch/OnMatching.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@
1818
use SebastianFeldmann\Git\Repository;
1919

2020
/**
21-
* OnMatching condition
21+
* OnMatching Branch condition
22+
*
23+
* Example configuration:
24+
* <code>
25+
* {
26+
* "action": "some-action",
27+
* "conditions": [
28+
* {
29+
* "exec": "CaptainHook.Status.OnMatchingBranch",
30+
* "args": ["#^branches-names/matching[0-9]+-this-regex$#i"]
31+
* }
32+
* ]
33+
* }
34+
* </code>
2235
*
2336
* @package CaptainHook
2437
* @author Sebastian Feldmann <sf@sebastian-feldmann.info>

src/Runner/Shorthand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ class Shorthand
7575
'thatis' => Hook\Condition\FileStaged\ThatIs::class,
7676
],
7777
'status' => [
78-
'onbranch' => Hook\Condition\Branch\On::class,
78+
'onbranch' => Hook\Condition\Branch\On::class,
79+
'onmatchingbranch' => Hook\Condition\Branch\OnMatching::class,
80+
'notonbranch' => Hook\Condition\Branch\NotOn::class,
81+
'notonmatchingbranch' => Hook\Condition\Branch\NotOnMatching::class,
7982
]
8083
]
8184
];

0 commit comments

Comments
 (0)