Changeset 82547 in spip-zone


Ignore:
Timestamp:
May 17, 2014, 12:09:59 PM (5 years ago)
Author:
cam.lafit@…
Message:

Ajout d'un mode de traitement pour l'export github

  • Si Mode = "create" alors création sur github, ajout de la branche distante, mise à jour github
  • Si mode = "update" alors mise à jour github

Le mode update va servir pour le cron, il est inutile de solliciter l'api github toutes les x minutes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _outils_/svn2git/trunk/git2github.sh

    r82418 r82547  
    55#hash subgit 2>/dev/null || { echo >&2 "Fonction subgit requise. Script stoppé."; exit 1; }
    66hash curl 2>/dev/null || { echo >&2 "Fonction curl requise. Script stoppé."; exit 1; }
     7
     8#Definir le mot de traitement : Création ou Mise à jour
     9if [ -z $1 ]; then
     10    echo 'Il manque le mode voulu "update" ou "create"'
     11    exit 1
     12fi
     13
     14case $1 in
     15
     16    "update")
     17        MODE="update"
     18        ;;
     19
     20    "create")
     21        MODE="create"
     22        ;;
     23    *)
     24        echo "Le mode demandé n'existe pas"
     25        exit 1
     26        ;;
     27esac
    728
    829#Initialisation des variables
     
    2647
    2748    #Creer le depot sur github
    28     echo "Création du depot ${plugin_name} sur github, si besoin"
    29     curl -X POST -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" ${GITHUB_API_URL}/orgs/spip/repos -d '{"name":"'"${plugin_name}"'"}' 2>/dev/null 1>/dev/null
     49    if [ "${MODE}" = "create" ]; then
     50        echo "Création du depot ${plugin_name} sur github, si besoin"
     51        curl -X POST -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" ${GITHUB_API_URL}/orgs/spip/repos -d '{"name":"'"${plugin_name}"'"}' 2>/dev/null 1>/dev/null
    3052
    31     #Tester la présence du plugin sur github
    32     #http://stackoverflow.com/questions/12170459/check-if-git-remote-exists-before-first-push
    33     su - gitosis -c "git --git-dir=${GIT_DIRECTORY}/${dir_plugin}.git ls-remote github -q 2>/dev/null"
     53        #Tester la présence du plugin sur github
     54        #http://stackoverflow.com/questions/12170459/check-if-git-remote-exists-before-first-push
     55        su - gitosis -c "git --git-dir=${GIT_DIRECTORY}/${dir_plugin}.git ls-remote github -q 2>/dev/null"
    3456
    35     if [ "$?" -ne "0" ]; then
    36         echo "Ajout du depot github distant pour ${dir_plugin}"
    37         #http://issues.tmatesoft.com/issue/SGT-634
    38         su - gitosis -c "git --git-dir=${GIT_DIRECTORY}/${dir_plugin}.git remote add github ${GITHUB_REPOSITORY}:${GITHUB_ORGANIZATION}/$plugin_name.git"
    39         su - gitosis -c "git --git-dir=${GIT_DIRECTORY}/${dir_plugin}.git config --add remote.github.push '+refs/heads/*:refs/heads/*'"
    40         su - gitosis -c "git --git-dir=${GIT_DIRECTORY}/${dir_plugin}.git config --add remote.github.push '+refs/tags/*:refs/tags/*'"
     57        if [ "$?" -ne "0" ]; then
     58            echo "Ajout du depot github distant pour ${dir_plugin}"
     59            #http://issues.tmatesoft.com/issue/SGT-634
     60            su - gitosis -c "git --git-dir=${GIT_DIRECTORY}/${dir_plugin}.git remote add github ${GITHUB_REPOSITORY}:${GITHUB_ORGANIZATION}/$plugin_name.git"
     61            su - gitosis -c "git --git-dir=${GIT_DIRECTORY}/${dir_plugin}.git config --add remote.github.push '+refs/heads/*:refs/heads/*'"
     62            su - gitosis -c "git --git-dir=${GIT_DIRECTORY}/${dir_plugin}.git config --add remote.github.push '+refs/tags/*:refs/tags/*'"
     63        fi
    4164    fi
    4265
    43     #Mettre à jour le depot github
    44     echo "Mise à jour du dépot gihub ${plugin_name}"
    45     su - gitosis -c "git --git-dir=${GIT_DIRECTORY}/${dir_plugin}.git push github"
     66    if [ "${MODE}" = "create" -o "$MODE" = "update" ];then
     67        #Mettre à jour le depot github
     68        echo "Mise à jour du dépot gihub ${plugin_name}"
     69        su - gitosis -c "git --git-dir=${GIT_DIRECTORY}/${dir_plugin}.git push github"
     70    fi
    4671done
Note: See TracChangeset for help on using the changeset viewer.