Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature demo merge #159

Merged
merged 7 commits into from
Dec 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions inc/twgit_demo.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ function usage () {
CUI_displayMsg help_detail ' specified, then focus on this demo. Add <b>-F</b> to do not make fetch.'; echo
CUI_displayMsg help_detail '<b>merge-feature <featurename> </b>'
CUI_displayMsg help_detail ' Try to merge specified feature into current demo.'; echo
CUI_displayMsg help_detail '<b>update-features</b>'
CUI_displayMsg help_detail ' Try to update features into current demo.'; echo
CUI_displayMsg help_detail '<b>merge-demo <demoname> </b>'
CUI_displayMsg help_detail ' Try to merge specified demo into current demo.'; echo
CUI_displayMsg help_detail '<b>push</b>'
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
Expand Down Expand Up @@ -175,6 +179,96 @@ 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
#
# @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
Expand Down
49 changes: 49 additions & 0 deletions inc/twgit_release.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b><tagname></b> is specified then current release name will be used.'
CUI_displayMsg help_detail ' Add <b>-I</b> to run in non-interactive mode (always say yes).'; echo
CUI_displayMsg help_detail '<b>merge-demo <demoname> </b>'
CUI_displayMsg help_detail ' Try to merge specified demo into specified release.'; echo
CUI_displayMsg help_detail '<b>list [-F]</b>'
CUI_displayMsg help_detail ' List remote release with their merged features.'
CUI_displayMsg help_detail ' Add <b>-F</b> to do not make fetch.'; echo
Expand Down Expand Up @@ -289,6 +291,53 @@ 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...'
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."
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'!"

#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

#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.
#
Expand Down
4 changes: 2 additions & 2 deletions install/bash_completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ function _twgit () {
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
;;
demo)
local opts="help list merge-feature push remove start status"
local opts="help list merge-feature update-features merge-demo push remove start status"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
;;
hotfix)
local opts="finish help list push remove start"
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)
Expand Down
4 changes: 2 additions & 2 deletions install/completion/zsh/_twgit
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ _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 update-features merge-demo push remove start status
;;
(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
;;
Expand Down