diff --git a/lib/ulib/.ulibver b/lib/ulib/.ulibver index 1dafc22..52ac9b1 100644 --- a/lib/ulib/.ulibver +++ b/lib/ulib/.ulibver @@ -1 +1 @@ -007003000 +007004000 diff --git a/lib/ulib/vcs b/lib/ulib/vcs index b3e6ed9..758c9cc 100644 --- a/lib/ulib/vcs +++ b/lib/ulib/vcs @@ -530,6 +530,45 @@ function git_ensure_cleancheckout() { check_cleancheckout || die "Vous avez des modifications locales. Enregistrez ces modifications avant de continuer" } +# fonctions pour git annex +function git_annex_initial() { + # sur le dépôt $1 fraichement cloné, vérifier s'il faut faire git annex + # init. Si oui, l'initialiser avec le nom d'hôte, et récupérer tous les + # fichiers annexés + # retourner 1 si une erreur s'est produite + local repodir="${1:-.}" + [ -d "$repodir" ] || return 1 + repodir="$(abspath "$repodir")" + + local GIT_DIR GIT_WORK_TREE + [ "$(cd "$repodir"; git rev-parse --is-bare-repository)" == false ] || return 0 + [ -n "$(GIT_DIR="$repodir/.git" git config annex.uuid)" ] && return 0 + + # ici, on sait que git annex n'a pas encore été configuré + # vérifier s'il existe des fichiers annexés + local -a links + array_from_lines links "$(find "$repodir" -type l)" + local link hasannex= + for link in "${links[@]}"; do + link="$(readlink "$link")" + if [ "${link#.git/annex/}" != "$link" ]; then + hasannex=1 + break + elif [[ "$link" == "*/.git/annex/*" ]]; then + hasannex=1 + break + fi + done + + if [ -n "$hasannex" ]; then + (cd "$repodir" + git annex init "$MYHOSTNAME" && + git annex get && + git annex sync + ) || return 1 + fi +} + ################################################################################ # Subversion diff --git a/uproject b/uproject index 1c03301..48c9fa1 100755 --- a/uproject +++ b/uproject @@ -52,6 +52,13 @@ COMMANDS Afficher les différences depuis la révision REV. -R Afficher les modifications effectuées depuis la dernière release. + clone git@host:path/to/repo [destdir] + Cloner un dépôt distant. Initialiser git annex si le dépôt contient des + fichiers annexés. Récupérer aussi ces fichiers avec 'git annex get' + + crone git@host:path/to/repo [destdir] + Créer un dépôt distant sur gitolite, puis le cloner + annex [args] Lancer git annex avec les arguments spécifiés. xadd @@ -66,9 +73,10 @@ COMMANDS xget Comme ci-dessus, mais si la commande s'exécute sans erreur, lancer aussi 'git annex sync' - - crone git@host:path/to/repo - Créer puis cloner un dépôt distant sur gitolite + xinitial + Sur un dépôt fraichement cloné, initialiser le dépôt avec 'annex init' + s'il contient des fichiers annexés. Récupérer aussi ces fichiers avec + 'annex get' printml [-t TYPE] Afficher le modeline pour un fichier du type spécifié @@ -94,6 +102,8 @@ SCRIPT_ALIASES=( pxx:annex pxa:xadd pxu:xunlock pxc:xcopy pxd:xdrop pxm:xmove pxg:xget pxs:xsync pxw:xwhereis + pxinitial:xinitial + pclone:clone pcrone:crone pnew:new pgr:grep @@ -125,7 +135,7 @@ CMD_ALIASES=( DEFAULT_CMD=status PY_CMDS=(new) VCS_CMDS=(getvcs getroot getrepos geturl vcs add remove copy move mkdir commit status update push diff tag) -GITANNEX_CMDS=(annex xadd xunlock xcopy xdrop xmove xget xsync xwhereis) +GITANNEX_CMDS=(annex xadd xunlock xcopy xdrop xmove xget xsync xwhereis xinitial) ML_CMDS=(printml addml) if [ "$#" -eq 1 -a "$1" == --nutools-makelinks ]; then @@ -198,12 +208,29 @@ elif array_contains GITANNEX_CMDS "$CMD"; then case "$CMD" in annex) git annex "$@";; xcopy|xmove|xget) git annex "${CMD#x}" "$@" && git annex sync;; + xinitial) git_annex_initial "$@";; *) git annex "${CMD#x}" "$@";; esac +elif [ "$CMD" == clone ]; then + repourl="${1%.git}" + [ -n "$repourl" ] || die "Vous devez spécifier l'url du dépôt git" + + destdir="$2" + [ -n "$destdir" ] || setx destdir=basename -- "$destdir" + [ -d "$destdir" ] && die "$(ppath "$destdir"): répertoire existant" + + git clone "$repourl" "$destdir" || die + git_annex_initial "$destdir" || die + elif [ "$CMD" == crone ]; then repourl="${1%.git}" [ -n "$repourl" ] || die "Vous devez spécifier l'url du dépôt git" + + destdir="$2" + [ -n "$destdir" ] || setx destdir=basename -- "$destdir" + [ -d "$destdir" ] && die "$(ppath "$destdir"): répertoire existant" + splitfsep "$repourl" : userhost path splituserhost "$userhost" user host [ -n "$user" ] || user=git @@ -212,7 +239,8 @@ elif [ "$CMD" == crone ]; then [ -n "$path" ] || die "Vous devez spécifier le chemin du dépôt git" ${GIT_SSH:-ssh} "$userhost" create "$path" || die - git clone "$userhost:$path" + git clone "$userhost:$path" "$destdir" || die + git_annex_initial "$destdir" || die elif array_contains PY_CMDS "$CMD"; then exec "$scriptdir/lib/pywrapper" uproject.py "$CMD" "$@"