2020-07-01 03:51:00 +02:00
|
|
|
/* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FEDIBLOCK_BACKEND_GIT_HPP
|
|
|
|
#define FEDIBLOCK_BACKEND_GIT_HPP
|
|
|
|
|
2020-07-01 08:48:36 +02:00
|
|
|
#include "cgi.hpp"
|
|
|
|
|
2020-07-01 10:18:53 +02:00
|
|
|
#include <git2.h>
|
|
|
|
|
2020-07-01 03:51:00 +02:00
|
|
|
#include <cstdint>
|
2020-07-02 03:20:27 +02:00
|
|
|
#include <string>
|
2020-07-01 03:51:00 +02:00
|
|
|
|
2020-07-01 08:50:16 +02:00
|
|
|
namespace FediBlock::git
|
2020-07-01 03:51:00 +02:00
|
|
|
{
|
|
|
|
|
2020-07-02 03:20:27 +02:00
|
|
|
using std::string;
|
2020-07-01 03:51:00 +02:00
|
|
|
using std::uint64_t;
|
|
|
|
|
2020-07-02 03:20:27 +02:00
|
|
|
// Throw runtime_error on error.
|
2020-07-01 08:55:13 +02:00
|
|
|
void check(int error);
|
2020-07-01 04:38:08 +02:00
|
|
|
|
2020-07-01 10:18:53 +02:00
|
|
|
// Acquire credentials for SSH.
|
|
|
|
int cred_acquire(git_cred **cred, const char *url,
|
|
|
|
const char *username_from_url, unsigned int allowed_types,
|
|
|
|
void *payload);
|
|
|
|
|
2020-07-01 03:51:00 +02:00
|
|
|
// Clone the git repo.
|
2020-07-01 08:55:13 +02:00
|
|
|
void clone();
|
2020-07-01 03:51:00 +02:00
|
|
|
|
|
|
|
// Make a new branch for preparing the pull request.
|
2020-07-01 08:55:13 +02:00
|
|
|
void create_branch();
|
2020-07-01 03:51:00 +02:00
|
|
|
|
2020-07-01 08:48:36 +02:00
|
|
|
// Make a new commit.
|
2020-07-01 20:51:35 +02:00
|
|
|
void commit(const cgi::entry_type &entry);
|
2020-07-01 03:51:00 +02:00
|
|
|
|
2020-07-01 10:24:38 +02:00
|
|
|
// Push the new commit.
|
|
|
|
void push();
|
|
|
|
|
2020-07-02 03:20:27 +02:00
|
|
|
// Get the name of the branch we use.
|
|
|
|
string get_branch_name();
|
|
|
|
|
2020-07-01 08:50:16 +02:00
|
|
|
} // namespace FediBlock::git
|
2020-07-01 03:51:00 +02:00
|
|
|
|
|
|
|
#endif // FEDIBLOCK_BACKEND_GIT_HPP
|