aboutsummaryrefslogtreecommitdiff
path: root/repo.py
diff options
context:
space:
mode:
Diffstat (limited to 'repo.py')
-rwxr-xr-xrepo.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/repo.py b/repo.py
index 1a127ae..9735285 100755
--- a/repo.py
+++ b/repo.py
@@ -3,6 +3,7 @@
import requests
import argparse
import subprocess
+import os
gitweb_url = "https://git.marks.kitchen"
@@ -21,6 +22,21 @@ def clone_repo(args):
if title == args["repo"]:
subprocess.run(["git", "clone", remote])
+def init_repo(args):
+ name = os.path.basename(os.getcwd())
+ git_dir = f"/srv/git/{name}.git"
+ r = subprocess.run(["ssh", "git@marks.kitchen", f"mkdir {git_dir}"])
+ if r.returncode == 0:
+ subprocess.run(["ssh", "git@marks.kitchen",
+ f"cd \"{git_dir}\"; git init --bare; touch git-daemon-export-ok"])
+
+ subprocess.run(["git", "init"])
+ subprocess.run(["git", "remote", "add", "origin", f"git@marks.kitchen:{git_dir}"])
+ #subprocess.run(["git", "branch", "--set-upstream-to=origin/master", "master"])
+ #subprocess.run(["git", "push", "--set-upstream", "origin", "master"])
+ else:
+ print("Repo already exists")
+
def main():
parser = argparse.ArgumentParser("wikijscmd")
parser.set_defaults(command=None)
@@ -33,6 +49,9 @@ def main():
parser_clone.add_argument("repo", type=str, help="repo name")
parser_clone.set_defaults(command=clone_repo)
+ parser_init = subparsers.add_parser("init", help="create repos")
+ parser_init.set_defaults(command=init_repo)
+
args = vars(parser.parse_args())
callback = args["command"]
if callback is None: