1
0
Fork 0

README-generator: improve mechanism to only add the 'specific branch' note when version is different from master + display master's version

This commit is contained in:
Alexandre Aubin 2022-08-05 23:06:38 +02:00
parent 5ceaebc120
commit 0a9495483f
3 changed files with 13 additions and 5 deletions

View file

@ -57,7 +57,14 @@ def generate_READMEs(app_path: str):
disclaimer = None disclaimer = None
# Get the current branch using git inside the app path # Get the current branch using git inside the app path
branch = os.popen("git --git-dir=%s/.git --work-tree=%s rev-parse --abbrev-ref HEAD" % (app_path, app_path)).read().strip() default_branch = from_catalog.get('branch', 'master')
current_branch = os.popen(f"git -C {app_path} rev-parse --abbrev-ref HEAD").read().strip()
if default_branch != current_branch:
os.system(f"git -C {app_path} fetch origin {default_branch} 2>/dev/null")
default_branch_version = os.popen(f"git -C {app_path} show FETCH_HEAD:manifest.json | jq -r .version").read().strip()
else:
default_branch_version = None # we don't care in that case
out = template.render( out = template.render(
lang=lang, lang=lang,
@ -66,8 +73,9 @@ def generate_READMEs(app_path: str):
screenshots=screenshots, screenshots=screenshots,
disclaimer=disclaimer, disclaimer=disclaimer,
manifest=manifest, manifest=manifest,
branch=branch, current_branch=current_branch,
default_branch=from_catalog.get('branch', 'master'), default_branch=default_branch,
default_branch_version=default_branch_version,
) )
(app_path / f"README{lang_suffix}.md").write_text(out) (app_path / f"README{lang_suffix}.md").write_text(out)

View file

@ -31,7 +31,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
{% if description %}{{description}}{% else %}{{manifest.description[lang]}}{% endif %} {% if description %}{{description}}{% else %}{{manifest.description[lang]}}{% endif %}
**Shipped version:** {% if upstream.version %}{{upstream.version}}{% else %}{{manifest.version}}{% endif %}{% if branch != default_branch %} *(This is the `{{ branch }}` branch. See the [`{{ default_branch }}` branch](https://github.com/YunoHost-Apps/{{manifest.id}}_ynh/tree/{{ default_branch }}) for the version in the catalog.)*{% endif %} **Shipped version:** {% if upstream.version %}{{upstream.version}}{% else %}{{manifest.version}}{% endif %}{% if current_branch != default_branch and manifest.version != default_branch_version %} *(:warning: This is the `{{ current_branch }}` branch. The [`{{ default_branch }}` branch](https://github.com/YunoHost-Apps/{{manifest.id}}_ynh/tree/{{ default_branch }}) used in the catalog is currently on version {{ default_branch_version.replace('~', '\~') }}.)*{% endif %}
{% if upstream.demo %} {% if upstream.demo %}
**Demo:** {{upstream.demo}} **Demo:** {{upstream.demo}}

View file

@ -17,7 +17,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
{% if description %}{{description}}{% else %}{{manifest.description[lang]}}{% endif %} {% if description %}{{description}}{% else %}{{manifest.description[lang]}}{% endif %}
**Version incluse :** {% if upstream.version %}{{upstream.version}}{% else %}{{manifest.version}}{% endif %}{% if branch != default_branch %} *(Vous êtes sur la branche `{{ branch }}`. Voir la [branche `{{ default_branch }}`](https://github.com/YunoHost-Apps/{{manifest.id}}_ynh/tree/{{ default_branch }}) pour la version du catalogue.)*{% endif %} **Version incluse :** {% if upstream.version %}{{upstream.version}}{% else %}{{manifest.version}}{% endif %}{% if current_branch != default_branch and manifest.version != default_branch_version %} *(:warning: Il s'agit de la branche `{{ current_branch }}`. La [branche `{{ default_branch }}`](https://github.com/YunoHost-Apps/{{manifest.id}}_ynh/tree/{{ default_branch }}) utilisée dans le catalogue est actuellement en {{ default_branch_version.replace('~', '\~') }}.)*{% endif %}
{% if upstream.demo %} {% if upstream.demo %}
**Démo :** {{upstream.demo}} **Démo :** {{upstream.demo}}