summaryrefslogtreecommitdiff
path: root/src/backend/syncenv.py
blob: 5a571c87a3f72d7486b54fa98cc3a7adf2bfee3e (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/python3

import os
import subprocess
import sisyphus.getfs


def gentooRepo():
    os.chdir(sisyphus.getfs.gentooRepoDir)
    localBranch = subprocess.check_output(
        ['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
    remoteBranch = subprocess.check_output(
        ['git', 'rev-parse', '--symbolic-full-name', '@{u}'])

    gitExecStage1 = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] +
                                     localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE)
    gitExecStage1.wait()

    gitExecStage2 = subprocess.Popen(['git', 'reset', '--hard'] + remoteBranch.decode(
    ).strip().replace('refs/remotes/', '').split() + ['--quiet'], stdout=subprocess.PIPE)
    gitExecStage2.wait()


def redcoreRepo():
    os.chdir(sisyphus.getfs.redcoreRepoDir)
    localBranch = subprocess.check_output(
        ['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
    remoteBranch = subprocess.check_output(
        ['git', 'rev-parse', '--symbolic-full-name', '@{u}'])

    gitExecStage1 = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] +
                                     localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE)
    gitExecStage1.wait()

    gitExecStage2 = subprocess.Popen(['git', 'reset', '--hard'] + remoteBranch.decode(
    ).strip().replace('refs/remotes/', '').split() + ['--quiet'], stdout=subprocess.PIPE)
    gitExecStage2.wait()


def portageConfigRepo():
    os.chdir(sisyphus.getfs.portageConfigDir)
    localBranch = subprocess.check_output(
        ['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
    remoteBranch = subprocess.check_output(
        ['git', 'rev-parse', '--symbolic-full-name', '@{u}'])

    gitExecStage1 = subprocess.Popen(['git', 'stash'], stdout=subprocess.PIPE)
    gitExecStage1.wait()
    gitExecStage2 = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] +
                                     localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE)
    gitExecStage2.wait()
    gitExecStage3 = subprocess.Popen(['git', 'reset', '--hard'] + remoteBranch.decode(
    ).strip().replace('refs/remotes/', '').split() + ['--quiet'], stdout=subprocess.PIPE)
    gitExecStage3.wait()
    gitExecStage4 = subprocess.Popen(
        ['git', 'stash', 'apply'], stdout=subprocess.PIPE)
    gitExecStage4.wait()
    gitExecStage5 = subprocess.Popen(
        ['git', 'stash', 'clear'], stdout=subprocess.PIPE)
    gitExecStage5.wait()
    gitExecStage6 = subprocess.Popen(
        ['git', 'gc', '--prune=now', '--quiet'], stdout=subprocess.PIPE)
    gitExecStage6.wait()