Fossil SCM
Expand the 'fossil wiki export --technote' interface to support technote retrieval via tag name as discussed in the chat. The query looks to match against both 'sym-TAG' and 'TAG' as technote tags are presently prefixed with 'sym-'. This identifier should be reserved for branches, however, so may be removed from technotes, at which point this query should be changed.
Commit
d71b648c6ce92a7a3e8f5e0d8dce660e9ad09dff35ff3c649dd1773ef69ea510
Parent
04b725d9bf814fa…
2 files changed
+27
-5
+22
-1
+27
-5
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -2048,12 +2048,12 @@ | ||
| 2048 | 2048 | db_end_transaction(0); |
| 2049 | 2049 | return 1; |
| 2050 | 2050 | } |
| 2051 | 2051 | |
| 2052 | 2052 | /* |
| 2053 | -** Determine the rid for a tech note given either its id or its | |
| 2054 | -** timestamp. Returns 0 if there is no such item and -1 if the details | |
| 2053 | +** Determine the rid for a tech note given either its id, its timestamp, | |
| 2054 | +** or its tag. Returns 0 if there is no such item and -1 if the details | |
| 2055 | 2055 | ** are ambiguous and could refer to multiple items. |
| 2056 | 2056 | */ |
| 2057 | 2057 | int wiki_technote_to_rid(const char *zETime) { |
| 2058 | 2058 | int rid=0; /* Artifact ID of the tech note */ |
| 2059 | 2059 | int nETime = strlen(zETime); |
| @@ -2084,10 +2084,31 @@ | ||
| 2084 | 2084 | " AND tagid IS NOT NULL" |
| 2085 | 2085 | " ORDER BY objid DESC LIMIT 1", |
| 2086 | 2086 | zETime); |
| 2087 | 2087 | } |
| 2088 | 2088 | } |
| 2089 | + if( !rid ) { | |
| 2090 | + /* | |
| 2091 | + ** At present, technote tags are prefixed with 'sym-', which shouldn't | |
| 2092 | + ** be the case, so we check for both with and without the prefix until | |
| 2093 | + ** such time as tags have the errant prefix dropped. | |
| 2094 | + */ | |
| 2095 | + rid = db_int(0, "SELECT e.objid" | |
| 2096 | + " FROM event e, tag t, tagxref tx" | |
| 2097 | + " WHERE e.type='e'" | |
| 2098 | + " AND e.tagid IS NOT NULL" | |
| 2099 | + " AND e.objid IN" | |
| 2100 | + " (SELECT rid FROM tagxref" | |
| 2101 | + " WHERE tagid=(SELECT tagid FROM tag" | |
| 2102 | + " WHERE tagname GLOB '%q'))" | |
| 2103 | + " OR e.objid IN" | |
| 2104 | + " (SELECT rid FROM tagxref" | |
| 2105 | + " WHERE tagid=(SELECT tagid FROM tag" | |
| 2106 | + " WHERE tagname GLOB 'sym-%q'))" | |
| 2107 | + " ORDER BY e.mtime DESC LIMIT 1", | |
| 2108 | + zETime, zETime); | |
| 2109 | + } | |
| 2089 | 2110 | return rid; |
| 2090 | 2111 | } |
| 2091 | 2112 | |
| 2092 | 2113 | /* |
| 2093 | 2114 | ** COMMAND: wiki* |
| @@ -2095,24 +2116,25 @@ | ||
| 2095 | 2116 | ** Usage: %fossil wiki (export|create|commit|list) WikiName |
| 2096 | 2117 | ** |
| 2097 | 2118 | ** Run various subcommands to work with wiki entries or tech notes. |
| 2098 | 2119 | ** |
| 2099 | 2120 | ** > fossil wiki export ?OPTIONS? PAGENAME ?FILE? |
| 2100 | -** > fossil wiki export ?OPTIONS? -t|--technote DATETIME|TECHNOTE-ID ?FILE? | |
| 2121 | +** > fossil wiki export ?OPTIONS? -t|--technote DATETIME|TECHNOTE-ID|TAG ?FILE? | |
| 2101 | 2122 | ** |
| 2102 | 2123 | ** Sends the latest version of either a wiki page or of a tech |
| 2103 | 2124 | ** note to the given file or standard output. A filename of "-" |
| 2104 | 2125 | ** writes the output to standard output. The directory parts of |
| 2105 | 2126 | ** the output filename are created if needed. |
| 2106 | 2127 | ** If PAGENAME is provided, the named wiki page will be output. |
| 2107 | 2128 | ** |
| 2108 | 2129 | ** Options: |
| 2109 | -** -t|--technote DATETIME|TECHNOTE-ID | |
| 2130 | +** -t|--technote DATETIME|TECHNOTE-ID|TAG | |
| 2110 | 2131 | ** Specifies that a technote, rather than a wiki page, |
| 2111 | 2132 | ** will be exported. If DATETIME is used, the most |
| 2112 | 2133 | ** recently modified tech note with that DATETIME will |
| 2113 | -** output. | |
| 2134 | +** output. If TAG is used, the most recently modified | |
| 2135 | +** tech note with that TAG will be output. | |
| 2114 | 2136 | ** -h|--html The body (only) is rendered in HTML form, without |
| 2115 | 2137 | ** any page header/foot or HTML/BODY tag wrappers. |
| 2116 | 2138 | ** -H|--HTML Works like -h|-html but wraps the output in |
| 2117 | 2139 | ** <html><body>...</body></html>. |
| 2118 | 2140 | ** -p|--pre If -h|-H is used and the page or technote has |
| 2119 | 2141 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -2048,12 +2048,12 @@ | |
| 2048 | db_end_transaction(0); |
| 2049 | return 1; |
| 2050 | } |
| 2051 | |
| 2052 | /* |
| 2053 | ** Determine the rid for a tech note given either its id or its |
| 2054 | ** timestamp. Returns 0 if there is no such item and -1 if the details |
| 2055 | ** are ambiguous and could refer to multiple items. |
| 2056 | */ |
| 2057 | int wiki_technote_to_rid(const char *zETime) { |
| 2058 | int rid=0; /* Artifact ID of the tech note */ |
| 2059 | int nETime = strlen(zETime); |
| @@ -2084,10 +2084,31 @@ | |
| 2084 | " AND tagid IS NOT NULL" |
| 2085 | " ORDER BY objid DESC LIMIT 1", |
| 2086 | zETime); |
| 2087 | } |
| 2088 | } |
| 2089 | return rid; |
| 2090 | } |
| 2091 | |
| 2092 | /* |
| 2093 | ** COMMAND: wiki* |
| @@ -2095,24 +2116,25 @@ | |
| 2095 | ** Usage: %fossil wiki (export|create|commit|list) WikiName |
| 2096 | ** |
| 2097 | ** Run various subcommands to work with wiki entries or tech notes. |
| 2098 | ** |
| 2099 | ** > fossil wiki export ?OPTIONS? PAGENAME ?FILE? |
| 2100 | ** > fossil wiki export ?OPTIONS? -t|--technote DATETIME|TECHNOTE-ID ?FILE? |
| 2101 | ** |
| 2102 | ** Sends the latest version of either a wiki page or of a tech |
| 2103 | ** note to the given file or standard output. A filename of "-" |
| 2104 | ** writes the output to standard output. The directory parts of |
| 2105 | ** the output filename are created if needed. |
| 2106 | ** If PAGENAME is provided, the named wiki page will be output. |
| 2107 | ** |
| 2108 | ** Options: |
| 2109 | ** -t|--technote DATETIME|TECHNOTE-ID |
| 2110 | ** Specifies that a technote, rather than a wiki page, |
| 2111 | ** will be exported. If DATETIME is used, the most |
| 2112 | ** recently modified tech note with that DATETIME will |
| 2113 | ** output. |
| 2114 | ** -h|--html The body (only) is rendered in HTML form, without |
| 2115 | ** any page header/foot or HTML/BODY tag wrappers. |
| 2116 | ** -H|--HTML Works like -h|-html but wraps the output in |
| 2117 | ** <html><body>...</body></html>. |
| 2118 | ** -p|--pre If -h|-H is used and the page or technote has |
| 2119 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -2048,12 +2048,12 @@ | |
| 2048 | db_end_transaction(0); |
| 2049 | return 1; |
| 2050 | } |
| 2051 | |
| 2052 | /* |
| 2053 | ** Determine the rid for a tech note given either its id, its timestamp, |
| 2054 | ** or its tag. Returns 0 if there is no such item and -1 if the details |
| 2055 | ** are ambiguous and could refer to multiple items. |
| 2056 | */ |
| 2057 | int wiki_technote_to_rid(const char *zETime) { |
| 2058 | int rid=0; /* Artifact ID of the tech note */ |
| 2059 | int nETime = strlen(zETime); |
| @@ -2084,10 +2084,31 @@ | |
| 2084 | " AND tagid IS NOT NULL" |
| 2085 | " ORDER BY objid DESC LIMIT 1", |
| 2086 | zETime); |
| 2087 | } |
| 2088 | } |
| 2089 | if( !rid ) { |
| 2090 | /* |
| 2091 | ** At present, technote tags are prefixed with 'sym-', which shouldn't |
| 2092 | ** be the case, so we check for both with and without the prefix until |
| 2093 | ** such time as tags have the errant prefix dropped. |
| 2094 | */ |
| 2095 | rid = db_int(0, "SELECT e.objid" |
| 2096 | " FROM event e, tag t, tagxref tx" |
| 2097 | " WHERE e.type='e'" |
| 2098 | " AND e.tagid IS NOT NULL" |
| 2099 | " AND e.objid IN" |
| 2100 | " (SELECT rid FROM tagxref" |
| 2101 | " WHERE tagid=(SELECT tagid FROM tag" |
| 2102 | " WHERE tagname GLOB '%q'))" |
| 2103 | " OR e.objid IN" |
| 2104 | " (SELECT rid FROM tagxref" |
| 2105 | " WHERE tagid=(SELECT tagid FROM tag" |
| 2106 | " WHERE tagname GLOB 'sym-%q'))" |
| 2107 | " ORDER BY e.mtime DESC LIMIT 1", |
| 2108 | zETime, zETime); |
| 2109 | } |
| 2110 | return rid; |
| 2111 | } |
| 2112 | |
| 2113 | /* |
| 2114 | ** COMMAND: wiki* |
| @@ -2095,24 +2116,25 @@ | |
| 2116 | ** Usage: %fossil wiki (export|create|commit|list) WikiName |
| 2117 | ** |
| 2118 | ** Run various subcommands to work with wiki entries or tech notes. |
| 2119 | ** |
| 2120 | ** > fossil wiki export ?OPTIONS? PAGENAME ?FILE? |
| 2121 | ** > fossil wiki export ?OPTIONS? -t|--technote DATETIME|TECHNOTE-ID|TAG ?FILE? |
| 2122 | ** |
| 2123 | ** Sends the latest version of either a wiki page or of a tech |
| 2124 | ** note to the given file or standard output. A filename of "-" |
| 2125 | ** writes the output to standard output. The directory parts of |
| 2126 | ** the output filename are created if needed. |
| 2127 | ** If PAGENAME is provided, the named wiki page will be output. |
| 2128 | ** |
| 2129 | ** Options: |
| 2130 | ** -t|--technote DATETIME|TECHNOTE-ID|TAG |
| 2131 | ** Specifies that a technote, rather than a wiki page, |
| 2132 | ** will be exported. If DATETIME is used, the most |
| 2133 | ** recently modified tech note with that DATETIME will |
| 2134 | ** output. If TAG is used, the most recently modified |
| 2135 | ** tech note with that TAG will be output. |
| 2136 | ** -h|--html The body (only) is rendered in HTML form, without |
| 2137 | ** any page header/foot or HTML/BODY tag wrappers. |
| 2138 | ** -H|--HTML Works like -h|-html but wraps the output in |
| 2139 | ** <html><body>...</body></html>. |
| 2140 | ** -p|--pre If -h|-H is used and the page or technote has |
| 2141 |
+22
-1
| --- www/event.wiki | ||
| +++ www/event.wiki | ||
| @@ -43,10 +43,16 @@ | ||
| 43 | 43 | reporting as news. |
| 44 | 44 | |
| 45 | 45 | * <b>Announcements</b>. Changes to the composition of the development |
| 46 | 46 | team or acquisition of new project sponsors can be communicated as |
| 47 | 47 | announcements which can be implemented as technotes. |
| 48 | + | |
| 49 | + * <b>Signed Checksums</b>. Technotes containing cryptographically signed | |
| 50 | + checksums can be linked to repository artifacts, thereby creating a | |
| 51 | + traceable, auditable chain so that users can readily verify the integrity | |
| 52 | + and authenticity of project deliverables. And the command line interface | |
| 53 | + to technotes enables embedding such processes in scripts. | |
| 48 | 54 | |
| 49 | 55 | No project is required to use technotes. But technotes can help many projects |
| 50 | 56 | stay better organized and provide a better historical record of the |
| 51 | 57 | development progress. |
| 52 | 58 | |
| @@ -82,11 +88,11 @@ | ||
| 82 | 88 | Different technotes can have the same timestamp. |
| 83 | 89 | |
| 84 | 90 | The first argument to create, <b>TECHNOTE-COMMENT</b>, is the title text for the technote |
| 85 | 91 | that appears in the timeline. |
| 86 | 92 | |
| 87 | -To view technotes, use the <b>wiki ls</b> command: | |
| 93 | +To view all technotes, use the <b>wiki ls</b> command: | |
| 88 | 94 | |
| 89 | 95 | <blockquote> |
| 90 | 96 | <b> |
| 91 | 97 | fossil wiki ls --technote --show-technote-ids<br> |
| 92 | 98 | <tt>z739263a134bf0da1d28e939f4c4367f51ef4c51 2020-12-19 13:20:19</tt><br> |
| @@ -93,13 +99,28 @@ | ||
| 93 | 99 | <tt>e15a918a8bed71c2ac091d74dc397b8d3340d5e1 2018-09-22 17:40:10</tt><br> |
| 94 | 100 | </b> |
| 95 | 101 | </blockquote> |
| 96 | 102 | |
| 97 | 103 | A technote ID is the UUID of the technote. |
| 104 | + | |
| 105 | +To view an individual technote, use the <b>wiki export</b> command: | |
| 106 | + | |
| 107 | +<blockquote> | |
| 108 | +<b> | |
| 109 | +fossil wiki export --technote version-2.16<br> | |
| 110 | +Release Notes 2021-07-02 | |
| 111 | + | |
| 112 | +This note describes changes in the Fossil snapshot for ... | |
| 113 | +</b> | |
| 114 | +</blockquote> | |
| 115 | + | |
| 116 | +The <b>-t|--technote</b> option to the <b>export</b> subcommand takes one of | |
| 117 | +three identifiers: <b>DATETIME</b>; <b>TECHNOTE-ID</b>; and <b>TAG</b>. | |
| 118 | +See the [/help?cmd=wiki | wiki help] for specifics. | |
| 98 | 119 | |
| 99 | 120 | Users must have check-in privileges (permission "i") in order to |
| 100 | 121 | create or edit technotes. In addition, users must have create-wiki |
| 101 | 122 | privilege (permission "f") to create new technotes and edit-wiki |
| 102 | 123 | privilege (permission "k") in order to edit existing technotes. |
| 103 | 124 | |
| 104 | 125 | Technote content may be formatted as [/wiki_rules | Fossil wiki], |
| 105 | 126 | [/md_rules | Markdown], or a plain text. |
| 106 | 127 |
| --- www/event.wiki | |
| +++ www/event.wiki | |
| @@ -43,10 +43,16 @@ | |
| 43 | reporting as news. |
| 44 | |
| 45 | * <b>Announcements</b>. Changes to the composition of the development |
| 46 | team or acquisition of new project sponsors can be communicated as |
| 47 | announcements which can be implemented as technotes. |
| 48 | |
| 49 | No project is required to use technotes. But technotes can help many projects |
| 50 | stay better organized and provide a better historical record of the |
| 51 | development progress. |
| 52 | |
| @@ -82,11 +88,11 @@ | |
| 82 | Different technotes can have the same timestamp. |
| 83 | |
| 84 | The first argument to create, <b>TECHNOTE-COMMENT</b>, is the title text for the technote |
| 85 | that appears in the timeline. |
| 86 | |
| 87 | To view technotes, use the <b>wiki ls</b> command: |
| 88 | |
| 89 | <blockquote> |
| 90 | <b> |
| 91 | fossil wiki ls --technote --show-technote-ids<br> |
| 92 | <tt>z739263a134bf0da1d28e939f4c4367f51ef4c51 2020-12-19 13:20:19</tt><br> |
| @@ -93,13 +99,28 @@ | |
| 93 | <tt>e15a918a8bed71c2ac091d74dc397b8d3340d5e1 2018-09-22 17:40:10</tt><br> |
| 94 | </b> |
| 95 | </blockquote> |
| 96 | |
| 97 | A technote ID is the UUID of the technote. |
| 98 | |
| 99 | Users must have check-in privileges (permission "i") in order to |
| 100 | create or edit technotes. In addition, users must have create-wiki |
| 101 | privilege (permission "f") to create new technotes and edit-wiki |
| 102 | privilege (permission "k") in order to edit existing technotes. |
| 103 | |
| 104 | Technote content may be formatted as [/wiki_rules | Fossil wiki], |
| 105 | [/md_rules | Markdown], or a plain text. |
| 106 |
| --- www/event.wiki | |
| +++ www/event.wiki | |
| @@ -43,10 +43,16 @@ | |
| 43 | reporting as news. |
| 44 | |
| 45 | * <b>Announcements</b>. Changes to the composition of the development |
| 46 | team or acquisition of new project sponsors can be communicated as |
| 47 | announcements which can be implemented as technotes. |
| 48 | |
| 49 | * <b>Signed Checksums</b>. Technotes containing cryptographically signed |
| 50 | checksums can be linked to repository artifacts, thereby creating a |
| 51 | traceable, auditable chain so that users can readily verify the integrity |
| 52 | and authenticity of project deliverables. And the command line interface |
| 53 | to technotes enables embedding such processes in scripts. |
| 54 | |
| 55 | No project is required to use technotes. But technotes can help many projects |
| 56 | stay better organized and provide a better historical record of the |
| 57 | development progress. |
| 58 | |
| @@ -82,11 +88,11 @@ | |
| 88 | Different technotes can have the same timestamp. |
| 89 | |
| 90 | The first argument to create, <b>TECHNOTE-COMMENT</b>, is the title text for the technote |
| 91 | that appears in the timeline. |
| 92 | |
| 93 | To view all technotes, use the <b>wiki ls</b> command: |
| 94 | |
| 95 | <blockquote> |
| 96 | <b> |
| 97 | fossil wiki ls --technote --show-technote-ids<br> |
| 98 | <tt>z739263a134bf0da1d28e939f4c4367f51ef4c51 2020-12-19 13:20:19</tt><br> |
| @@ -93,13 +99,28 @@ | |
| 99 | <tt>e15a918a8bed71c2ac091d74dc397b8d3340d5e1 2018-09-22 17:40:10</tt><br> |
| 100 | </b> |
| 101 | </blockquote> |
| 102 | |
| 103 | A technote ID is the UUID of the technote. |
| 104 | |
| 105 | To view an individual technote, use the <b>wiki export</b> command: |
| 106 | |
| 107 | <blockquote> |
| 108 | <b> |
| 109 | fossil wiki export --technote version-2.16<br> |
| 110 | Release Notes 2021-07-02 |
| 111 | |
| 112 | This note describes changes in the Fossil snapshot for ... |
| 113 | </b> |
| 114 | </blockquote> |
| 115 | |
| 116 | The <b>-t|--technote</b> option to the <b>export</b> subcommand takes one of |
| 117 | three identifiers: <b>DATETIME</b>; <b>TECHNOTE-ID</b>; and <b>TAG</b>. |
| 118 | See the [/help?cmd=wiki | wiki help] for specifics. |
| 119 | |
| 120 | Users must have check-in privileges (permission "i") in order to |
| 121 | create or edit technotes. In addition, users must have create-wiki |
| 122 | privilege (permission "f") to create new technotes and edit-wiki |
| 123 | privilege (permission "k") in order to edit existing technotes. |
| 124 | |
| 125 | Technote content may be formatted as [/wiki_rules | Fossil wiki], |
| 126 | [/md_rules | Markdown], or a plain text. |
| 127 |