Commit e0d6e73f authored by nimrod's avatar nimrod
Browse files

Git infrastructure refactor.

Move some reusable code to the module.
parent 64c7663e
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -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,
+9 −0
Original line number Diff line number Diff line
@@ -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()