-
Notifications
You must be signed in to change notification settings - Fork 1
/
mgmt_git_rename.py
25 lines (23 loc) · 890 Bytes
/
mgmt_git_rename.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
import os
import fnmatch
import re
import subprocess
import os.path as path
SERVICE = 'containerregistry'
for root, dir, files in os.walk("..\\" + SERVICE):
for item in fnmatch.filter(files, "*.java"):
file = root + '\\' + item
filename = item[0:-5]
clazz = ''
with open(file, 'r', encoding='utf8') as f:
lines = f.readlines()
for line in lines:
m = re.search('class (\\S+)', line)
if m:
clazz = m.group(1)
if clazz and len(filename) == len(clazz) and not filename == clazz:
#print(filename + " - " + clazz)
newfile = file.replace(filename, clazz)
#print(newfile)
#subprocess.Popen(['git', 'mv', '-f', file, newfile], cwd='.').communicate()
print('git mv -f ' + file + ' ' + newfile)