From e0d6e73f16505ab8ac55f1c433ab009945bb886c Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Tue, 7 Sep 2021 18:21:51 +0300
Subject: [PATCH] Git infrastructure refactor.

Move some reusable code to the module.
---
 Documents/bin/git-manage     | 7 +------
 Documents/bin/rcfiles/git.py | 9 +++++++++
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/Documents/bin/git-manage b/Documents/bin/git-manage
index 774e9a8..f413e74 100755
--- a/Documents/bin/git-manage
+++ b/Documents/bin/git-manage
@@ -9,7 +9,6 @@ import sys
 import github3.exceptions  # pylint: disable=import-error
 import gitlab.exceptions  # pylint: disable=import-error
 import passhole.passhole  # pylint: disable=import-error
-import sh  # pylint: disable=import-error
 
 sys.path.append(os.path.expanduser("~/Documents/bin"))
 
@@ -218,11 +217,7 @@ def create_github_repo(args):
     rcfiles.git.git.clone(repo.ssh_url)
     print("Cloned repository.", file=sys.stderr)
 
-    with sh.pushd(repo.name):
-        rcfiles.git.git.commit(
-            "--allow-empty", "--only", "--message", "Initial empty commit."
-        )
-        rcfiles.git.git.push("origin")
+    rcfiles.git.empty_commit(repo.name)
     print(
         "Committed an initial empty commit.",
         file=sys.stderr,
diff --git a/Documents/bin/rcfiles/git.py b/Documents/bin/rcfiles/git.py
index cd7b358..a26c6b3 100644
--- a/Documents/bin/rcfiles/git.py
+++ b/Documents/bin/rcfiles/git.py
@@ -67,3 +67,12 @@ def author_email():
     if "GIT_AUTHOR_EMAil" in os.environ:
         return os.environ["GIT_AUTHOR_EMAIL"].strip()
     return git.config("--get", "user.email").strip()
+
+
+def empty_commit(repo):
+    """Commits an empty commit and pushes."""
+    with sh.pushd(repo):
+        git.commit(
+            "--allow-empty", "--only", "--message", "Initial empty commit."
+        )
+        git.push()
-- 
GitLab