forked from OCA/maintainer-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-badges.py
86 lines (74 loc) · 2.82 KB
/
add-badges.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import re
import os
import subprocess
import fileinput
import sys
import shutil
import pdb
# Runbot urls need the repo id from the table in the runbot server.
# This file is the output of a select id, name from there.
for repo_list_line in open('repos_with_ids.txt'):
m = re.search('(\d+)\|github.com/OCA/(.*)', repo_list_line)
repo_name = m.group(2)
repo_id = m.group(1)
print(repo_name)
if not os.path.exists(repo_name):
subprocess.call(['hub', 'clone', '--quiet', 'OCA/' + repo_name])
os.chdir(repo_name)
for version in ['6.1', '7.0', '8.0']:
try:
subprocess.check_call(['git', 'checkout', '--quiet', version])
except subprocess.CalledProcessError:
continue
subprocess.check_call(['git', 'reset', '--hard'])
subprocess.check_call(['git', 'clean', '-fxd'])
new_lines = (
"[![Runbot Build Status]"
"(http://runbot.odoo-community.org/runbot/badge/flat/{0}/{1}.svg)]"
"(http://runbot.odoo-community.org/runbot/repo/{0})\n".format(
repo_id, version
)
)
# template file is in OCA/maintainer-quality-tools
if not os.path.exists('.codeclimate.yml'):
new_lines += (
"[![Code Climate]"
"(https://codeclimate.com/github/OCA/{0}/badges/gpa.svg)]"
"(https://codeclimate.com/github/OCA/{0})\n".format(
repo_name
)
)
shutil.copy('../.codeclimate.yml', '.')
# template file is in OCA/maintainer-quality-tools
if not os.path.exists('CONTRIBUTING.md'):
shutil.copy('../CONTRIBUTING.md', '.')
stuff_added = False
for readme_line in fileinput.input('README.md', inplace=1):
sys.stdout.write(readme_line)
if not stuff_added and 'travis-ci.org' in readme_line:
sys.stdout.write(new_lines)
stuff_added = True
transifex_folder = "OCA-" + repo_name + version.replace('.', '-')
transifex_lines = (
"Translation Status\n"
"------------------\n"
"[![Transifex Status]"
"(https://www.transifex.com/projects/p/{0}/chart/image_png)]"
"(https://www.transifex.com/projects/p/{0})\n".format(
transifex_folder
)
)
with open("REAMDME.md", "a") as readme_file: # append
readme_file.write(transifex_lines)
subprocess.check_call(['git', 'add', '--all'])
subprocess.check_call(
['git', 'commit', '-m',
'''\
add badges and files for transifex, runbot, codeclimate
This is an automatic commit done with the add-badges.py script
in maintainers-tools.
''']
)
# stop here!
pdb.set_trace()
os.chdir('..')