summaryrefslogtreecommitdiff
path: root/src/backend/branchsetup.py
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2020-06-10 00:12:21 +0100
committerV3n3RiX <venerix@redcorelinux.org>2020-06-10 00:12:21 +0100
commitdf5e80d63cff8acce2b510e1f2be07a7e1369415 (patch)
tree85f3127fb5f533719008edc98c97e2bfcb76ac9a /src/backend/branchsetup.py
parentc76a29a71d16e9ed512a22945d6e6b77b0d21fb6 (diff)
branchsetup : new generic module, drop old branchinject, branchmaster && branchnext modules; plug the new module into the new cli client -> works magic
Diffstat (limited to 'src/backend/branchsetup.py')
-rw-r--r--src/backend/branchsetup.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/backend/branchsetup.py b/src/backend/branchsetup.py
new file mode 100644
index 0000000..5e0976e
--- /dev/null
+++ b/src/backend/branchsetup.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python3
+
+import os
+import subprocess
+import sisyphus.check
+import sisyphus.branchreset
+import sisyphus.filesystem
+import sys
+
+def start(branch,remote):
+ if "master" in branch:
+ if "gitlab" in remote:
+ remote = sisyphus.filesystem.remoteGitlab
+ elif "pagure" in remote:
+ remote = sisyphus.filesystem.remotePagure
+ else:
+ sys.exit("Usage: sisyphus-cli.py branch [OPTIONS] BRANCH" + "\n" +
+ "Try 'sisyphus-cli.py branch --help' for help." + "\n\n" +
+ "Error: Invalid remote" + " " + "'" + str(remote) + "'" + " " + "(options : gitlab, pagure)"
+ )
+ elif "next" in branch:
+ if "gitlab" in remote:
+ remote = sisyphus.filesystem.remoteGitlab
+ elif "pagure" in remote:
+ remote = sisyphus.filesystem.remotePagure
+ else:
+ sys.exit("Usage: sisyphus-cli.py branch [OPTIONS] BRANCH" + "\n" +
+ "Try 'sisyphus-cli.py branch --help' for help." + "\n\n" +
+ "Error: Invalid remote" + " " + "'" + str(remote) + "'" + " " + "(options : gitlab, pagure)"
+ )
+ else:
+ sys.exit("Usage: sisyphus-cli.py branch [OPTIONS] BRANCH" + "\n" +
+ "Try 'sisyphus-cli.py branch --help' for help." + "\n\n" +
+ "Error: Invalid branch" + " " + "'" + str(branch) + "'" +" " + "(options : master, next)"
+ )
+
+ portageRemote = [remote, sisyphus.filesystem.portageRepo]
+ redcoreRemote = [remote, sisyphus.filesystem.redcoreRepo]
+ portageConfigRemote = [remote, sisyphus.filesystem.portageConfigRepo]
+ remoteBranch = ['origin', branch]
+
+ sisyphus.check.root()
+ sisyphus.branchreset.start()
+
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')):
+ os.chdir(sisyphus.filesystem.portageRepoDir)
+ print("\nInjecting branch" + " " + "'" + branch + "'" + " " + "from" + " " + "/".join(portageRemote))
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin'] + "/".join(portageRemote).split())
+ subprocess.call(['git', 'fetch', '--depth=1', 'origin'] + branch.split() + ['--quiet'])
+ subprocess.call(['git', 'checkout', '-b'] + branch.split() + "/".join(remoteBranch).split() + ['--quiet'])
+
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.redcoreRepoDir, '.git')):
+ os.chdir(sisyphus.filesystem.redcoreRepoDir)
+ print("\nInjecting branch" + " " + "'" + branch + "'" + " " + "from" + " " + "/".join(redcoreRemote) + "\n")
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin'] + "/".join(redcoreRemote).split())
+ subprocess.call(['git', 'fetch', '--depth=1', 'origin'] + branch.split() + ['--quiet'])
+ subprocess.call(['git', 'checkout', '-b'] + branch.split() + "/".join(remoteBranch).split() + ['--quiet'])
+
+ if not os.path.isdir(os.path.join(sisyphus.filesystem.portageConfigDir, '.git')):
+ os.chdir(sisyphus.filesystem.portageConfigDir)
+ print("Injecting branch" + " " + "'" + branch + "'" + " " + "from" + " " + "/".join(portageConfigRemote) + "\n")
+ subprocess.call(['git', 'init', '-q'])
+ subprocess.call(['git', 'remote', 'add', 'origin'] + "/".join(portageConfigRemote).split())
+ subprocess.call(['git', 'fetch', '--depth=1', 'origin'] + branch.split() + ['--quiet'])
+ subprocess.call(['git', 'checkout', '-b'] + branch.split() + "/".join(remoteBranch).split() + ['--quiet'])
+
+ sisyphus.setjobs.start()
+ sisyphus.setprofile.start()
+ sisyphus.metadata.regenAnimated()