aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-git-receiver/post-receive.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-09-29 00:49:36 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-09-29 00:49:36 +0200
commit3fff4bb3172f77b292b0c913749e81bedd3545f3 (patch)
treecf0445fac31f374445c7706bd7b4d62fa10101bc /src/blogc-git-receiver/post-receive.c
parent4f1f932f6ef6d6c9770266775c2db072964d7a62 (diff)
downloadblogc-3fff4bb3172f77b292b0c913749e81bedd3545f3.tar.gz
blogc-3fff4bb3172f77b292b0c913749e81bedd3545f3.tar.bz2
blogc-3fff4bb3172f77b292b0c913749e81bedd3545f3.zip
git-receiver: splitted code
Diffstat (limited to 'src/blogc-git-receiver/post-receive.c')
-rw-r--r--src/blogc-git-receiver/post-receive.c29
1 files changed, 29 insertions, 0 deletions
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 <rafael@rafaelmartins.eng.br>
+ *
+ * This program can be distributed under the terms of the BSD License.
+ * See the file LICENSE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+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;
+}