/* This file is part of FediBlock-backend. * Copyright © 2020 tastytea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ #include "cgi.hpp" #include "files.hpp" #include "fs-compat.hpp" #include "git.hpp" #include "gitea.hpp" #include "json.hpp" #include "types.hpp" #include #include #include #include using std::cerr; using std::cout; using std::exception; using std::to_string; using namespace FediBlock; int main() { cout << "Content-Type: text/plain; charset=utf-8\r\n\r\n"; git_libgit2_init(); gitea::init(); try { const entry_type entry{cgi::parse_formdata()}; git::clone(); git::create_branch(); git::commit(entry); git::push(); gitea::pull_request(git::get_branch_name(), entry); cout << "Created pull request: <" << "https://schlomp.space/FediBlock/data/pulls/" << gitea::get_last_pr_number() << ">.\r\n"; files::remove_tmpdir(); } catch (const exception &e) { cerr << e.what() << '\n'; cout << "An error happened: " << e.what() << "\r\n"; cout << "Please report it at " ".\r\n"; } gitea::cleanup(); git_libgit2_shutdown(); return 0; }