Fossil SCM
Added /json/tag/cancel.
Commit
0b685fcc0f2ef0952e1665c19cfce33664705bfe
Parent
bd9d7ce2f687387…
1 file changed
+40
-4
+40
-4
| --- src/json_tag.c | ||
| +++ src/json_tag.c | ||
| @@ -137,14 +137,50 @@ | ||
| 137 | 137 | |
| 138 | 138 | /* |
| 139 | 139 | ** Impl of /json/tag/cancel. |
| 140 | 140 | */ |
| 141 | 141 | static cson_value * json_tag_cancel(){ |
| 142 | - cson_value * payV = NULL; | |
| 143 | - cson_object * pay = NULL; | |
| 144 | - g.json.resultCode = FSL_JSON_E_NYI; | |
| 145 | - return payV; | |
| 142 | + char const * zName = NULL; | |
| 143 | + char const * zCheckin = NULL; | |
| 144 | + char fRaw = 0; | |
| 145 | + const char *zPrefix = NULL; | |
| 146 | + | |
| 147 | + if( !g.perm.Write ){ | |
| 148 | + json_set_err(FSL_JSON_E_DENIED, | |
| 149 | + "Requires 'i' permissions."); | |
| 150 | + return NULL; | |
| 151 | + } | |
| 152 | + | |
| 153 | + fRaw = json_find_option_bool("raw",NULL,NULL,0); | |
| 154 | + zPrefix = fRaw ? "" : "sym-"; | |
| 155 | + zName = json_find_option_cstr("name",NULL,NULL); | |
| 156 | + if(!zName || !*zName){ | |
| 157 | + if(!fossil_is_json()){ | |
| 158 | + zName = json_command_arg(3); | |
| 159 | + } | |
| 160 | + if(!zName || !*zName){ | |
| 161 | + json_set_err(FSL_JSON_E_MISSING_ARGS, | |
| 162 | + "'name' parameter is missing."); | |
| 163 | + return NULL; | |
| 164 | + } | |
| 165 | + } | |
| 166 | + | |
| 167 | + zCheckin = json_find_option_cstr("checkin",NULL,NULL); | |
| 168 | + if( !zCheckin ){ | |
| 169 | + if(!fossil_is_json()){ | |
| 170 | + zCheckin = json_command_arg(4); | |
| 171 | + } | |
| 172 | + if(!zCheckin || !*zCheckin){ | |
| 173 | + json_set_err(FSL_JSON_E_MISSING_ARGS, | |
| 174 | + "'checkin' parameter is missing."); | |
| 175 | + return NULL; | |
| 176 | + } | |
| 177 | + } | |
| 178 | + db_begin_transaction(); | |
| 179 | + tag_add_artifact(zPrefix, zName, zCheckin, NULL, 0, 0, 0); | |
| 180 | + db_end_transaction(0); | |
| 181 | + return NULL; | |
| 146 | 182 | } |
| 147 | 183 | |
| 148 | 184 | |
| 149 | 185 | /* |
| 150 | 186 | ** Impl of /json/tag/find. |
| 151 | 187 |
| --- src/json_tag.c | |
| +++ src/json_tag.c | |
| @@ -137,14 +137,50 @@ | |
| 137 | |
| 138 | /* |
| 139 | ** Impl of /json/tag/cancel. |
| 140 | */ |
| 141 | static cson_value * json_tag_cancel(){ |
| 142 | cson_value * payV = NULL; |
| 143 | cson_object * pay = NULL; |
| 144 | g.json.resultCode = FSL_JSON_E_NYI; |
| 145 | return payV; |
| 146 | } |
| 147 | |
| 148 | |
| 149 | /* |
| 150 | ** Impl of /json/tag/find. |
| 151 |
| --- src/json_tag.c | |
| +++ src/json_tag.c | |
| @@ -137,14 +137,50 @@ | |
| 137 | |
| 138 | /* |
| 139 | ** Impl of /json/tag/cancel. |
| 140 | */ |
| 141 | static cson_value * json_tag_cancel(){ |
| 142 | char const * zName = NULL; |
| 143 | char const * zCheckin = NULL; |
| 144 | char fRaw = 0; |
| 145 | const char *zPrefix = NULL; |
| 146 | |
| 147 | if( !g.perm.Write ){ |
| 148 | json_set_err(FSL_JSON_E_DENIED, |
| 149 | "Requires 'i' permissions."); |
| 150 | return NULL; |
| 151 | } |
| 152 | |
| 153 | fRaw = json_find_option_bool("raw",NULL,NULL,0); |
| 154 | zPrefix = fRaw ? "" : "sym-"; |
| 155 | zName = json_find_option_cstr("name",NULL,NULL); |
| 156 | if(!zName || !*zName){ |
| 157 | if(!fossil_is_json()){ |
| 158 | zName = json_command_arg(3); |
| 159 | } |
| 160 | if(!zName || !*zName){ |
| 161 | json_set_err(FSL_JSON_E_MISSING_ARGS, |
| 162 | "'name' parameter is missing."); |
| 163 | return NULL; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | zCheckin = json_find_option_cstr("checkin",NULL,NULL); |
| 168 | if( !zCheckin ){ |
| 169 | if(!fossil_is_json()){ |
| 170 | zCheckin = json_command_arg(4); |
| 171 | } |
| 172 | if(!zCheckin || !*zCheckin){ |
| 173 | json_set_err(FSL_JSON_E_MISSING_ARGS, |
| 174 | "'checkin' parameter is missing."); |
| 175 | return NULL; |
| 176 | } |
| 177 | } |
| 178 | db_begin_transaction(); |
| 179 | tag_add_artifact(zPrefix, zName, zCheckin, NULL, 0, 0, 0); |
| 180 | db_end_transaction(0); |
| 181 | return NULL; |
| 182 | } |
| 183 | |
| 184 | |
| 185 | /* |
| 186 | ** Impl of /json/tag/find. |
| 187 |