MCPcopy Create free account
hub / github.com/DanielKeep/rust-conv / main

Function main

update-docs.py:130–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128 msg('%s is ready. Continuing.' % DOC_TARGET_BRANCH)
129
130def main():
131 if sh_eval('git symbolic-ref --short HEAD') != u'master':
132 msg('Not on master; doing nothing.')
133 return 0
134
135 # Sanity check: does the doc branch exist at all?
136 branches = {b[2:].strip() for b in sh_eval('git branch', dont_strip=True).splitlines()}
137 msg_trace('branches = %r' % branches)
138 if DOC_TARGET_BRANCH not in branches:
139 init_doc_branch()
140
141 last_rev = sh_eval('git rev-parse HEAD')
142 last_msg = sh_eval('git log -1 --pretty=%B')
143 msg_trace('last_rev = %r' % last_rev)
144 msg_trace('last_msg = %r' % last_msg)
145
146 dir = os.getcwdu()
147 msg_trace('dir = %r' % dir)
148
149 tmp1 = tempfile.mkdtemp(prefix=TEMP_CHECKOUT_PREFIX)
150 tmp2 = tempfile.mkdtemp(prefix=TEMP_OUTPUT_PREFIX)
151 msg_trace('tmp1 = %r' % tmp1)
152 msg_trace('tmp2 = %r' % tmp2)
153
154 try:
155 msg("Cloning into a temporary directory...")
156 sh('git clone -qb "%s" "%s" "%s"' % (DOC_TARGET_BRANCH, dir, tmp1))
157 msg_trace('os.chdir(%r)' % tmp1)
158 os.chdir(tmp1)
159 sh('git checkout -q master')
160
161 msg("Generating documentation...")
162 sh('cargo doc %s' % DOC_ARGS)
163 tmp1_target_doc = '%s/target/doc' % tmp1
164 msg_trace('shutil.move(%r, %r)' % (tmp1_target_doc, tmp2))
165 shutil.move(tmp1_target_doc, tmp2)
166
167 msg('Updating %s...' % DOC_TARGET_BRANCH)
168 sh('git checkout -q "%s"' % DOC_TARGET_BRANCH)
169 sh('git clean -dfq')
170 tmp2_doc = '%s/doc' % tmp2
171
172 msg_trace('copytree(%r, %r)' % (tmp2_doc, './doc'))
173 copytree(tmp2_doc, './doc')
174
175 msg('Committing changes...')
176 sh('git add .')
177 sh('git commit -m "Update docs for %s" -m "%s"' % (last_rev[:7], last_msg))
178
179 sh('git push -qu origin "%s"' % DOC_TARGET_BRANCH)
180
181 finally:
182 msg('Cleaning up...')
183 msg_trace('os.chdir(%r)' % dir)
184 os.chdir(dir)
185 msg_trace('shutil.rmtree(%r)' % tmp2)
186 really_rmtree(tmp2)
187 msg_trace('shutil.rmtree(%r)' % tmp1)

Callers 1

update-docs.pyFile · 0.85

Calls 7

sh_evalFunction · 0.85
msgFunction · 0.85
msg_traceFunction · 0.85
init_doc_branchFunction · 0.85
shFunction · 0.85
copytreeFunction · 0.85
really_rmtreeFunction · 0.85

Tested by

no test coverage detected