Fossil SCM

Define the "hooks" setting and mark it as sensitive.

drh 2020-08-28 18:38 trunk
Commit 23f95bfc06b7ebb07adbd79947f1c09d3330d14d638e37a4ba90b2dac393fe04
1 file changed +27
+27
--- src/hook.c
+++ src/hook.c
@@ -39,10 +39,23 @@
3939
** interpretation of the artifact.
4040
*/
4141
#include "config.h"
4242
#include "hook.h"
4343
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
+*/
4457
/*
4558
** List of valid hook types:
4659
*/
4760
static const char *azType[] = {
4861
"after-receive",
@@ -476,10 +489,24 @@
476489
blob_reset(&chng);
477490
hook_backoffice_done:
478491
db_commit_transaction();
479492
return cnt;
480493
}
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
+}
481508
482509
/*
483510
** Run all hooks of type zType. Use zAuxFile as the auxiliary information
484511
** file.
485512
**
486513
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button