51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#include "calculator_c_interface_lib.h"
|
|
|
|
#include <git2.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
TariffCalculatorHandle NewTariffCalculator(void) {
|
|
return new TariffCalculator();
|
|
}
|
|
|
|
void DeleteTariffCalculator(TariffCalculatorHandle handle) {
|
|
delete handle;
|
|
}
|
|
|
|
int InitGitLibrary(void) {
|
|
return git_libgit2_init();
|
|
}
|
|
|
|
int ShutdownGitLibrary(void) {
|
|
return git_libgit2_shutdown();
|
|
}
|
|
|
|
int CloneRepository(char const *url, char const *local_path) {
|
|
git_repository *out;
|
|
git_clone_options opts;
|
|
|
|
int res = 0;
|
|
if ((res = git_clone_options_init(&opts, GIT_CLONE_OPTIONS_VERSION)) == 0) {
|
|
opts.checkout_branch = "master";
|
|
|
|
fprintf(stderr, "%s:%d %s %s\n", __func__, __LINE__, url, local_path);
|
|
|
|
if ((res = git_clone(&out, url, local_path, &opts)) < 0) {
|
|
git_error const *error = git_error_last();
|
|
fprintf(stderr, "%s:%d error: %s\n", __func__, __LINE__, error->message);
|
|
}
|
|
} else {
|
|
git_error const *error = git_error_last();
|
|
fprintf(stderr, "%s:%d error: %s\n", __func__, __LINE__, error->message);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|