Changeset 119866 in spip-zone


Ignore:
Timestamp:
Jan 20, 2020, 1:53:10 PM (8 months ago)
Author:
Cerdic
Message:

normalisation des noms de fonctions vcs, surchargeables et une fonction helper pour les charger

Location:
_plugins_/trad-lang/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/trad-lang/trunk

    • Property subgit:lock:056bb918d1d80216dcf3142e45cab3196d6c1116 deleted
    • Property subgit:lock:467a6f56f89cb312b600e8226491c91e985b3895 set to 2020-01-20T15:00:36.304
  • _plugins_/trad-lang/trunk/inc/salvatore.php

    r119862 r119866  
    396396}
    397397
     398/**
     399 * Charger une fonction vcs
     400 * @param string $methode (git|svn)
     401 * @param string $function
     402 * @return string
     403 * @throws Exception
     404 */
     405function salvatore_vcs_function($methode, $function) {
     406        include_spip('salvatore/vcs/' . $methode);
     407        if (function_exists($f = "salvatore_vcs_{$methode}_$function")
     408          or function_exists($f = $f . '_dist')) {
     409                return $f;
     410        }
     411        throw new \Exception("Erreur fonction $f inexistante");
     412}
    398413
    399414/**
  • _plugins_/trad-lang/trunk/salvatore/ecriveur.php

    r119865 r119866  
    419419        }
    420420
    421         $salvatore_lastmodified_file = "salvatore_" . $source['methode'] . "_lastmodified_file";
    422         return $salvatore_lastmodified_file($dir_depots . $source['dir_checkout'], $file_path_relative);
     421        $vcs_lastmodified_file = salvatore_vcs_function($source['methode'],  "lastmodified_file");
     422        return $vcs_lastmodified_file($dir_depots . $source['dir_checkout'], $file_path_relative);
    423423}
    424424
     
    438438        $files_list = [$pre . $module . '_*', $pre . $module . '.xml'];
    439439
    440         $salvatore_status_file = "salvatore_" . $source['methode'] . "_status_file";
    441         return $salvatore_status_file($dir_depots . $source['dir_checkout'], $files_list);
    442 }
     440        $vcs_status_file = salvatore_vcs_function($source['methode'],  "status_file");
     441        return $vcs_status_file($dir_depots . $source['dir_checkout'], $files_list);
     442}
  • _plugins_/trad-lang/trunk/salvatore/pousseur.php

    r119864 r119866  
    118118
    119119        $commits_todo = array();
    120         $salvatore_status_file = "salvatore_" . $source['methode'] . "_status_file";
    121         $salvatore_commit_files = "salvatore_" . $source['methode'] . "_commit_files";
    122         $salvatore_push_repository = "salvatore_" . $source['methode'] . "_push_repository";
     120        $vcs_status_file = salvatore_vcs_function($source['methode'],  "status_file");
     121        $vcs_commit_files = salvatore_vcs_function($source['methode'],  "commit_files");
     122        $vcs_push_repository = salvatore_vcs_function($source['methode'],  "push_repository");
    123123
    124124        foreach ($commit_infos as $what => $commit_info) {
     
    127127
    128128                if ($commit_info['lastmodified'] or $commit_info['must_add']) {
    129                         $status = $salvatore_status_file($dir_depots . $source['dir_checkout'], $subdir . $file);
     129                        $status = $vcs_status_file($dir_depots . $source['dir_checkout'], $subdir . $file);
    130130
    131131                        // fichier nouveau ou modifie (sinon on l'ignore)
     
    187187                salvatore_log("\t" . str_replace("\n", "\n\t", $message));
    188188
    189                 list($res,$out) = $salvatore_commit_files($dir_depots . $source['dir_checkout'], $commit_todo['files'], $message, $author, empty($source['user']) ? null : $source['user'], empty($source['pass']) ? null : $source['pass']);
     189                list($res,$out) = $vcs_commit_files($dir_depots . $source['dir_checkout'], $commit_todo['files'], $message, $author, empty($source['user']) ? null : $source['user'], empty($source['pass']) ? null : $source['pass']);
    190190                salvatore_log($out);
    191191                if (!$res) {
     
    200200        // et push si besoin
    201201        // ne fera rien en svn (deja pushe)
    202         list($res,$out) = $salvatore_push_repository($dir_depots . $source['dir_checkout'], empty($source['user']) ? null : $source['user'], empty($source['pass']) ? null : $source['pass']);
     202        list($res,$out) = $vcs_push_repository($dir_depots . $source['dir_checkout'], empty($source['user']) ? null : $source['user'], empty($source['pass']) ? null : $source['pass']);
    203203        salvatore_log($out);
    204204        if (!$res) {
  • _plugins_/trad-lang/trunk/salvatore/vcs/git.php

    r119864 r119866  
    4949 * @return false|int
    5050 */
    51 function salvatore_git_lastmodified_file($dir_repo, $file) {
     51function salvatore_vcs_git_lastmodified_file_dist($dir_repo, $file) {
    5252
    5353        $d = getcwd();
     
    6666 * @return string
    6767 */
    68 function salvatore_git_status_file($dir_repo, $file_or_files) {
     68function salvatore_vcs_git_status_file_dist($dir_repo, $file_or_files) {
    6969
    7070        if (is_array($file_or_files)) {
     
    9696 * @return array
    9797 */
    98 function salvatore_git_commit_files($dir_repo, $files, $message, $author, $user=null, $pass=null) {
     98function salvatore_vcs_git_commit_files_dist($dir_repo, $files, $message, $author, $user=null, $pass=null) {
    9999        $files = array_map('escapeshellarg', $files);
    100100        $files = implode(' ', $files);
     
    133133 * @return array
    134134 */
    135 function salvatore_git_push_repository($dir_repo, $user=null, $pass=null) {
     135function salvatore_vcs_git_push_repository_dist($dir_repo, $user=null, $pass=null) {
    136136        $d = getcwd();
    137137        chdir($dir_repo);
  • _plugins_/trad-lang/trunk/salvatore/vcs/svn.php

    r119864 r119866  
    3333 * @return false|int
    3434 */
    35 function salvatore_svn_lastmodified_file($dir_repo, $file) {
     35function salvatore_vcs_svn_lastmodified_file_dist($dir_repo, $file) {
    3636
    3737        $d = getcwd();
     
    5050 * @return string
    5151 */
    52 function salvatore_svn_status_file($dir_repo, $file_or_files) {
     52function salvatore_vcs_svn_status_file_dist($dir_repo, $file_or_files) {
    5353
    5454        if (is_array($file_or_files)) {
     
    8080 * @return array
    8181 */
    82 function salvatore_svn_commit_files($dir_repo, $files, $message, $author, $user=null, $pass=null) {
     82function salvatore_vcs_svn_commit_files_dist($dir_repo, $files, $message, $author, $user=null, $pass=null) {
    8383
    8484        // lister deja les fichiers qui necessitent un svn add (fichiers ajoutes qui ne sont pas dans le repo)
    8585        $files_to_add = array();
    8686        foreach ($files as $file) {
    87                 if (!salvatore_svn_lastmodified_file($dir_repo, $file)) {
     87                if (!salvatore_vcs_svn_lastmodified_file($dir_repo, $file)) {
    8888                        $files_to_add[] = $file;
    8989                }
     
    153153 * @return array
    154154 */
    155 function salvatore_svn_push_repository($dir_repo, $user=null, $pass=null) {
     155function salvatore_vcs_svn_push_repository_dist($dir_repo, $user=null, $pass=null) {
    156156        return array(true, '');
    157157}
Note: See TracChangeset for help on using the changeset viewer.