diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2020-06-13 11:54:14 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2020-06-13 11:54:14 +0100 |
commit | e684f2b8d0fa206728ffe0820dd7640ca78b1958 (patch) | |
tree | 920f19d085c5e5dffbb29ec28bb02d33c09f2cd6 | |
parent | 61d13cc66b74df9be710ffedd64c22b2501b71cf (diff) |
branchsetup : use GitPython instead of subprocess
-rw-r--r-- | src/backend/branchsetup.py | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/backend/branchsetup.py b/src/backend/branchsetup.py index 6524bb4..23670d1 100644 --- a/src/backend/branchsetup.py +++ b/src/backend/branchsetup.py @@ -2,7 +2,7 @@ import animation import os -import subprocess +import git import sisyphus.check import sisyphus.branchreset import sisyphus.filesystem @@ -15,7 +15,6 @@ def getBranchRemote(branch,remote): portageRemote = [] redcoreRemote = [] portageConfigRemote = [] - remoteBranch = [] if "master" in branch: if "gitlab" in remote: remote = sisyphus.filesystem.remoteGitlab @@ -45,42 +44,29 @@ def getBranchRemote(branch,remote): portageRemote = [remote, sisyphus.filesystem.portageRepo] redcoreRemote = [remote, sisyphus.filesystem.redcoreRepo] portageConfigRemote = [remote, sisyphus.filesystem.portageConfigRepo] - remoteBranch = ['origin', branch] - return portageRemote,redcoreRemote,portageConfigRemote,remoteBranch + return portageRemote,redcoreRemote,portageConfigRemote @animation.wait('injecting Gentoo Linux portage tree') def injectGentooPortageTree(branch,remote): - portageRemote,redcoreRemote,portageConfigRemote,remoteBranch = getBranchRemote(branch,remote) + portageRemote,redcoreRemote,portageConfigRemote = getBranchRemote(branch,remote) if not os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')): - os.chdir(sisyphus.filesystem.portageRepoDir) - 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']) + git.Repo.clone_from("/".join(portageRemote), sisyphus.filesystem.portageRepoDir, depth=1, branch=branch) @animation.wait('injecting Redcore Linux ebuild overlay') def injectRedcoreEbuildOverlay(branch,remote): - portageRemote,redcoreRemote,portageConfigRemote,remoteBranch = getBranchRemote(branch,remote) + portageRemote,redcoreRemote,portageConfigRemote = getBranchRemote(branch,remote) if not os.path.isdir(os.path.join(sisyphus.filesystem.redcoreRepoDir, '.git')): - os.chdir(sisyphus.filesystem.redcoreRepoDir) - 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']) + git.Repo.clone_from("/".join(redcoreRemote), sisyphus.filesystem.redcoreRepoDir, depth=1, branch=branch) @animation.wait('injecting Redcore Linux portage config') def injectRedcorePortageConfig(branch,remote): - portageRemote,redcoreRemote,portageConfigRemote,remoteBranch = getBranchRemote(branch,remote) + portageRemote,redcoreRemote,portageConfigRemote = getBranchRemote(branch,remote) if not os.path.isdir(os.path.join(sisyphus.filesystem.portageConfigDir, '.git')): - os.chdir(sisyphus.filesystem.portageConfigDir) - 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']) + git.Repo.clone_from("/".join(portageConfigRemote), sisyphus.filesystem.portageConfigDir, depth=1, branch=branch) def warnAboutBinaryRepository(branch,remote): if "master" in branch: |