MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / runJob

Method runJob

Source/Wasm/WasmRuntime.cpp:2818–2855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2816}
2817
2818int64_t Git::runJob(int64_t jobId, String path, String kind, const std::function<void(String)>& callback) {
2819 if (jobId == 0) {
2820 callback(fmt::format(
2821 "{{\"id\":0,\"state\":\"error\",\"kind\":\"{}\",\"error\":\"failed to start git job\"}}",
2822 EscapeJsonString(kind.toString())));
2823 return 0;
2824 }
2825 std::string repoPath = path.toString();
2826 handles()[jobId] = GitHandle{jobId, repoPath, kind.toString(), callback, std::string()};
2827 SharedDirector.getSystemScheduler()->schedule([jobId](double) {
2828 auto& gitHandles = handles();
2829 auto it = gitHandles.find(jobId);
2830 if (it == gitHandles.end()) {
2831 return true;
2832 }
2833 std::string status = poll(jobId);
2834 it = gitHandles.find(jobId);
2835 if (it == gitHandles.end()) {
2836 return true;
2837 }
2838 bool isTerminal = IsGitTerminalStatus(status);
2839 if (status != it->second.lastStatus || isTerminal) {
2840 it->second.lastStatus = status;
2841 it->second.callback(status);
2842 it = gitHandles.find(jobId);
2843 if (it == gitHandles.end()) {
2844 return true;
2845 }
2846 }
2847 if (isTerminal) {
2848 dispose(jobId);
2849 gitHandles.erase(jobId);
2850 return true;
2851 }
2852 return false;
2853 });
2854 return jobId;
2855}
2856
2857int64_t Git::run(String repoPath, String command, const std::function<void(String)>& callback, String optionsJSON) {
2858#ifdef DORA_NO_WA

Callers

nothing calls this directly

Calls 13

EscapeJsonStringFunction · 0.85
stringFunction · 0.85
IsGitTerminalStatusFunction · 0.85
disposeFunction · 0.85
getSystemSchedulerMethod · 0.80
callbackMethod · 0.80
toStringMethod · 0.65
findMethod · 0.65
formatFunction · 0.50
pollFunction · 0.50
scheduleMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected