From c1bd66d91ba074c250dd093a4fe2f8dca64efa95 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Tue, 4 Jun 2024 08:48:11 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- bin/nlp | 48 ++++++++++++++++++++++++++++++++++++++++++++++ bin/{pci => nlpci} | 0 bin/{pp => nlpp} | 0 bin/{pu => nlpu} | 0 4 files changed, 48 insertions(+) create mode 100755 bin/nlp rename bin/{pci => nlpci} (100%) rename bin/{pp => nlpp} (100%) rename bin/{pu => nlpu} (100%) diff --git a/bin/nlp b/bin/nlp new file mode 100755 index 0000000..c208111 --- /dev/null +++ b/bin/nlp @@ -0,0 +1,48 @@ +#!/bin/bash +# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 +source "$(dirname -- "$0")/../load.sh" || exit 1 +require: git + +chdir= +all= +args=( + "afficher l'état du dépôt" + "[-d chdir] [-a patterns...] + +Si l'option -a est utilisée, ce script accepte comme arguments une liste de patterns permettant de filtrer les répertoires concernés" + -d:,--chdir:BASEDIR chdir= "répertoire dans lequel se placer avant de lancer les opérations" + -a,--all all=1 "faire l'opération sur tous les sous-répertoires de BASEDIR qui sont des dépôts git" +) +parse_args "$@"; set -- "${args[@]}" + +if [ -n "$chdir" ]; then + cd "$chdir" || die +fi + +if [ -n "$all" ]; then + # liste de sous répertoires + if [ $# -gt 0 ]; then + # si on a une liste de patterns, l'utiliser + setx -a dirs=ls_dirs . "$@" + else + dirs=() + for dir in */.git; do + [ -d "$dir" ] || continue + dirs+=("${dir%/.git}") + done + fi + setx cwd=pwd + for dir in "${dirs[@]}"; do + cd "$dir" || die + setx status=git status --porcelain + cd "$cwd" + if [ -n "$status" ]; then + etitle "$dir" echo "$status" + fi + done +else + # répertoire courant uniquement + args=() + isatty || args+=(--porcelain) + git status "${args[@]}" +fi diff --git a/bin/pci b/bin/nlpci similarity index 100% rename from bin/pci rename to bin/nlpci diff --git a/bin/pp b/bin/nlpp similarity index 100% rename from bin/pp rename to bin/nlpp diff --git a/bin/pu b/bin/nlpu similarity index 100% rename from bin/pu rename to bin/nlpu