From 65809ac9a9e30e7c40df8f9f90da19f50e503944 Mon Sep 17 00:00:00 2001
From: Bensong Liu <bensl@microsoft.com>
Date: Fri, 7 May 2021 18:07:47 +0800
Subject: [PATCH] allow disable sync

---
 gitlab2github_sync.fish | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gitlab2github_sync.fish b/gitlab2github_sync.fish
index 83655ca..4769218 100755
--- a/gitlab2github_sync.fish
+++ b/gitlab2github_sync.fish
@@ -13,6 +13,15 @@ function echo2
     echo $argv 1>&2
 end
 
+function assert_this_repo_allows_sync
+    # We can use `echo sync=0 > .gitlab2github.conf` to disable the sync
+    # Return 0 if ok to sync, return 1 if sync is disabled. 
+    grep 'sync=0' .gitlab2github.conf > /dev/null 2>&1
+    and echo2 "Disable sync for repo "(pwd)
+    and return 1
+    or return 0
+end
+
 function sync_one_project
     set project_name $argv[1]
     set project_url $argv[2]
@@ -46,6 +55,7 @@ function sync_one_project
         # https://stackoverflow.com/questions/67054889/force-git-pull-to-resolve-divergent-by-discard-all-local-commits
         and git fetch
         and git reset --hard "@{upstream}"
+        and assert_this_repo_allows_sync
         and git push --tags --force dst (git branch --show-current)
         and cd ..
         or return 4
-- 
GitLab