current_branch -> current_commit

This commit is contained in:
Kay0u 2020-11-26 16:40:51 +01:00
parent b18fecce60
commit 96d7855de7
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D
2 changed files with 7 additions and 7 deletions

View file

@ -5,16 +5,16 @@ import glob
import datetime import datetime
import subprocess import subprocess
def get_current_git_branch(): def get_current_commit():
p = subprocess.Popen("git rev-parse --verify HEAD", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p = subprocess.Popen("git rev-parse --verify HEAD", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
current_branch = stdout.strip().decode('utf-8') current_commit = stdout.strip().decode('utf-8')
return current_branch return current_commit
def render(helpers): def render(helpers):
current_branch = get_current_git_branch() current_commit = get_current_commit()
data = {"helpers": helpers, data = {"helpers": helpers,
"date": datetime.datetime.now().strftime("%m/%d/%Y"), "date": datetime.datetime.now().strftime("%m/%d/%Y"),
@ -34,7 +34,7 @@ def render(helpers):
template = open("helper_doc_template.html", "r").read() template = open("helper_doc_template.html", "r").read()
t = Template(template) t = Template(template)
t.globals['now'] = datetime.datetime.utcnow t.globals['now'] = datetime.datetime.utcnow
result = t.render(current_branch=current_branch, data=data, convert=shell_to_html, shell_css=shell_css) result = t.render(current_commit=current_commit, data=data, convert=shell_to_html, shell_css=shell_css)
open("helpers.html", "w").write(result) open("helpers.html", "w").write(result)
############################################################################## ##############################################################################

View file

@ -2,7 +2,7 @@
<h1>App helpers</h1> <h1>App helpers</h1>
<p>Doc auto-generated by <a href="https://github.com/YunoHost/yunohost/blob/{{ current_branch }}/doc/generate_helper_doc.py">this script</a> on {{data.date}} (Yunohost version {{data.version}})</p> <p>Doc auto-generated by <a href="https://github.com/YunoHost/yunohost/blob/{{ current_commit }}/doc/generate_helper_doc.py">this script</a> on {{data.date}} (Yunohost version {{data.version}})</p>
{% for category, helpers in data.helpers %} {% for category, helpers in data.helpers %}
@ -72,7 +72,7 @@
</p> </p>
{% endif %} {% endif %}
<p> <p>
<a href="https://github.com/YunoHost/yunohost/blob/{{ current_branch }}/data/helpers.d/{{ category }}#L{{ h.line + 1 }}">Dude, show me the code !</a> <a href="https://github.com/YunoHost/yunohost/blob/{{ current_commit }}/data/helpers.d/{{ category }}#L{{ h.line + 1 }}">Dude, show me the code !</a>
</p> </p>
</div> </div>