static const std::string REPO(const kul::Dir& d, const std::string& r){ if(INSTANCE().valids.count(d.path())) return (*INSTANCE().valids.find(d.path())).second; if(IS_SOLID(r)) INSTANCE().valids.insert(d.path(), r); else GET_SCM(d, r); if(INSTANCE().valids.count(d.path())) return (*INSTANCE().valids.find(d.path())).second; KEXCEPT(Exception, "SCM not discovered for project: "+d.path()); }
static const kul::SCM* GET_SCM(const kul::Dir& d, const std::string& r){ std::vector<std::string> repos; if(IS_SOLID(r)) repos.push_back(r); else for(const std::string& s : Settings::INSTANCE().remoteRepos()) repos.push_back(s + r); for(const auto& repo : repos){ try{ kul::Process g("git"); kul::ProcessCapture gp(g); std::string r1(repo); if(repo.find("http") != std::string::npos && repo.find("@") == std::string::npos) r1 = repo.substr(0, repo.find("//") + 2) + "u:p@" + repo.substr(repo.find("//") + 2); g.arg("ls-remote").arg(r1).start(); if(!gp.errs().size()) { INSTANCE().valids.insert(d.path(), repo); return &kul::scm::Manager::INSTANCE().get("git"); } }catch(const kul::proc::ExitException& e){} try{ kul::Process s("svn"); kul::ProcessCapture sp(s); s.arg("ls").arg(repo).start(); if(!sp.errs().size()) { INSTANCE().valids.insert(d.path(), repo); return &kul::scm::Manager::INSTANCE().get("svn"); } }catch(const kul::proc::ExitException& e){} } std::stringstream ss; for(const auto& s : repos) ss << s << "\n"; KEXCEPT(Exception, "SCM not found or not supported type(git/svn) for repo(s)\n"+ss.str()+"project:"+d.path()); }
int map_is_solid (int m, int x, int y) { return (IS_SOLID (map_getcell (m, x, y))); }
static const kul::SCM* GET(const kul::Dir& d, const std::string& r){ if(IS_SOLID(r)) INSTANCE().valids.insert(d.path(), r); if(kul::Dir(d.join(".git"))) return &kul::scm::Manager::INSTANCE().get("git"); if(kul::Dir(d.join(".svn"))) return &kul::scm::Manager::INSTANCE().get("svn"); return r.size() ? GET_SCM(d, r) : 0; }