diff --git a/git_00_checkout_branch.sh b/git_00_checkout_branch.sh deleted file mode 100755 index bb12f3e..0000000 --- a/git_00_checkout_branch.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/env bash - -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 - -git_01_quick_commit.sh - -if [ ! "$CIBLE" = "$CUR_BRANCH" ]; -then - git checkout $CIBLE - git pull -fi diff --git a/git_00_status.sh b/git_00_status.sh deleted file mode 100755 index 7a8a80f..0000000 --- a/git_00_status.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/env bash - -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/git_01_quick_commit.sh b/git_01_quick_commit.sh index 0cdd53e..78f8b04 100755 --- a/git_01_quick_commit.sh +++ b/git_01_quick_commit.sh @@ -1,11 +1,13 @@ #!/bin/env bash TIMESTAMP=`date "+%Y%m%d%H%M"` +COURANTE=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | sed 's:(::g' | sed 's:)::g' | xargs` -git_00_status.sh +git add . -TEST=`git status | grep propre | wc -l` -if [ $TEST -eq 0 ] +TEST=$(git_99_status.sh) + +if [ ! "$TEST" = "GIT STATUS OK" ] then - git commit -m "$TIMESTAMP" + git commit -m "[$COURANTE] $TIMESTAMP" fi diff --git a/git_02_add_branch.sh b/git_02_add_branch.sh index a947d23..e5bad92 100755 --- a/git_02_add_branch.sh +++ b/git_02_add_branch.sh @@ -16,7 +16,7 @@ then echo # (optional) move to a new line if [[ $REPLY =~ ^[YyOo]$ ]] then - git_00_checkout_branch.sh develop + git_98_checkout_branch.sh develop fi fi diff --git a/git_03_push_branch.sh b/git_03_push_branch.sh index aa4dae2..b7d1d49 100755 --- a/git_03_push_branch.sh +++ b/git_03_push_branch.sh @@ -1,26 +1,22 @@ #!/bin/env bash -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 + echo "Using $GIT_CURRENT_BRANCH as cible" + CIBLE=$GIT_CURRENT_BRANCH fi git_01_quick_commit.sh -if [ ! "$CIBLE" = "$CUR_BRANCH" ]; +if [ ! "$CIBLE" = "$GIT_CURRENT_BRANCH" ]; then - git_00_checkout_branch.sh $CIBLE + git_98_checkout_branch.sh $CIBLE fi git push all -if [ ! "$CIBLE" = "$CUR_BRANCH" ]; +if [ ! "$CIBLE" = "$GIT_CURRENT_BRANCH" ]; then - git_00_checkout_branch.sh $CUR_BRANCH + git_98_checkout_branch.sh $GIT_CURRENT_BRANCH fi diff --git a/git_05_delete_feature_branch.sh b/git_05_delete_feature_branch.sh index 1e63426..26432d5 100755 --- a/git_05_delete_feature_branch.sh +++ b/git_05_delete_feature_branch.sh @@ -1,14 +1,10 @@ #!/bin/env bash -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 + Using $GIT_CURRENT_BRANCH as cible + CIBLE=$GIT_CURRENT_BRANCH fi internal_delete_branch() { @@ -27,19 +23,19 @@ delete_branch() { git_03_push_branch.sh -if [ ! "$CUR_BRANCH" = "develop" ] +if [ ! "$GIT_CURRENT_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 - git_00_checkout_branch.sh develop + git_98_checkout_branch.sh develop fi fi case $CIBLE in - ($CUR_BRANCH) echo "Impossible : $CIBLE is current branch !";; + ($GIT_CURRENT_BRANCH) echo "Impossible : $CIBLE is current branch !";; ("evo"*) delete_branch $CIBLE;; ("ano"*) delete_branch $CIBLE;; (*) echo "$CIBLE is not a feature branch";; diff --git a/git_07_rename_branch.sh b/git_07_rename_branch.sh new file mode 100755 index 0000000..7235a62 --- /dev/null +++ b/git_07_rename_branch.sh @@ -0,0 +1,34 @@ +#!/bin/env bash + +if [ ! $# -eq 2 ] +then + echo "usage : rename old_branch new_branch" + exit 1 +fi + + +# Source - https://stackoverflow.com/a +# Posted by CodeWizard, modified by community. See post 'Timeline' for change history +# Retrieved 2025-11-21, License - CC BY-SA 4.0 + +# Names of things - allows you to copy/paste commands +old_name=$1 +new_name=$2 +remote=all + +# Rename the local branch to the new name +git branch -m $old_name $new_name + +# Delete the old branch on remote +git push $remote --delete $old_name + +# Prevent git from using the old name when pushing in the next step. +# Otherwise, git will use the old upstream name instead of $new_name. +git branch --unset-upstream $new_name + +# Push the new branch to remote +git push $remote $new_name + +# Reset the upstream branch for the new_name local branch +git push $remote -u $new_name + diff --git a/git_98_checkout_branch.sh b/git_98_checkout_branch.sh new file mode 100755 index 0000000..e336e94 --- /dev/null +++ b/git_98_checkout_branch.sh @@ -0,0 +1,15 @@ +#!/bin/env bash + +CIBLE=$1 +if [ "$CIBLE" == "" ] +then + CIBLE=$GIT_CURRENT_BRANCH +fi + +git_01_quick_commit.sh + +if [ ! "$CIBLE" = "$GIT_CURRENT_BRANCH" ]; +then + git checkout $CIBLE + git pull +fi diff --git a/git_99_status.sh b/git_99_status.sh new file mode 100755 index 0000000..6bbb5e3 --- /dev/null +++ b/git_99_status.sh @@ -0,0 +1,22 @@ +#!/bin/env bash + +TEST1=`git status | grep propre | wc -l` +if [ $TEST1 -eq 0 ] +then + echo "La branche actuelle ($GIT_CURRENT_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 +fi + +TEST2=`git status | grep propre | wc -l` +if [ $TEST1 -eq 1 ] +then + echo "GIT STATUS OK" +fi diff --git a/hq b/hq new file mode 100644 index 0000000..18896fc --- /dev/null +++ b/hq @@ -0,0 +1,113 @@ +commit e42cfcb7dc3e79302c1eb124a65bf745cc379e10 (HEAD -> develop) +Author: Thibaud +Date: Thu Dec 18 08:51:37 2025 +0100 + + [develop] 202512180851 + +commit 2a9ae666fa1510332404ea8c7e85668e5dc1869d +Author: Thibaud +Date: Thu Dec 18 08:50:30 2025 +0100 + + [ develop ] 202512180850 + +commit 3af764626489262da68f290efa00d39d0f6c7755 +Author: Thibaud +Date: Thu Dec 18 08:46:52 2025 +0100 + + [ develop ] 202512180846 + +commit b33ea191abfb2f5c7803effa9a49b3bf24f56982 +Author: Thibaud +Date: Thu Dec 18 08:44:56 2025 +0100 + + develop : 202512180844 + +commit cedf94d2fe2999969ce0a15a018476458928f27d (origin/develop) +Author: Thibaud +Date: Wed Nov 26 08:20:02 2025 +0100 + + 202511260820 + +commit 095d35d999210b34b40bc7556d787282b69b7546 +Author: Thibaud +Date: Wed Nov 26 08:18:28 2025 +0100 + + 202511260818 + +commit 3b4d658e9c5045ddbe93c95d02426ce6cc50e5f6 +Author: Thibaud +Date: Fri Nov 21 14:57:29 2025 +0100 + + 202511211457 + +commit 693b63ec7f80c57c5827635e88665a1e478726af +Author: Thibaud +Date: Fri Nov 21 14:55:57 2025 +0100 + + 202511211455 + +commit 227cf54995382d7b757b90d63995b1b8e4e8435f +Author: Thibaud +Date: Fri Nov 21 13:20:34 2025 +0100 + + 202511211320 + +commit 8483b06342a43230ff0b6a721b3d9ad0cf2f0774 +Author: Thibaud +Date: Fri Nov 21 12:53:49 2025 +0100 + + 202511211253 + +commit ac3003b23e416025124ba718e74a3db9026e3ae3 +Author: Thibaud +Date: Fri Nov 21 12:40:24 2025 +0100 + + 202511211240 + +commit fd00e31ba701a5e736f51afa46b186ad2d51c100 +Author: Thibaud +Date: Fri Nov 21 12:34:39 2025 +0100 + + 202511211234 + +commit bf218c2f8e242d47dfca9cb73d99e048bd932ad4 +Author: Thibaud +Date: Fri Nov 21 12:32:37 2025 +0100 + + 202511211232 + +commit 0d3e70a9c49c649a80fcd98b47464373c0446a3f +Author: Thibaud +Date: Fri Nov 21 12:27:52 2025 +0100 + + 202511211227 + +commit 85afb168dd65b03c6f88c99f037fe32ff0c4d3f6 +Author: Thibaud +Date: Fri Nov 21 12:24:52 2025 +0100 + + 202511211224 + +commit 4c3cf65a0d5073e86aa658999b06253a36885fa5 +Author: Thibaud +Date: Thu Nov 20 16:10:29 2025 +0100 + + 202511201610 + +commit 9d93b82d0734e692958494f2c46263fb77340db2 (origin/production, origin/hotfix, production, hotfix) +Author: Thibaud +Date: Thu Nov 20 16:00:08 2025 +0100 + + 202511201600 + +commit 689995449d46f3bfdd438758387a86e78ffc3b9e +Author: Thibaud +Date: Thu Nov 20 15:41:06 2025 +0100 + + 202511201541 + +commit c68019a2050c7657ef84aea0b75c43fc8637435e +Author: Thibaud +Date: Thu Nov 20 15:28:54 2025 +0100 + + Initial commit diff --git a/mygitflow b/mygitflow index 573b00c..922690a 100755 --- a/mygitflow +++ b/mygitflow @@ -1,9 +1,14 @@ #!/bin/env bash +git_parse_branches() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' +} + git_current_branch() { - git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' + export GIT_CURRENT_BRANCH="$(git_parse_branches)" } -export CUR_BRANCH=`git_current_branch`o + +git_current_branch usage(){ echo @@ -15,20 +20,21 @@ usage(){ echo ---- push pour git_03_push_branch.sh echo ---- merge pour git_04_merge_branch.sh echo ---- delete pour git_05_delete_feature_branch.sh - echo ---- delete_all pour git_06_delete_all_feature_branch.sh + echo ---- delete_all pour git_06_delete_all_features_branch.sh } GITCMD=$1 shift case $GITCMD in - ("checkout") git_00_checkout_branch.sh $@;; - ("status") git_00_status.sh $@;; + ("checkout") git_98_checkout_branch.sh $@;; + ("status") git_99_status.sh $@;; ("commit") git_01_quick_commit.sh $@;; ("add") git_02_add_branch.sh $@;; ("push") git_03_push_branch.sh $@;; ("merge") git_04_merge_branch.sh $@;; ("delete") git_05_delete_feature_branch.sh $@;; - ("delete_all") git_06_delete_all_feature_branch.sh $@;; + ("delete_all") git_06_delete_all_features_branch.sh $@;; + ("rename") git_07_rename_branch.sh $@;; (*) echo && echo "$GITCMD is not a GITCMD !" && usage;; esac