Fossil SCM

Fix a memleak in manifest_crosslink() when hooks are activated (one uuid leaked per checkin manifest). When posting a chat-robot message for a forum post, add links to the artifact and user's timeline to that message (as is done for checkins.

stephan 2024-09-24 18:05 trunk
Commit 5fabb7ccb7d195c423cc7a0ed7c1283e3cdaae85256d8ba35e50fff552852507
2 files changed +8 -2 +7 -3
+8 -2
--- src/chat.c
+++ src/chat.c
@@ -1137,12 +1137,11 @@
11371137
);
11381138
fossil_free(zBranch);
11391139
fossil_free(zUuid);
11401140
}else if( zType[0]=='w' ){
11411141
/* Wiki page changes */
1142
- char *zUuid;
1143
- zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1142
+ char *zUuid = rid_to_uuid(rid);
11441143
wiki_hyperlink_override(zUuid);
11451144
if( zMsg[0]=='-' ){
11461145
zRes = mprintf("Delete wiki page <a href='%R/whistory?name=%t'>%h</a>",
11471146
zMsg+1, zMsg+1);
11481147
}else if( zMsg[0]=='+' ){
@@ -1155,10 +1154,17 @@
11551154
}else{
11561155
zRes = mprintf("%W", zMsg);
11571156
}
11581157
wiki_hyperlink_override(0);
11591158
fossil_free(zUuid);
1159
+ }else if( zType[0]=='f' ){
1160
+ /* Forum changes */
1161
+ char *zUuid = rid_to_uuid(rid);
1162
+ zRes = mprintf( "%W (artifact: <a href='%R/info/%S'>%S</a>, "
1163
+ "user: <a href='%R/timeline?u=%t&c=%S'>%h</a>)",
1164
+ zMsg, zUuid, zUuid, zUser, zUuid, zUser);
1165
+ fossil_free(zUuid);
11601166
}else{
11611167
/* Anything else */
11621168
zRes = mprintf("%W", zMsg);
11631169
}
11641170
if( zRes ){
11651171
--- src/chat.c
+++ src/chat.c
@@ -1137,12 +1137,11 @@
1137 );
1138 fossil_free(zBranch);
1139 fossil_free(zUuid);
1140 }else if( zType[0]=='w' ){
1141 /* Wiki page changes */
1142 char *zUuid;
1143 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1144 wiki_hyperlink_override(zUuid);
1145 if( zMsg[0]=='-' ){
1146 zRes = mprintf("Delete wiki page <a href='%R/whistory?name=%t'>%h</a>",
1147 zMsg+1, zMsg+1);
1148 }else if( zMsg[0]=='+' ){
@@ -1155,10 +1154,17 @@
1155 }else{
1156 zRes = mprintf("%W", zMsg);
1157 }
1158 wiki_hyperlink_override(0);
1159 fossil_free(zUuid);
 
 
 
 
 
 
 
1160 }else{
1161 /* Anything else */
1162 zRes = mprintf("%W", zMsg);
1163 }
1164 if( zRes ){
1165
--- src/chat.c
+++ src/chat.c
@@ -1137,12 +1137,11 @@
1137 );
1138 fossil_free(zBranch);
1139 fossil_free(zUuid);
1140 }else if( zType[0]=='w' ){
1141 /* Wiki page changes */
1142 char *zUuid = rid_to_uuid(rid);
 
1143 wiki_hyperlink_override(zUuid);
1144 if( zMsg[0]=='-' ){
1145 zRes = mprintf("Delete wiki page <a href='%R/whistory?name=%t'>%h</a>",
1146 zMsg+1, zMsg+1);
1147 }else if( zMsg[0]=='+' ){
@@ -1155,10 +1154,17 @@
1154 }else{
1155 zRes = mprintf("%W", zMsg);
1156 }
1157 wiki_hyperlink_override(0);
1158 fossil_free(zUuid);
1159 }else if( zType[0]=='f' ){
1160 /* Forum changes */
1161 char *zUuid = rid_to_uuid(rid);
1162 zRes = mprintf( "%W (artifact: <a href='%R/info/%S'>%S</a>, "
1163 "user: <a href='%R/timeline?u=%t&c=%S'>%h</a>)",
1164 zMsg, zUuid, zUuid, zUser, zUuid, zUser);
1165 fossil_free(zUuid);
1166 }else{
1167 /* Anything else */
1168 zRes = mprintf("%W", zMsg);
1169 }
1170 if( zRes ){
1171
+7 -3
--- src/manifest.c
+++ src/manifest.c
@@ -2334,11 +2334,11 @@
23342334
int i, rc = TH_OK;
23352335
Manifest *p;
23362336
int parentid = 0;
23372337
int permitHooks = (flags & MC_PERMIT_HOOKS);
23382338
const char *zScript = 0;
2339
- const char *zUuid = 0;
2339
+ char *zUuid = 0;
23402340
23412341
if( g.fSqlTrace ){
23422342
fossil_trace("-- manifest_crosslink(%d)\n", rid);
23432343
}
23442344
manifest_create_event_triggers();
@@ -2370,11 +2370,11 @@
23702370
}
23712371
db_begin_transaction();
23722372
if( p->type==CFTYPE_MANIFEST ){
23732373
if( permitHooks ){
23742374
zScript = xfer_commit_code();
2375
- zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
2375
+ zUuid = rid_to_uuid(rid);
23762376
}
23772377
if( p->nCherrypick && db_table_exists("repository","cherrypick") ){
23782378
int i;
23792379
for(i=0; i<p->nCherrypick; i++){
23802380
db_multi_exec(
@@ -2722,11 +2722,12 @@
27222722
branchMove = 0;
27232723
if( permitHooks && db_exists("SELECT 1 FROM event, blob"
27242724
" WHERE event.type='ci' AND event.objid=blob.rid"
27252725
" AND blob.uuid=%Q", zTagUuid) ){
27262726
zScript = xfer_commit_code();
2727
- zUuid = zTagUuid;
2727
+ fossil_free(zUuid);
2728
+ zUuid = fossil_strdup(zTagUuid);
27282729
}
27292730
}
27302731
zName = p->aTag[i].zName;
27312732
zValue = p->aTag[i].zValue;
27322733
if( strcmp(zName, "*branch")==0 ){
@@ -2805,10 +2806,12 @@
28052806
}
28062807
if( p->type==CFTYPE_FORUM ){
28072808
int froot, fprev, firt;
28082809
char *zFType;
28092810
char *zTitle;
2811
+
2812
+ assert( 0==zUuid );
28102813
schema_forum();
28112814
search_doc_touch('f', rid, 0);
28122815
froot = p->zThreadRoot ? uuid_to_rid(p->zThreadRoot, 1) : rid;
28132816
fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0;
28142817
firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0;
@@ -2877,10 +2880,11 @@
28772880
rc = xfer_run_common_script();
28782881
if( rc==TH_OK ){
28792882
rc = xfer_run_script(zScript, zUuid, 0);
28802883
}
28812884
}
2885
+ fossil_free(zUuid);
28822886
if( p->type==CFTYPE_MANIFEST ){
28832887
manifest_cache_insert(p);
28842888
}else{
28852889
manifest_destroy(p);
28862890
}
28872891
--- src/manifest.c
+++ src/manifest.c
@@ -2334,11 +2334,11 @@
2334 int i, rc = TH_OK;
2335 Manifest *p;
2336 int parentid = 0;
2337 int permitHooks = (flags & MC_PERMIT_HOOKS);
2338 const char *zScript = 0;
2339 const char *zUuid = 0;
2340
2341 if( g.fSqlTrace ){
2342 fossil_trace("-- manifest_crosslink(%d)\n", rid);
2343 }
2344 manifest_create_event_triggers();
@@ -2370,11 +2370,11 @@
2370 }
2371 db_begin_transaction();
2372 if( p->type==CFTYPE_MANIFEST ){
2373 if( permitHooks ){
2374 zScript = xfer_commit_code();
2375 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
2376 }
2377 if( p->nCherrypick && db_table_exists("repository","cherrypick") ){
2378 int i;
2379 for(i=0; i<p->nCherrypick; i++){
2380 db_multi_exec(
@@ -2722,11 +2722,12 @@
2722 branchMove = 0;
2723 if( permitHooks && db_exists("SELECT 1 FROM event, blob"
2724 " WHERE event.type='ci' AND event.objid=blob.rid"
2725 " AND blob.uuid=%Q", zTagUuid) ){
2726 zScript = xfer_commit_code();
2727 zUuid = zTagUuid;
 
2728 }
2729 }
2730 zName = p->aTag[i].zName;
2731 zValue = p->aTag[i].zValue;
2732 if( strcmp(zName, "*branch")==0 ){
@@ -2805,10 +2806,12 @@
2805 }
2806 if( p->type==CFTYPE_FORUM ){
2807 int froot, fprev, firt;
2808 char *zFType;
2809 char *zTitle;
 
 
2810 schema_forum();
2811 search_doc_touch('f', rid, 0);
2812 froot = p->zThreadRoot ? uuid_to_rid(p->zThreadRoot, 1) : rid;
2813 fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0;
2814 firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0;
@@ -2877,10 +2880,11 @@
2877 rc = xfer_run_common_script();
2878 if( rc==TH_OK ){
2879 rc = xfer_run_script(zScript, zUuid, 0);
2880 }
2881 }
 
2882 if( p->type==CFTYPE_MANIFEST ){
2883 manifest_cache_insert(p);
2884 }else{
2885 manifest_destroy(p);
2886 }
2887
--- src/manifest.c
+++ src/manifest.c
@@ -2334,11 +2334,11 @@
2334 int i, rc = TH_OK;
2335 Manifest *p;
2336 int parentid = 0;
2337 int permitHooks = (flags & MC_PERMIT_HOOKS);
2338 const char *zScript = 0;
2339 char *zUuid = 0;
2340
2341 if( g.fSqlTrace ){
2342 fossil_trace("-- manifest_crosslink(%d)\n", rid);
2343 }
2344 manifest_create_event_triggers();
@@ -2370,11 +2370,11 @@
2370 }
2371 db_begin_transaction();
2372 if( p->type==CFTYPE_MANIFEST ){
2373 if( permitHooks ){
2374 zScript = xfer_commit_code();
2375 zUuid = rid_to_uuid(rid);
2376 }
2377 if( p->nCherrypick && db_table_exists("repository","cherrypick") ){
2378 int i;
2379 for(i=0; i<p->nCherrypick; i++){
2380 db_multi_exec(
@@ -2722,11 +2722,12 @@
2722 branchMove = 0;
2723 if( permitHooks && db_exists("SELECT 1 FROM event, blob"
2724 " WHERE event.type='ci' AND event.objid=blob.rid"
2725 " AND blob.uuid=%Q", zTagUuid) ){
2726 zScript = xfer_commit_code();
2727 fossil_free(zUuid);
2728 zUuid = fossil_strdup(zTagUuid);
2729 }
2730 }
2731 zName = p->aTag[i].zName;
2732 zValue = p->aTag[i].zValue;
2733 if( strcmp(zName, "*branch")==0 ){
@@ -2805,10 +2806,12 @@
2806 }
2807 if( p->type==CFTYPE_FORUM ){
2808 int froot, fprev, firt;
2809 char *zFType;
2810 char *zTitle;
2811
2812 assert( 0==zUuid );
2813 schema_forum();
2814 search_doc_touch('f', rid, 0);
2815 froot = p->zThreadRoot ? uuid_to_rid(p->zThreadRoot, 1) : rid;
2816 fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0;
2817 firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0;
@@ -2877,10 +2880,11 @@
2880 rc = xfer_run_common_script();
2881 if( rc==TH_OK ){
2882 rc = xfer_run_script(zScript, zUuid, 0);
2883 }
2884 }
2885 fossil_free(zUuid);
2886 if( p->type==CFTYPE_MANIFEST ){
2887 manifest_cache_insert(p);
2888 }else{
2889 manifest_destroy(p);
2890 }
2891

Keyboard Shortcuts

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