MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / assertSameTask

Method assertSameTask

src/Hooks.cpp:407–433  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

405
406////////////////////////////////////////////////////////////////////////////////
407void Hooks::assertSameTask(const std::vector<std::string>& input, const Task& task,
408 const std::string& script) const {
409 std::string uuid = task.get("uuid");
410
411 for (auto& i : input) {
412 auto root_obj = (json::object*)json::parse(i);
413
414 // If there is no UUID at all.
415 auto u = root_obj->_data.find("uuid");
416 if (u == root_obj->_data.end() || u->second->type() != json::j_string) {
417 Context::getContext().error(format(STRING_HOOK_ERROR_SAME1, uuid, Path(script).name()));
418 throw 0;
419 }
420
421 auto up = (json::string*)u->second;
422 auto text = up->dump();
423 Lexer::dequote(text);
424 std::string json_uuid = json::decode(text);
425 if (json_uuid != uuid) {
426 Context::getContext().error(
427 format(STRING_HOOK_ERROR_SAME2, uuid, json_uuid, Path(script).name()));
428 throw 0;
429 }
430
431 delete root_obj;
432 }
433}
434
435////////////////////////////////////////////////////////////////////////////////
436void Hooks::assertFeedback(const std::vector<std::string>& input, const std::string& script) const {

Callers

nothing calls this directly

Calls 5

findMethod · 0.80
typeMethod · 0.80
errorMethod · 0.80
getMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected