Skip to content

feat(update): check core branch validity and alert if missing#3375

Open
zoic21 wants to merge 2 commits into
developfrom
feat/check-core-branch-validity
Open

feat(update): check core branch validity and alert if missing#3375
zoic21 wants to merge 2 commits into
developfrom
feat/check-core-branch-validity

Conversation

@zoic21

@zoic21 zoic21 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Résumé

Vérifie que la branche (ou le tag) configurée pour le core via core::branch existe toujours sur le dépôt, et alerte l'utilisateur si elle a disparu — par exemple après la suppression d'une branche de test sélectionnée précédemment.

Changements

  • update::getCoreBranchList() : extraction de la logique de récupération des branches/tags (+ cache 24 h) qui était dupliquée inline dans administration.php. Aucune logique modifiée, simplement rendue réutilisable.
  • update::isCoreBranchValid() : valide que la branche/tag configuré figure dans la liste distante. Pour éviter les faux positifs, renvoie true lorsque la validité ne peut être déterminée : fournisseur personnalisé, branche stable connue (master/release/stable), ou liste distante indisponible (réseau KO).
  • Alerte sur les deux canaux quand la branche est introuvable :
    • item dans la page Santé (jeedom::health()),
    • message dans le centre de notifications depuis update::checkUpdate() (retiré automatiquement dès que la branche redevient valide).
  • administration.php : remplacement du bloc inline par l'appel à update::getCoreBranchList(). Le bouton de rafraîchissement (bt_refreshListBranch) continue de fonctionner : il vide le cache puis recharge, et la liste est re-récupérée à la volée.

Closes #3166


Generated by Claude Code

Add update::getCoreBranchList() by extracting the inline branch/tag
fetching logic from administration.php, and update::isCoreBranchValid()
to verify the configured core branch (or tag) still exists on the
repository. Custom providers, well-known stable branches and an
unreachable remote list all return true to avoid false positives.

Alert the user through both channels when the branch is gone:
- a health check item in jeedom::health()
- a message in the notification center from update::checkUpdate()

Closes #3166
@Mips2648 Mips2648 requested review from Mips2648 and Salvialf June 15, 2026 09:43
Comment thread core/class/jeedom.class.php Outdated
'name' => __('Branche du core', __FILE__),
'state' => $state,
'result' => ($state) ? $branch : $branch . ' (' . __('introuvable', __FILE__) . ')',
'comment' => ($state) ? '' : __("La branche configurée pour le core n'existe plus sur le dépôt. Allez dans Réglages -> Système -> Mises à jour / Réinitialisation pour sélectionner une branche valide.", __FILE__),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ca n'existe pas ce bouton "Réinitialisation" ou j'ai raté un truc?

* Résultat mis en cache 24h (clé core::branch::default::list).
* @param bool $_refresh force le rafraichissement du cache
* @return array tableau contenant les clés 'branchs' et 'tags'
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commentaire à mettre en anglais + respect du format PHPDoc

Comment thread core/class/update.class.php Outdated
* @param bool $_refresh force le rafraichissement du cache
* @return array tableau contenant les clés 'branchs' et 'tags'
*/
public static function getCoreBranchList($_refresh = false) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je suggère de typer les arguments de fonctions dorénavant => ici bool

* Vérifie que la branche (ou le tag) configurée pour le core existe toujours sur le dépôt.
* Retourne true si la validité ne peut être déterminée (fournisseur custom, branche stable, ou liste distante indisponible).
* @return bool
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commentaire à mettre en anglais + respect du format PHPDoc

Comment thread core/class/update.class.php Outdated
return true;
}
$branch = config::byKey('core::branch', 'core', 'master');
if (in_array($branch, array('master', 'release', 'stable'))) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ca n'existe pas "stable"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

et faut-il vraiment faire un cas particulier?
la branche master ou release pourrait être vérifiée comme toutes les autres plus bas ainsi si un jour ca change on ne doit pas revenir sur ce code

Comment thread core/class/jeedom.class.php Outdated
'state' => $state,
'result' => ($state) ? $branch : $branch . ' (' . __('introuvable', __FILE__) . ')',
'comment' => ($state) ? '' : __("La branche configurée pour le core n'existe plus sur le dépôt. Allez dans Réglages -> Système -> Mises à jour / Réinitialisation pour sélectionner une branche valide.", __FILE__),
'key' => 'core::branch'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est voulu d'avoir "::" ? jusqu'ici aucune clé n'avait ce format dans cette fonction

Comment thread core/class/update.class.php Outdated
if (self::isCoreBranchValid()) {
message::removeAll('core', 'core::branch::invalid');
} else {
message::add('core', __("La branche configurée pour le core n'existe plus sur le dépôt. Allez dans Réglages -> Système -> Mises à jour / Réinitialisation pour sélectionner une branche valide.", __FILE__), '', 'core::branch::invalid');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message dupliqué de la fonction "health" dans jeedom.class.php; peut-être qu'on peut améliorer ca?

Comment thread core/class/update.class.php Outdated
if (self::isCoreBranchValid()) {
message::removeAll('core', 'core::branch::invalid');
} else {
message::add('core', __("La branche configurée pour le core n'existe plus sur le dépôt. Allez dans Réglages -> Système -> Mises à jour / Réinitialisation pour sélectionner une branche valide.", __FILE__), '', 'core::branch::invalid');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

la fonction "Réinitialisation" est toujours un mystère

- translate the new PHPDoc blocks to English and fix their format
- type-hint getCoreBranchList(bool $_refresh)
- drop the master/release/stable special case and validate every branch
  against the remote list ('stable' was not a real branch anyway)
- deduplicate the user message via update::getCoreBranchInvalidMessage(),
  reused by jeedom::health() and update::checkUpdate()
- fix the message: point to Settings -> System -> Mises a jour/Market
- rename the health key core::branch -> coreBranch for consistency

zoic21 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Merci pour la relecture @Mips2648 👍 Points traités dans le dernier commit :

  • PHPDoc (getCoreBranchList, isCoreBranchValid) : passés en anglais + format corrigé.
  • Typage : getCoreBranchList(bool $_refresh = false).
  • Cas particulier master/release/stable : supprimé. Toutes les branches sont désormais validées de la même façon via la liste distante (master y figure déjà), donc plus rien de codé en dur — et stable qui n'existait pas disparaît.
  • Message dupliqué entre health() et checkUpdate() : factorisé dans update::getCoreBranchInvalidMessage(), réutilisé des deux côtés.
  • Texte « Réinitialisation » : corrigé, le message pointe maintenant vers Réglages -> Système -> Mises à jour/Market (l'onglet réel de sélection de branche).
  • Clé core::branch du health() : renommée en coreBranch pour rester cohérente avec les autres clés de la fonction.

Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check config core::branch validity

2 participants