From 3fff4bb3172f77b292b0c913749e81bedd3545f3 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Thu, 29 Sep 2016 00:49:36 +0200 Subject: git-receiver: splitted code --- src/blogc-git-receiver/post-receive.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/blogc-git-receiver/post-receive.c (limited to 'src/blogc-git-receiver/post-receive.c') diff --git a/src/blogc-git-receiver/post-receive.c b/src/blogc-git-receiver/post-receive.c new file mode 100644 index 0000000..8310939 --- /dev/null +++ b/src/blogc-git-receiver/post-receive.c @@ -0,0 +1,29 @@ +/* + * blogc: A blog compiler. + * Copyright (C) 2015-2016 Rafael G. Martins + * + * This program can be distributed under the terms of the BSD License. + * See the file LICENSE. + */ + +#include +#include + + +int +bgr_post_receive_hook(int argc, char *argv[]) +{ + if (0 != system("git config --local remote.mirror.pushurl &> /dev/null")) { + if (0 != system("git config --local remote.mirror.url &> /dev/null")) { + fprintf(stderr, "warning: repository mirroring disabled\n"); + return 0; + } + } + + // at this point we know that we have a remote called mirror, we can just + // push to it. + if (0 != system("git push --mirror mirror")) + fprintf(stderr, "warning: failed push to git mirror\n"); + + return 0; +} -- cgit v1.2.3-18-g5258