summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/config.c14
-rw-r--r--src/config.h3
-rw-r--r--src/main.c6
3 files changed, 22 insertions, 1 deletions
diff --git a/src/config.c b/src/config.c
index 154127e..a80aefb 100644
--- a/src/config.c
+++ b/src/config.c
@@ -170,7 +170,19 @@ static int parse_line_inner(struct config *cfg, enum config_section section,
cfg->head->user_agent = value;
else if (!strcmp(key, "owner"))
cfg->head->owner = value;
- else {
+ else if (!strcmp(key, "skip-forks")) {
+ if (!strcmp(value, "true"))
+ cfg->head->skip_forks = 1;
+ else if (!strcmp(value, "false"))
+ cfg->head->skip_forks = 0;
+ else {
+ fprintf(stderr,
+ "Error parsing config file: "
+ "invalid value for skip-forks: %s\n",
+ value);
+ return -1;
+ }
+ } else {
fprintf(stderr,
"Error parsing config file: unknown key: %s\n",
key);
diff --git a/src/config.h b/src/config.h
index 13f2649..0f4709f 100644
--- a/src/config.h
+++ b/src/config.h
@@ -13,6 +13,9 @@
extern const char *config_locations[];
struct github_cfg {
+ /// Whether to skip mirroring fork repositories
+ int skip_forks;
+
// Borrowed
/// Github graphql API endpoint
const char *endpoint;
diff --git a/src/main.c b/src/main.c
index 64c369f..3bba961 100644
--- a/src/main.c
+++ b/src/main.c
@@ -88,6 +88,12 @@ static int mirror_owner(const char *git_base, const struct github_cfg *cfg)
return -1;
for (size_t i = 0; i < res.repos_len; i++) {
+ if (cfg->skip_forks && res.repos[i].is_fork) {
+ fprintf(stderr, "Skipping forked repo: %s\n",
+ res.repos[i].name);
+ continue;
+ }
+
printf("Repo: %s\t%s\n", res.repos[i].name,
res.repos[i].url);