summaryrefslogtreecommitdiff
path: root/src/backend/check.py
blob: a159a27b0de81298f4cd9c27f621fe0db9959ee9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python3

import os
import subprocess
import sisyphus.binhost
import sisyphus.filesystem

def root():
    return True if os.getuid() == 0 else False

def branch():
    if os.path.isdir(os.path.join(sisyphus.filesystem.portageRepoDir, '.git')):
        os.chdir(sisyphus.filesystem.portageRepoDir)
        needsMatch = int()

        isBinhost = sisyphus.binhost.start()
        localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])

        if "packages-next" in isBinhost:
            if localBranch.decode().strip() == "next":
                needsMatch = int(0)
            else:
                needsMatch = int(1)
        else:
            if localBranch.decode().strip() == "master":
                needsMatch = int(0)
            else:
                needsMatch = int(1)

        return needsMatch,localBranch