forked from holatuwol/liferay-faster-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitchanges.py
71 lines (50 loc) · 1.68 KB
/
gitchanges.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
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
#!/usr/bin/env python
from __future__ import print_function
from git import git_root
from sourcetrie import SourceTrie, get_rd_file
import os.path
module_paths = SourceTrie.load(get_rd_file())
changed_modules = set()
# Scan modules
with open(get_rd_file('changes.txt'), 'r') as f:
for file_name in [line.strip() for line in f.readlines()]:
if file_name.startswith('portal-web') and file_name.endswith('.tld'):
continue
if file_name.endswith('node_modules'):
continue
if file_name.find('hs_err_pid') >= 0:
continue
node = module_paths.find_leaf(file_name)
if node is None:
continue
node_path = node.get_path()
if node_path != 'modules':
changed_modules.add(node_path)
# Sort the modules
global is_subrepo
is_subrepo = False
if os.path.isfile('settings.gradle'):
with open('settings.gradle') as f:
is_subrepo = len([line for line in f.readlines() if line.find('com.liferay') != -1]) > 0
def priority(x):
global is_subrepo
if x.startswith('modules/') or is_subrepo:
if os.path.exists('%s/.lfrbuild-portal-pre' % x):
return (0, x)
else:
return (4, x)
if x == 'portal-kernel':
return (1, x)
if x == 'portal-web':
return (3, x)
return (2, x)
changed_modules = sorted([priority(x) for x in changed_modules])
with open(get_rd_file('changes_ant.txt'), 'w') as f:
for module in [x[1] for x in changed_modules if x[0] != 0 and x[0] != 4]:
f.write('%s\n' % module)
with open(get_rd_file('changes_gradle_1.txt'), 'w') as f:
for module in [x[1] for x in changed_modules if x[0] == 0]:
f.write('%s\n' % module)
with open(get_rd_file('changes_gradle_2.txt'), 'w') as f:
for module in [x[1] for x in changed_modules if x[0] == 4]:
f.write('%s\n' % module)