| 2816 | } |
| 2817 | |
| 2818 | int64_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 | |
| 2857 | int64_t Git::run(String repoPath, String command, const std::function<void(String)>& callback, String optionsJSON) { |
| 2858 | #ifdef DORA_NO_WA |
nothing calls this directly
no test coverage detected