-
Notifications
You must be signed in to change notification settings - Fork 0
/
drop-sphinxmark.py
86 lines (68 loc) · 3.23 KB
/
drop-sphinxmark.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 os
import subprocess
from osa import repos
for repo in repos:
print(repo.working_dir)
# Remove from doc/requirements.txt
req_path = "%s/doc/requirements.txt" % repo.working_dir
if os.path.isfile(req_path):
proc = subprocess.run("sed /^sphinxmark/d %s" % (req_path),
shell=True, check=True, capture_output=True)
# NOTE(mnaser): macOS doesn't have GNU sed, so `-i` flag is missing.
with open(req_path, 'wb') as fd:
fd.write(proc.stdout)
# Remove sphinxmark module reference
conf_path = "%s/doc/source/conf.py" % repo.working_dir
if os.path.isfile(conf_path):
proc = subprocess.run("sed /sphinxmark/d %s" % (conf_path),
shell=True, check=True, capture_output=True)
# NOTE(mnaser): macOS doesn't have GNU sed, so `-i` flag is missing.
with open(conf_path, 'wb') as fd:
fd.write(proc.stdout)
# Remove watermark reference
conf_path = "%s/doc/source/conf.py" % repo.working_dir
if os.path.isfile(conf_path):
proc = subprocess.run("sed /watermark/d %s" % (conf_path),
shell=True, check=True, capture_output=True)
# NOTE(mnaser): macOS doesn't have GNU sed, so `-i` flag is missing.
with open(conf_path, 'wb') as fd:
fd.write(proc.stdout)
# Remove trailing sed line reference
conf_path = "%s/doc/source/conf.py" % repo.working_dir
if os.path.isfile(conf_path):
proc = subprocess.run("sed /^\|\ awk/d %s" % (conf_path),
shell=True, check=True, capture_output=True)
# NOTE(mnaser): macOS doesn't have GNU sed, so `-i` flag is missing.
with open(conf_path, 'wb') as fd:
fd.write(proc.stdout)
# Remove config comment
conf_path = "%s/doc/source/conf.py" % repo.working_dir
if os.path.isfile(conf_path):
proc = subprocess.run("sed /^#.\*sphinxmark/d %s" % (conf_path),
shell=True, check=True, capture_output=True)
# NOTE(mnaser): macOS doesn't have GNU sed, so `-i` flag is missing.
with open(conf_path, 'wb') as fd:
fd.write(proc.stdout)
# Remove config files
conf_path = "%s/doc/source/conf.py" % repo.working_dir
if os.path.isfile(conf_path):
proc = subprocess.run("sed /^sphinxmark/d %s" % (conf_path),
shell=True, check=True, capture_output=True)
# NOTE(mnaser): macOS doesn't have GNU sed, so `-i` flag is missing.
with open(conf_path, 'wb') as fd:
fd.write(proc.stdout)
# Commit if we have changes
if repo.is_dirty():
message = """docs: drop sphinxmark
sphinxmark is no longer compatible with the latest release of Sphinx
which is causing all of our documentation jobs to fail. This patch
removes it as our current usage of openstacktheme for documentation
already provides watermarks for current branch and notices for which
branch the documentation covers.
"""
repo.git.commit('-a', '-m', message)
# Get latest commit
commit = repo.head.commit
# Send to Gerrit
if 'drop sphinxmark' in commit.message:
repo.git.execute(['git', 'review', '-t', 'osa-drop-sphinxmark'])