27 lines
577 B
C
27 lines
577 B
C
#include "log.h"
|
|
#include "util.h"
|
|
#include <git2.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#define TMP_PATH "/tmp/confer"
|
|
|
|
char *repo_clone(char *url) {
|
|
git_libgit2_init();
|
|
git_repository *repo = NULL;
|
|
|
|
int random = randint(100, 999);
|
|
char path[strlen(TMP_PATH) + 4];
|
|
sprintf(path, "%s_%d", TMP_PATH, random);
|
|
|
|
if (git_clone(&repo, url, path, NULL) != 0) {
|
|
error("Failed to clone the repository: " COLOR_RESET "%s", git_error_last()->message);
|
|
return NULL;
|
|
}
|
|
|
|
git_libgit2_shutdown();
|
|
return strdup(path);
|
|
}
|