75 lines
1.9 KiB
C++
75 lines
1.9 KiB
C++
/* This file is part of FediBlock-backend.
|
|
* Copyright © 2020 tastytea <tastytea@tastytea.de>
|
|
*
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "cgi.hpp"
|
|
#include "files.hpp"
|
|
#include "fs-compat.hpp"
|
|
#include "git.hpp"
|
|
#include "gitea.hpp"
|
|
#include "json.hpp"
|
|
#include "types.hpp"
|
|
|
|
#include <git2/global.h>
|
|
|
|
#include <exception>
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
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 "
|
|
"<https://schlomp.space/FediBlock/backend/issues>.\r\n";
|
|
}
|
|
|
|
gitea::cleanup();
|
|
git_libgit2_shutdown();
|
|
|
|
return 0;
|
|
}
|