Clone via SSH.
This commit is contained in:
parent
8af8115e24
commit
ca61c1e391
16
src/git.cpp
16
src/git.cpp
|
@ -55,10 +55,22 @@ void check(int error)
|
|||
}
|
||||
}
|
||||
|
||||
int cred_acquire(git_cred **cred, const char * /*url*/,
|
||||
const char *username_from_url, unsigned int /*allowed_types*/,
|
||||
void * /*payload*/)
|
||||
{
|
||||
// return git_credential_ssh_key_new(
|
||||
// cred, username_from_url, "/home/tastytea/.ssh/noid_fediblock.pub",
|
||||
// "/home/tastytea/.ssh/noid_fediblock.pub", "");
|
||||
return git_credential_ssh_key_from_agent(cred, username_from_url);
|
||||
}
|
||||
|
||||
void clone()
|
||||
{
|
||||
check(git_clone(&_repo, "https://schlomp.space/FediBlock/data.git",
|
||||
(get_tmpdir() / "repo").c_str(), nullptr));
|
||||
git_clone_options options = GIT_CLONE_OPTIONS_INIT;
|
||||
options.fetch_opts.callbacks.credentials = cred_acquire;
|
||||
check(git_clone(&_repo, "git@schlomp.space:FediBlock/data.git",
|
||||
(get_tmpdir() / "repo").c_str(), &options));
|
||||
}
|
||||
|
||||
uint64_t get_last_id()
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
#include "cgi.hpp"
|
||||
|
||||
#include <git2.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace FediBlock::git
|
||||
|
@ -29,6 +31,11 @@ using std::uint64_t;
|
|||
// Throws runtime_error on error.
|
||||
void check(int error);
|
||||
|
||||
// Acquire credentials for SSH.
|
||||
int cred_acquire(git_cred **cred, const char *url,
|
||||
const char *username_from_url, unsigned int allowed_types,
|
||||
void *payload);
|
||||
|
||||
// Clone the git repo.
|
||||
void clone();
|
||||
|
||||
|
|
Reference in New Issue
Block a user