summaryrefslogtreecommitdiff
path: root/tau/sync-tau-to-slp.py
blob: b6ebf3ba6c00d103f2599291e3666d89ff2ae578 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/python
# author Heeju Joo <heeju.joo@samsung.com>
# This script is used for update latest TAU library to ide source and sdk-web-apps
# If you have any problem with this script, please contact author
import os, sys, subprocess, shutil, fileinput

cwd=os.getcwd()
syncdir=cwd+"/_sync"
gitaccount=""

if(len(sys.argv) > 1):
	gitaccount=sys.argv[1]

if "" == gitaccount:
	print("No git account is given")
	sys.exit(1)

def cmd(command):
	return subprocess.call(command.split())

class Git:
	addr=""
	branch=""


# Git info
class webuifw(Git):
	addr="168.219.209.56:29418/framework/web/web-ui-fw"
	branch="devel/tau"

class slpwebuifw(Git):
	addr="165.213.149.219:29418/magnolia/framework/web/web-ui-fw"
	branch="devel/webappfw/tau"


def cloneAndMerge(git, targetdir):
	cwd=os.getcwd()
	os.chdir(targetdir)

	localpath=os.path.basename(git.addr)

	if not os.path.isdir(localpath):
		cmd("git clone ssh://"+gitaccount+"@"+git.addr)
		os.chdir(localpath)
		cmd("git fetch origin "+git.branch+":"+git.branch)
		cmd("git checkout "+git.branch)
	else:
		pass
		os.chdir(localpath)
		cmd("git fetch origin")
		cmd("git checkout "+git.branch)
		cmd("git rebase origin/"+git.branch)
	cmd("cp ../../commit-msg .git/hooks/")

	# add slp git as remote repo and merge SPIN_tau to slp_tau
	cmd("git remote add slp ssh://"+gitaccount+"@"+slpwebuifw.addr)
	cmd("git fetch slp "+slpwebuifw.branch+":"+slpwebuifw.branch)
	cmd("git checkout "+slpwebuifw.branch)
	cmd("git merge --no-ff "+webuifw.branch)

def main():
	global syncdir

	if os.path.isdir(syncdir):
		cmd("rm -rf "+syncdir)
	os.mkdir(syncdir)

	cloneAndMerge(webuifw, syncdir)

	pushcmd = "git push slp HEAD:refs/for/"+slpwebuifw.branch

	print "================================================================"
	print "Merge to slp web-ui-fw git finished!"
	print "================================================================"
	print "1. Go to '_sync/web-ui-fw' dir"
	print "2. Please add your commit message using 'git commit --amend'"
	print "3. Push to gerrit!(using following command)"
	print "==> "+pushcmd

if __name__ == "__main__":
	main()