From df5e80d63cff8acce2b510e1f2be07a7e1369415 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Wed, 10 Jun 2020 00:12:21 +0100 Subject: branchsetup : new generic module, drop old branchinject, branchmaster && branchnext modules; plug the new module into the new cli client -> works magic --- src/backend/check.py | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'src/backend/check.py') diff --git a/src/backend/check.py b/src/backend/check.py index 9c0a878..a129d36 100644 --- a/src/backend/check.py +++ b/src/backend/check.py @@ -10,36 +10,38 @@ def root(): sys.exit("\nYou need root permissions to do this, exiting!\n") def portage(): - os.chdir(sisyphus.filesystem.portageRepoDir) - needsPortageSync = int() + if os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')): + os.chdir(sisyphus.filesystem.portageRepoDir) + needsPortageSync = int() - localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) - localHash = subprocess.check_output(['git', 'rev-parse', '@']) - remoteHash = subprocess.check_output(['git', 'rev-parse', '@{u}']) + localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) + localHash = subprocess.check_output(['git', 'rev-parse', '@']) + remoteHash = subprocess.check_output(['git', 'rev-parse', '@{u}']) - gitExec = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + gitExec = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) - if not localHash.decode().strip() == remoteHash.decode().strip(): - needsPortageSync = int(1) + if not localHash.decode().strip() == remoteHash.decode().strip(): + needsPortageSync = int(1) - gitExec.wait() - return needsPortageSync + gitExec.wait() + return needsPortageSync def overlay(): - os.chdir(sisyphus.filesystem.redcoreRepoDir) - needsOverlaySync = int() + if os.path.isdir(os.path.join(sisyphus.filesystem.redcoreRepoDir, '.git')): + os.chdir(sisyphus.filesystem.redcoreRepoDir) + needsOverlaySync = int() - localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) - localHash = subprocess.check_output(['git', 'rev-parse', '@']) - remoteHash = subprocess.check_output(['git', 'rev-parse', '@{u}']) + localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) + localHash = subprocess.check_output(['git', 'rev-parse', '@']) + remoteHash = subprocess.check_output(['git', 'rev-parse', '@{u}']) - gitExec = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + gitExec = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) - if not localHash.decode().strip() == remoteHash.decode().strip(): - needsOverlaySync = int(1) + if not localHash.decode().strip() == remoteHash.decode().strip(): + needsOverlaySync = int(1) - gitExec.wait() - return needsOverlaySync + gitExec.wait() + return needsOverlaySync def update(): portage() -- cgit v1.2.3