-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
36 lines (27 loc) · 1.02 KB
/
main.py
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
import sys
from os import getenv
from os.path import abspath
from subprocess import check_call, DEVNULL
remote = "origin"
def get_testkit_branch(driverName, driverTargetBranch):
if driverName == "go" and driverTargetBranch in ['4.0', '4.1']:
return "4.2"
return driverTargetBranch
def main(testkitRepoPath, driverTargetBranch):
testkitRepoPath = abspath(testkitRepoPath)
driverName = getenv('TEST_DRIVER_NAME')
print("Driver is {} and target branch is {}".format(
driverName, driverTargetBranch))
testkitBranch = get_testkit_branch(driverName, driverTargetBranch)
print("Testkit branch is {}".format(testkitBranch))
# Git writes non-errors to stderr which indicates error to TeamCity
check_call(
["git", "fetch", remote],
cwd=testkitRepoPath,
stderr=DEVNULL)
check_call(
["git", "checkout", "{}/{}".format(remote, testkitBranch)],
cwd=testkitRepoPath,
stderr=DEVNULL)
if __name__ == "__main__":
main(sys.argv[1], sys.argv[2])