commit c68019a2050c7657ef84aea0b75c43fc8637435e Author: Thibaud Date: Thu Nov 20 15:28:54 2025 +0100 Initial commit diff --git a/00_checkout_branch.sh b/00_checkout_branch.sh new file mode 100755 index 0000000..5fccb60 --- /dev/null +++ b/00_checkout_branch.sh @@ -0,0 +1,22 @@ +#!/bin/env bash + +DIRNAME=`dirname $0` + +git_current_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' +} +CUR_BRANCH=`git_current_branch` + +CIBLE=$1 +if [ "$CIBLE" == "" ] +then + CIBLE=$CUR_BRANCH +fi + +$DIRNAME/01_quick_commit.sh + +if [ ! "$CIBLE" = "$CUR_BRANCH" ]; +then + git checkout $CIBLE + git pull +fi diff --git a/00_status.sh b/00_status.sh new file mode 100755 index 0000000..8b466d2 --- /dev/null +++ b/00_status.sh @@ -0,0 +1,30 @@ +#!/bin/env bash + +DIRNAME=`dirname $0` + +git_current_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' +} +CUR_BRANCH=`git_current_branch` + +TEST=`git status | grep propre | wc -l` +if [ $TEST -eq 0 ] +then + echo "La branche actuelle ($CUR_BRANCH) n'est pas propre" + + echo # (optional) move to a new line + read -p "Voulez-vous voir les modifications courantes ? " -n 1 -r + echo # (optional) move to a new line + if [[ $REPLY =~ ^[YyOo]$ ]] + then + git status + fi + + echo # (optional) move to a new line + read -p "Voulez-vous ajouter les modifications courantes ? " -n 1 -r + echo # (optional) move to a new line + if [[ $REPLY =~ ^[YyOo]$ ]] + then + git add . + fi +fi diff --git a/01_quick_commit.sh b/01_quick_commit.sh new file mode 100755 index 0000000..344bac8 --- /dev/null +++ b/01_quick_commit.sh @@ -0,0 +1,12 @@ +#!/bin/env bash + +DIRNAME=`dirname $0` +TIMESTAMP=`date "+%Y%m%d%H%M"` + +$DIRNAME/00_status.sh + +TEST=`git status | grep propre | wc -l` +if [ $TEST -eq 0 ] +then + git commit -m "$TIMESTAMP" +fi diff --git a/02_add_branch.sh b/02_add_branch.sh new file mode 100755 index 0000000..a9840c3 --- /dev/null +++ b/02_add_branch.sh @@ -0,0 +1,27 @@ +#!/bin/env bash + +DIRNAME=`dirname $0` + +if [ "$1" == "" ] +then + echo "Il faut préciser un nom de branche !" + exit 1 +fi + +$DIRNAME/01_quick_commit.sh + +courante=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | sed 's:(::g' | sed 's:)::g'` +if [ $courante != develop ] +then + echo "La branche actuelle n'est pas develop" + read -p "Voulez-vous basculer sur develop ? " -n 1 -r + echo # (optional) move to a new line + if [[ $REPLY =~ ^[YyOo]$ ]] + then + $DIRNAME/00_checkout_branch.sh develop + fi +fi + +git branch $1 +git checkout $1 +git push --set-upstream all $1 diff --git a/03_push_branch.sh b/03_push_branch.sh new file mode 100755 index 0000000..c74acaf --- /dev/null +++ b/03_push_branch.sh @@ -0,0 +1,28 @@ +#!/bin/env bash + +DIRNAME=`dirname $0` + +git_current_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' +} +CUR_BRANCH=`git_current_branch` + +CIBLE=$1 +if [ "$CIBLE" == "" ] +then + CIBLE=$CUR_BRANCH +fi + +$DIRNAME/01_quick_commit.sh + +if [ ! "$CIBLE" = "$CUR_BRANCH" ]; +then + $DIRNAME/00_checkout_branch.sh $CIBLE +fi + +git push all + +if [ ! "$CIBLE" = "$CUR_BRANCH" ]; +then + $DIRNAME/00_checkout_branch.sh $CUR_BRANCH +fi diff --git a/04_merge_branch.sh b/04_merge_branch.sh new file mode 100755 index 0000000..d2e8960 --- /dev/null +++ b/04_merge_branch.sh @@ -0,0 +1,39 @@ +#!/bin/env bash + +DIRNAME=`dirname $0` + +echo "Il vaudrait mieux passer par https://git.topisto.net/topisto/suivi_projets" +read -p "Are you sure ?" -n 1 -r +echo # (optional) move to a new line +if [[ $REPLY =~ ^[Yy]$ ]] +then + + # do dangerous stuff + + $DIRNAME/01_quick_commit.sh + + courante=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | sed 's:(::g' | sed 's:)::g'` + cible=develop + + if [ "$courante" = "develop" ] + then + cible=hotfix + fi + + if [ "$courante" = "hotfix" ] + then + cible=production + fi + + echo merge $courante into $cible + + git push + + git checkout $cible + + git merge $courante + + git push + + git checkout $courante +fi diff --git a/05_delete_feature_branch.sh b/05_delete_feature_branch.sh new file mode 100755 index 0000000..ae6e6e7 --- /dev/null +++ b/05_delete_feature_branch.sh @@ -0,0 +1,48 @@ +#!/bin/env bash +DIRNAME=`dirname $0` + +git_current_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' +} +CUR_BRANCH=`git_current_branch` + +CIBLE=$1 +if [ "$CIBLE" == "" ] +then + CIBLE=$CUR_BRANCH +fi + +internal_delete_branch() { + git branch -D $1 + git push all --delete $1 +} + +delete_branch() { + read -p "Delete $1 (y/n) ? " choice + case "$choice" in + y|Y|o|O ) internal_delete_branch $1;; + n|N ) echo "no";; + * ) echo "invalid choice ($choice)";; + esac +} + +$DIRNAME/03_push_branch.sh + +if [ ! "$CUR_BRANCH" = "develop" ] +then + echo "La branche actuelle n'est pas develop" + read -p "Voulez-vous basculer sur develop ? " -n 1 -r + echo # (optional) move to a new line + if [[ $REPLY =~ ^[YyOo]$ ]] + then + $DIRNAME/00_checkout_branch.sh develop + fi +fi + +case $CIBLE in + ($CUR_BRANCH) echo "Impossible : $CIBLE is current branch !";; + ("evo"*) delete_branch $CIBLE;; + ("ano"*) delete_branch $CIBLE;; + (*) echo "$CIBLE is not a feature branch";; +esac + diff --git a/06_delete_all_features_branch.sh b/06_delete_all_features_branch.sh new file mode 100755 index 0000000..f50a92e --- /dev/null +++ b/06_delete_all_features_branch.sh @@ -0,0 +1,10 @@ +#!/bin/env bash + +DIRNAME=`dirname $0` + +for branche in $(git branch | cut -c 3-) +do + echo "branch $branche detected" + $DIRNAME/05_delete_feature_branch.sh $branche +done + diff --git a/git_filter_secrets.sh b/git_filter_secrets.sh new file mode 100644 index 0000000..5ae7e11 --- /dev/null +++ b/git_filter_secrets.sh @@ -0,0 +1,47 @@ +#!/bin/env bash + +# +# Étape 1 : ajouter les lignes suivantes dans .git/config +# +# [filter "secrets"] +# clean = ../scripts/filter-secrets.sh clean +# smudge = ../scripts/filter-secrets.sh smudge +# +# Étape 2 : ajouter les lignes suivantes dans le .git/info/attributes +# NB : il s'agit de la liste des fichiers sur lequel git doit appliquer le filtre +# +# config.yaml filter=secrets +# .env filter=secrets +# +# + +if [ "$1" == "clean" ]; then + # Clean (replace sensitive data with placeholders) + sed -e 's/XXXXXXXXX/{API_KEY_PLACEHOLDER}/g' \ + -e 's/YYYYYYYYY/{SENDING_API_KEY_PLACEHOLDER}/g' \ + -e 's/ZZZZZZZZZ/{SMTP_PASSWORD_PLACEHOLDER}/g' \ + -e 's/AAAAAAAAA/{POSTGRES_PASSWORD_PLACEHOLDER}/g' \ + -e 's/BBBBBBBBB/{TWS_USERID_PLACEHOLDER}/g' \ + -e 's/CCCCCCCCCC/{TWS_PASSWORD_PLACEHOLDER}/g' + + # Si une erreur se produit avec sed, renvoyer un code d'erreur + if [ $? -ne 0 ]; then + echo "Erreur lors de l'exécution du clean" + exit 1 + fi +elif [ "$1" == "smudge" ]; then + # Smudge (replace placeholders with sensitive data) + sed -e 's/{API_KEY_PLACEHOLDER}/XXXXXXXXX/g' \ + -e 's/{SENDING_API_KEY_PLACEHOLDER}/YYYYYYYYY/g' \ + -e 's/{SMTP_PASSWORD_PLACEHOLDER}/ZZZZZZZZZ/g' \ + -e 's/{POSTGRES_PASSWORD_PLACEHOLDER}/AAAAAAAAA/g' \ + -e 's/{TWS_USERID_PLACEHOLDER}/BBBBBBBBB/g' \ + -e 's/{TWS_PASSWORD_PLACEHOLDER}/CCCCCCCCCC/g' + + if [ $? -ne 0 ]; then + echo "Erreur lors de l'exécution du smudge" + exit 1 + fi +fi +exit 0 +