Fossil SCM
Define the "hooks" setting and mark it as sensitive.
Commit
23f95bfc06b7ebb07adbd79947f1c09d3330d14d638e37a4ba90b2dac393fe04
Parent
35da20b54099cf4…
1 file changed
+27
+27
| --- src/hook.c | ||
| +++ src/hook.c | ||
| @@ -39,10 +39,23 @@ | ||
| 39 | 39 | ** interpretation of the artifact. |
| 40 | 40 | */ |
| 41 | 41 | #include "config.h" |
| 42 | 42 | #include "hook.h" |
| 43 | 43 | |
| 44 | +/* | |
| 45 | +** SETTING: hooks sensitive | |
| 46 | +** The "hooks" setting contains JSON that describes all defined | |
| 47 | +** hooks. The value is an array of objects. Each object describes | |
| 48 | +** a single hook. Example: | |
| 49 | +** | |
| 50 | +** | |
| 51 | +** { | |
| 52 | +** "type": "after-receive", // type of hook | |
| 53 | +** "cmd": "command-to-run", // command to run | |
| 54 | +** "seq": 50 // run in this order | |
| 55 | +** } | |
| 56 | +*/ | |
| 44 | 57 | /* |
| 45 | 58 | ** List of valid hook types: |
| 46 | 59 | */ |
| 47 | 60 | static const char *azType[] = { |
| 48 | 61 | "after-receive", |
| @@ -476,10 +489,24 @@ | ||
| 476 | 489 | blob_reset(&chng); |
| 477 | 490 | hook_backoffice_done: |
| 478 | 491 | db_commit_transaction(); |
| 479 | 492 | return cnt; |
| 480 | 493 | } |
| 494 | + | |
| 495 | +/* | |
| 496 | +** Return true if one or more hooks of type zType exit. | |
| 497 | +*/ | |
| 498 | +int hook_exists(const char *zType){ | |
| 499 | + return db_exists( | |
| 500 | + "SELECT 1" | |
| 501 | + " FROM config, json_each(config.value) AS jx" | |
| 502 | + " WHERE config.name='hooks' AND json_valid(config.value)" | |
| 503 | + " AND json_extract(jx.value,'$.type')=%Q" | |
| 504 | + " ORDER BY json_extract(jx.value,'$.seq');", | |
| 505 | + zType | |
| 506 | + ); | |
| 507 | +} | |
| 481 | 508 | |
| 482 | 509 | /* |
| 483 | 510 | ** Run all hooks of type zType. Use zAuxFile as the auxiliary information |
| 484 | 511 | ** file. |
| 485 | 512 | ** |
| 486 | 513 |
| --- src/hook.c | |
| +++ src/hook.c | |
| @@ -39,10 +39,23 @@ | |
| 39 | ** interpretation of the artifact. |
| 40 | */ |
| 41 | #include "config.h" |
| 42 | #include "hook.h" |
| 43 | |
| 44 | /* |
| 45 | ** List of valid hook types: |
| 46 | */ |
| 47 | static const char *azType[] = { |
| 48 | "after-receive", |
| @@ -476,10 +489,24 @@ | |
| 476 | blob_reset(&chng); |
| 477 | hook_backoffice_done: |
| 478 | db_commit_transaction(); |
| 479 | return cnt; |
| 480 | } |
| 481 | |
| 482 | /* |
| 483 | ** Run all hooks of type zType. Use zAuxFile as the auxiliary information |
| 484 | ** file. |
| 485 | ** |
| 486 |
| --- src/hook.c | |
| +++ src/hook.c | |
| @@ -39,10 +39,23 @@ | |
| 39 | ** interpretation of the artifact. |
| 40 | */ |
| 41 | #include "config.h" |
| 42 | #include "hook.h" |
| 43 | |
| 44 | /* |
| 45 | ** SETTING: hooks sensitive |
| 46 | ** The "hooks" setting contains JSON that describes all defined |
| 47 | ** hooks. The value is an array of objects. Each object describes |
| 48 | ** a single hook. Example: |
| 49 | ** |
| 50 | ** |
| 51 | ** { |
| 52 | ** "type": "after-receive", // type of hook |
| 53 | ** "cmd": "command-to-run", // command to run |
| 54 | ** "seq": 50 // run in this order |
| 55 | ** } |
| 56 | */ |
| 57 | /* |
| 58 | ** List of valid hook types: |
| 59 | */ |
| 60 | static const char *azType[] = { |
| 61 | "after-receive", |
| @@ -476,10 +489,24 @@ | |
| 489 | blob_reset(&chng); |
| 490 | hook_backoffice_done: |
| 491 | db_commit_transaction(); |
| 492 | return cnt; |
| 493 | } |
| 494 | |
| 495 | /* |
| 496 | ** Return true if one or more hooks of type zType exit. |
| 497 | */ |
| 498 | int hook_exists(const char *zType){ |
| 499 | return db_exists( |
| 500 | "SELECT 1" |
| 501 | " FROM config, json_each(config.value) AS jx" |
| 502 | " WHERE config.name='hooks' AND json_valid(config.value)" |
| 503 | " AND json_extract(jx.value,'$.type')=%Q" |
| 504 | " ORDER BY json_extract(jx.value,'$.seq');", |
| 505 | zType |
| 506 | ); |
| 507 | } |
| 508 | |
| 509 | /* |
| 510 | ** Run all hooks of type zType. Use zAuxFile as the auxiliary information |
| 511 | ** file. |
| 512 | ** |
| 513 |