From e7429406b12409a46410e47bd470d6063c6c887a Mon Sep 17 00:00:00 2001 From: Guillaume PROUX Date: Mon, 16 Nov 2015 16:05:07 +0100 Subject: [PATCH 1/7] [twgit] Init feature 'feature-DemoMerge'. From 972e903d41c3d015ce2001894ccf67d806c0ec64 Mon Sep 17 00:00:00 2001 From: Guillaume PROUX Date: Mon, 16 Nov 2015 16:10:15 +0100 Subject: [PATCH 2/7] ajout de la fonction merge-demo --- inc/twgit_release.inc.sh | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/inc/twgit_release.inc.sh b/inc/twgit_release.inc.sh index 2e824ce..017d9b8 100644 --- a/inc/twgit_release.inc.sh +++ b/inc/twgit_release.inc.sh @@ -44,6 +44,8 @@ function usage () { CUI_displayMsg help_detail " Merge current release branch into '$TWGIT_STABLE', create a new tag and push." CUI_displayMsg help_detail ' If no is specified then current release name will be used.' CUI_displayMsg help_detail ' Add -I to run in non-interactive mode (always say yes).'; echo + CUI_displayMsg help_detail 'merge-demo ' + CUI_displayMsg help_detail ' Try to merge specified demo into specified release.'; echo CUI_displayMsg help_detail 'list [-F]' CUI_displayMsg help_detail ' List remote release with their merged features.' CUI_displayMsg help_detail ' Add -F to do not make fetch.'; echo @@ -289,6 +291,57 @@ function cmd_finish () { echo } + +## +# Try to merge a specified demo and his features into release +# +# @param string $1 nom de la demo +# +function cmd_merge-demo () { + + process_options "$@" + require_parameter 'demo' + clean_prefixes "$RETVAL" 'demo' + local demo="$RETVAL" + local demo_fullname="$TWGIT_PREFIX_DEMO$demo" + + # Tests préliminaires : + assert_clean_working_tree + process_fetch + + # Récupération de la release en cours : + CUI_displayMsg processing 'Check remote release...'gh + local release_fullname="$(get_current_release_in_progress)" + [ -z "$release_fullname" ] && die 'No release in progress!' + local release="${release_fullname:${#TWGIT_PREFIX_RELEASE}}" + CUI_displayMsg processing "Remote release '$release_fullname' detected." + + # Merge de la demo dans la release + exec_git_command "git merge --no-ff $demo_fullname" "Could not merge '$demo_fullname' into '$release_fullname'!" + + #Recuperation de la liste des features + local demo_features=$(twgit demo list $demo -c -f | grep $TWGIT_PREFIX_FEATURE | cut -d "-" -f3 | cut -d " " -f1) + + CUI_displayMsg processing $demo_features + + #Suppression demo avant merge features + remove_demo "$demo" + + # merge des features associées : + for feature in $demo_features; do + CUI_displayMsg processing "Merge '$feature'" + + + merge_feature_into_branch "$feature" "$release_fullname" + + + done + + + + +} + ## # Supprime la release spécifiée. # From 7390a210b410c4eb3fef40544455aed592ccf1c0 Mon Sep 17 00:00:00 2001 From: Guillaume PROUX Date: Wed, 18 Nov 2015 17:24:55 +0100 Subject: [PATCH 3/7] Maj completion et correction sur recuperation liste feature --- inc/twgit_release.inc.sh | 12 ++---------- install/bash_completion.sh | 2 +- install/completion/zsh/_twgit | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/inc/twgit_release.inc.sh b/inc/twgit_release.inc.sh index 017d9b8..0e7dd97 100644 --- a/inc/twgit_release.inc.sh +++ b/inc/twgit_release.inc.sh @@ -291,7 +291,6 @@ function cmd_finish () { echo } - ## # Try to merge a specified demo and his features into release # @@ -310,7 +309,7 @@ function cmd_merge-demo () { process_fetch # Récupération de la release en cours : - CUI_displayMsg processing 'Check remote release...'gh + CUI_displayMsg processing 'Check remote release...' local release_fullname="$(get_current_release_in_progress)" [ -z "$release_fullname" ] && die 'No release in progress!' local release="${release_fullname:${#TWGIT_PREFIX_RELEASE}}" @@ -320,7 +319,7 @@ function cmd_merge-demo () { exec_git_command "git merge --no-ff $demo_fullname" "Could not merge '$demo_fullname' into '$release_fullname'!" #Recuperation de la liste des features - local demo_features=$(twgit demo list $demo -c -f | grep $TWGIT_PREFIX_FEATURE | cut -d "-" -f3 | cut -d " " -f1) + local demo_features=$(twgit demo list $demo -c -f | grep $TWGIT_PREFIX_FEATURE | awk -F$TWGIT_PREFIX_FEATURE '{print $2}' | cut -d " " -f1) CUI_displayMsg processing $demo_features @@ -330,16 +329,9 @@ function cmd_merge-demo () { # merge des features associées : for feature in $demo_features; do CUI_displayMsg processing "Merge '$feature'" - - merge_feature_into_branch "$feature" "$release_fullname" - - done - - - } ## diff --git a/install/bash_completion.sh b/install/bash_completion.sh index 36af276..b9d1de4 100644 --- a/install/bash_completion.sh +++ b/install/bash_completion.sh @@ -54,7 +54,7 @@ function _twgit () { COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) ;; release) - local opts="committers finish help list push remove reset start" + local opts="committers finish merge-demo help list push remove reset start" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) ;; tag) diff --git a/install/completion/zsh/_twgit b/install/completion/zsh/_twgit index 0d82ea8..4bd3d57 100644 --- a/install/completion/zsh/_twgit +++ b/install/completion/zsh/_twgit @@ -25,7 +25,7 @@ _twgit() { ;; (hotfix) compadd "$@" finish help list push remove start ;; - (release) compadd "$@" committers finish help list push remove reset start + (release) compadd "$@" committers finish merge-demo help list push remove reset start ;; (tag) compadd "$@" help list ;; From d3e49a97c405ad13a1d0956d9a42807ffcc54ef9 Mon Sep 17 00:00:00 2001 From: Guillaume PROUX Date: Thu, 19 Nov 2015 09:20:44 +0100 Subject: [PATCH 4/7] Force le positionnement sur la release --- inc/twgit_release.inc.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/twgit_release.inc.sh b/inc/twgit_release.inc.sh index 0e7dd97..a60d15c 100644 --- a/inc/twgit_release.inc.sh +++ b/inc/twgit_release.inc.sh @@ -314,6 +314,7 @@ function cmd_merge-demo () { [ -z "$release_fullname" ] && die 'No release in progress!' local release="${release_fullname:${#TWGIT_PREFIX_RELEASE}}" CUI_displayMsg processing "Remote release '$release_fullname' detected." + twgit release start $release # Merge de la demo dans la release exec_git_command "git merge --no-ff $demo_fullname" "Could not merge '$demo_fullname' into '$release_fullname'!" From 7a726e535c96c6a1a1a67fd6efcde3b369f3a809 Mon Sep 17 00:00:00 2001 From: Guillaume PROUX Date: Mon, 23 Nov 2015 10:50:23 +0100 Subject: [PATCH 5/7] New feature : merge demo dans demo --- inc/twgit_demo.inc.sh | 43 +++++++++++++++++++++++++++++++++++ install/bash_completion.sh | 2 +- install/completion/zsh/_twgit | 2 +- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/inc/twgit_demo.inc.sh b/inc/twgit_demo.inc.sh index dffa6b6..cc6caa6 100644 --- a/inc/twgit_demo.inc.sh +++ b/inc/twgit_demo.inc.sh @@ -38,6 +38,8 @@ function usage () { CUI_displayMsg help_detail ' specified, then focus on this demo. Add -F to do not make fetch.'; echo CUI_displayMsg help_detail 'merge-feature ' CUI_displayMsg help_detail ' Try to merge specified feature into current demo.'; echo + CUI_displayMsg help_detail 'merge-demo ' + CUI_displayMsg help_detail ' Try to merge specified demo into current demo.'; echo CUI_displayMsg help_detail 'push' CUI_displayMsg help_detail " Push current demo to '$TWGIT_ORIGIN' repository." CUI_displayMsg help_detail " It's a shortcut for: \"git push $TWGIT_ORIGIN $TWGIT_PREFIX_DEMO…\""; echo @@ -175,6 +177,47 @@ function cmd_merge-feature () { merge_feature_into_branch "$feature" "$current_branch" } +## +# Try to merge a specified demo and his features into demo +# +# @param string $1 nom de la demo +# +function cmd_merge-demo () { + + process_options "$@" + require_parameter 'demo' + clean_prefixes "$RETVAL" 'demo' + local demo="$RETVAL" + local demo_fullname="$TWGIT_PREFIX_DEMO$demo" + + # Tests préliminaires : + assert_clean_working_tree + process_fetch + + get_all_demos + local all_demos="$RETVAL" + local current_branch=$(get_current_branch) + + if ! has "$TWGIT_ORIGIN/$current_branch" $all_demos; then + die "You must be in a demo!" + fi + + # Merge de la demo dans la demo courante + exec_git_command "git merge $demo_fullname" "Could not merge '$demo_fullname' into '$current_branch'!" + + #Recuperation de la liste des features + local demo_features=$(twgit demo list $demo -c -f | grep $TWGIT_PREFIX_FEATURE | awk -F$TWGIT_PREFIX_FEATURE '{print $2}' | cut -d " " -f1) + + CUI_displayMsg processing $demo_features + + # merge des features associées : + for feature in $demo_features; do + CUI_displayMsg processing "Merge '$feature'" + merge_feature_into_branch "$feature" "$current_branch" + done + +} + ## # Display information about specified demo: long name if a connector is # set, last commit, status between local and remote demo and execute diff --git a/install/bash_completion.sh b/install/bash_completion.sh index b9d1de4..1ecf7dc 100644 --- a/install/bash_completion.sh +++ b/install/bash_completion.sh @@ -46,7 +46,7 @@ function _twgit () { COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) ;; demo) - local opts="help list merge-feature push remove start status" + local opts="help list merge-feature merge-demo push remove start status" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) ;; hotfix) diff --git a/install/completion/zsh/_twgit b/install/completion/zsh/_twgit index 4bd3d57..8ef2e6d 100644 --- a/install/completion/zsh/_twgit +++ b/install/completion/zsh/_twgit @@ -21,7 +21,7 @@ _twgit() { (feature) compadd "$@" committers help list merge-into-release merge-into-hotfix migrate push remove start status what-changed ;; - (demo) compadd "$@" help list merge-feature push remove start status + (demo) compadd "$@" help list merge-feature merge-demo push remove start status ;; (hotfix) compadd "$@" finish help list push remove start ;; From c34503dbbc0495337d4ee6246500c1c3ff57b116 Mon Sep 17 00:00:00 2001 From: Guillaume PROUX Date: Mon, 30 Nov 2015 13:28:44 +0100 Subject: [PATCH 6/7] Message de confirmation avant merge et remove de la demo. --- inc/twgit_release.inc.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/inc/twgit_release.inc.sh b/inc/twgit_release.inc.sh index a60d15c..b309eea 100644 --- a/inc/twgit_release.inc.sh +++ b/inc/twgit_release.inc.sh @@ -316,6 +316,9 @@ function cmd_merge-demo () { CUI_displayMsg processing "Remote release '$release_fullname' detected." twgit release start $release + echo -n $(CUI_displayMsg question "$demo_fullname merge to $release_fullname. Do you want to continue? [Y/N] "); read answer + [ "$answer" != "Y" ] && [ "$answer" != "y" ] && die 'Merge demo aborted!' + # Merge de la demo dans la release exec_git_command "git merge --no-ff $demo_fullname" "Could not merge '$demo_fullname' into '$release_fullname'!" From e1c135d360a72a06c34a1fa62f1dad5676c60823 Mon Sep 17 00:00:00 2001 From: Guillaume PROUX Date: Wed, 16 Dec 2015 11:36:17 +0100 Subject: [PATCH 7/7] New feature : demo update-features --- inc/twgit_demo.inc.sh | 51 +++++++++++++++++++++++++++++++++++ install/bash_completion.sh | 2 +- install/completion/zsh/_twgit | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/inc/twgit_demo.inc.sh b/inc/twgit_demo.inc.sh index cc6caa6..7a4c167 100644 --- a/inc/twgit_demo.inc.sh +++ b/inc/twgit_demo.inc.sh @@ -38,6 +38,8 @@ function usage () { CUI_displayMsg help_detail ' specified, then focus on this demo. Add -F to do not make fetch.'; echo CUI_displayMsg help_detail 'merge-feature ' CUI_displayMsg help_detail ' Try to merge specified feature into current demo.'; echo + CUI_displayMsg help_detail 'update-features' + CUI_displayMsg help_detail ' Try to update features into current demo.'; echo CUI_displayMsg help_detail 'merge-demo ' CUI_displayMsg help_detail ' Try to merge specified demo into current demo.'; echo CUI_displayMsg help_detail 'push' @@ -177,6 +179,55 @@ function cmd_merge-feature () { merge_feature_into_branch "$feature" "$current_branch" } +## +# Try to update features into current demo +# +# +function cmd_update-features () { + + # Tests préliminaires : + assert_clean_working_tree + process_fetch + + get_all_demos + local all_demos="$RETVAL" + local current_branch=$(get_current_branch) + + if ! has "$TWGIT_ORIGIN/$current_branch" $all_demos; then + die "You must be in a demo!" + fi + + #Merge dernière release si nécessaire + get_tags_not_merged_into_branch "$current_branch" + local tags_not_merged="$GET_TAGS_NOT_MERGED_INTO_BRANCH_RETURN_VALUE" + local nb_tags_no_merged="$(echo "$tags_not_merged" | wc -w)" + + if [ ! -z "$tags_not_merged" ]; then + local msg='Tag' + if echo "$tags_not_merged" | grep -q ' '; then + msg="${msg}s" + fi + exec_git_command "git merge --no-ff $(get_last_tag)" + msg="${msg} merged into this branch:" + [ "$nb_tags_no_merged" -eq "$TWGIT_MAX_RETRIEVE_TAGS_NOT_MERGED" ] && msg="${msg} at least" + msg="${msg} $(displayInterval "$tags_not_merged")." + CUI_displayMsg warning "$msg" + fi + + #Recuperation de la liste des features + local demo_features=$(twgit demo list $current_branch -c -f | grep $TWGIT_PREFIX_FEATURE | awk -F$TWGIT_PREFIX_FEATURE '{print $2}' | cut -d " " -f1) + + CUI_displayMsg processing $demo_features + + # merge des features associées : + for feature in $demo_features; do + CUI_displayMsg processing "Merge '$feature'" + merge_feature_into_branch "$feature" "$current_branch" + done + +} + + ## # Try to merge a specified demo and his features into demo # diff --git a/install/bash_completion.sh b/install/bash_completion.sh index 1ecf7dc..2ddcf3e 100644 --- a/install/bash_completion.sh +++ b/install/bash_completion.sh @@ -46,7 +46,7 @@ function _twgit () { COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) ;; demo) - local opts="help list merge-feature merge-demo push remove start status" + local opts="help list merge-feature update-features merge-demo push remove start status" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) ;; hotfix) diff --git a/install/completion/zsh/_twgit b/install/completion/zsh/_twgit index 8ef2e6d..e8af811 100644 --- a/install/completion/zsh/_twgit +++ b/install/completion/zsh/_twgit @@ -21,7 +21,7 @@ _twgit() { (feature) compadd "$@" committers help list merge-into-release merge-into-hotfix migrate push remove start status what-changed ;; - (demo) compadd "$@" help list merge-feature merge-demo push remove start status + (demo) compadd "$@" help list merge-feature update-features merge-demo push remove start status ;; (hotfix) compadd "$@" finish help list push remove start ;;