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 start from release #169

Closed
Closed
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
50 changes: 36 additions & 14 deletions inc/common.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -916,13 +916,16 @@ function create_and_push_tag () {
#
# @param string $1 nom court de la nouvelle branche.
# @param string $2 préfixe de branche, par exemple $TWGIT_PREFIX_FEATURE ou $TWGIT_PREFIX_DEMO.
# @param string $3 nom complet de la branche source à partir de laquelle créer la branche (optionnel).
# @param string $3 type de la branche source à partir de laquelle créer la branche (optionnel).
# @param string $4 nom court de la branche source (requis pour une branche source de type 'feature' ou 'demo').
#
function start_simple_branch () {
local branch="$1"
local branch_prefix="$2"
local source_branch_fullname="$3"
local source_branch_type="$3"
local source_branch_name="$4"
local branch_fullname="$branch_prefix$branch"
local source_branch_fullname=''

local -A wording=(
[$TWGIT_PREFIX_FEATURE]='feature'
Expand All @@ -934,6 +937,16 @@ function start_simple_branch () {
assert_clean_working_tree
process_fetch

if [ ! -z "$source_branch_type" ]; then
if [ "$source_branch_type" = 'release' ]; then
source_branch_fullname=$(get_current_release_in_progress)
[ -z "$source_branch_fullname" ] && die 'No release in progress!'
else
source_branch_fullname="$(prefix_of $source_branch_type)$source_branch_name"
assert_remote_branch_exists "$source_branch_fullname"
fi
fi

if isset_option 'd'; then
if has $branch_fullname $(get_local_branches); then
assert_working_tree_is_not_on_delete_branch $branch_fullname
Expand All @@ -953,8 +966,7 @@ function start_simple_branch () {
local last_tag=$(get_last_tag)
exec_git_command "git checkout -b $branch_fullname tags/$last_tag" "Could not check out tag '$last_tag'!"
else
assert_remote_branch_exists "$source_branch_fullname"
exec_git_command "git checkout -b $branch_fullname $TWGIT_ORIGIN/$source_branch_fullname" "Could not check out '$TWGIT_ORIGIN/$source_branch_fullname'!"
exec_git_command "git checkout -b $branch_fullname $TWGIT_ORIGIN/$source_branch_fullname" "Could not check out $source_branch_type '$TWGIT_ORIGIN/$source_branch_fullname'!"
fi

local subject="$(getFeatureSubject "$branch")"
Expand Down Expand Up @@ -1228,7 +1240,6 @@ function alert_old_branch () {
msg="${msg} not 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")."
[ "$2" = 'with-help' ] && msg="${msg} If need be: git merge --no-ff $(get_last_tag) && twgit feature push"
[ "$2" = 'with-help' ] && msg="${msg} If need be: git merge --no-ff $(get_last_tag) && git push $TWGIT_ORIGIN $branch"
CUI_displayMsg warning "$msg"
fi
Expand Down Expand Up @@ -1293,7 +1304,7 @@ function displayQuotedEnum () {
if [ -z "$trimmed_list" ]; then
echo
else
local quoted_list="'<b>${trimmed_list// /</b>', '<b>}</b>'"
local quoted_list="'<b>${trimmed_list// /</b>\', \'<b>}</b>'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand the reason. And these escaped quotes failed unit tests: https://travis-ci.org/Twenga/twgit/builds/205628394#L166

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have counter-commit this line to pass the rest of the pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, maybe this point needs more investigations. In my environment, the tests don't pass because the quotes disappear. For example, a twgit feature list prints:

/!\ Following branches are out of process: 'origin/rm-1, origin/rm-2, origin/rm-3'!

I am on Ubuntu 16.04 with bash version 4.3.46(1)-release (x86_64-pc-linux-gnu).

echo $quoted_list
fi
}
Expand Down Expand Up @@ -1393,7 +1404,8 @@ function convertList2CSV () {
##
# Analyse les prochains paramètres de la ligne de commande pour déduire la branche source demandée par
# l'utilisateur. S'attend à dépiler les paramètres 'from-<source_type> <source_name>'.
# Le résultat est stocké dans la variable $RETVAL.
# Le résultat est stocké dans la variable $RETVAL, et contient le type de la branche source et son
# nom court (s'il s'agit d'une branche source de type 'feature' ou 'demo').
#
# Si le premier paramètre n'est pas de la forme 'from-<source_type>' ou si <source_type> ne fait pas
# parti des types demandés, une erreur est levée.
Expand All @@ -1402,18 +1414,28 @@ function convertList2CSV () {
#
# @param string $1..$n Liste des types possibles de la branche source
#
function parse_source_branch () {
function parse_source_branch_info () {
require_parameter '-'
if [ ! -z "$RETVAL" ]; then
local keyword="$RETVAL"

if [ ! -z "$keyword" ]; then

for type in "$@"; do
if [ "$RETVAL" = "from-$type" ]; then
require_parameter "${type}name"
clean_prefixes "$RETVAL" "$type"
local source_branch="$RETVAL"
RETVAL="$(prefix_of $type)$source_branch"
if [ "$keyword" = "from-$type" ]; then

if [ "$type" = 'release' ]; then
RETVAL="$type"
else
require_parameter "${type}name"
clean_prefixes "$RETVAL" "$type"
local source_branch="$RETVAL"
RETVAL="$type $source_branch"
fi

return
fi
done

CUI_displayMsg error "Unknown action extension: '$RETVAL'!"
usage
exit 1
Expand Down
13 changes: 7 additions & 6 deletions inc/twgit_demo.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function usage () {
CUI_displayMsg help_detail '<b>remove <demoname></b>'
CUI_displayMsg help_detail ' Remove both local and remote specified demo branch. No feature will'
CUI_displayMsg help_detail ' be removed.'; echo
CUI_displayMsg help_detail '<b>start <demoname> [from-demo <demoname>] [-d]</b>'
CUI_displayMsg help_detail '<b>start <demoname> [from-release|from-demo <demoname>] [-d]</b>'
CUI_displayMsg help_detail ' Create both a new local and remote demo, or fetch the remote demo,'
CUI_displayMsg help_detail ' or checkout the local demo. Add <b>-d</b> to delete beforehand local demo'
CUI_displayMsg help_detail ' if exists.'; echo
Expand All @@ -57,7 +57,8 @@ function usage () {
CUI_displayMsg help_detail ' If no <b><demoname></b> is specified, then use 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 "Prefix '$TWGIT_PREFIX_DEMO' will be added to <b><demoname></b> parameter."; echo
CUI_displayMsg help_detail "Prefix '$TWGIT_PREFIX_FEATURE' will be added to <b><featurename></b> parameters."
CUI_displayMsg help_detail "Prefix '$TWGIT_PREFIX_DEMO' will be added to <b><demoname></b> parameters."; echo
CUI_displayMsg help_detail '<b>[help]</b>'
CUI_displayMsg help_detail ' Display this help.'; echo
}
Expand Down Expand Up @@ -134,9 +135,9 @@ function cmd_start () {
require_parameter 'demo'
clean_prefixes "$RETVAL" 'demo'
local demo="$RETVAL"
parse_source_branch 'demo'
local source_branch="$RETVAL"
start_simple_branch "$demo" "$TWGIT_PREFIX_DEMO" "$source_branch"
parse_source_branch_info 'release' 'demo'
local source_branch_info="$RETVAL"
start_simple_branch "$demo" "$TWGIT_PREFIX_DEMO" ${source_branch_info}
echo
}

Expand Down Expand Up @@ -302,7 +303,7 @@ function cmd_status() {
fi

echo
display_branches 'feature' "$TWGIT_ORIGIN/$demo_fullname"
display_branches 'demo' "$TWGIT_ORIGIN/$demo_fullname"
echo
inform_about_branch_status $demo_fullname
if [ "$demo_fullname" = "$current_branch" ]; then
Expand Down
18 changes: 10 additions & 8 deletions inc/twgit_feature.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ function usage () {
CUI_displayMsg help_detail '<b>merge-into-hotfix [<featurename>]</b>'
CUI_displayMsg help_detail ' Try to merge specified feature into current hotfix.'
CUI_displayMsg help_detail ' If no <b><featurename></b> is specified, then ask to use current feature.'; echo
CUI_displayMsg help_detail '<b>migrate <oldfeaturefullname> <newfeaturename></b>'
CUI_displayMsg help_detail ' Migrate old branch to new process.'
CUI_displayMsg help_detail '<b>migrate <oldfeaturefullname> <newfeaturename> [-I]</b>'
CUI_displayMsg help_detail ' Migrate old branch to new process. Add <b>-I</b> to run in non-interactive'
CUI_displayMsg help_detail ' mode (always say yes).'
CUI_displayMsg help_detail ' For example: "twgit feature migrate rm7880 7880"'; echo
CUI_displayMsg help_detail '<b>push</b>'
CUI_displayMsg help_detail " Push current feature to '$TWGIT_ORIGIN' repository."
CUI_displayMsg help_detail " It's a shortcut for: \"git push $TWGIT_ORIGIN ${TWGIT_PREFIX_FEATURE}…\""; echo
CUI_displayMsg help_detail '<b>remove <featurename></b>'
CUI_displayMsg help_detail ' Remove both local and remote specified feature branch.'; echo
CUI_displayMsg help_detail '<b>start <featurename> [from-feature <featurename>|from-demo <demoname>] [-d]</b>'
CUI_displayMsg help_detail '<b>start <featurename> [from-release|from-demo <demoname>|from-feature <featurename>] [-d]</b>'
CUI_displayMsg help_detail ' Create both a new local and remote feature, or fetch the remote feature,'
CUI_displayMsg help_detail ' or checkout the local feature. Add <b>-d</b> to delete beforehand local feature'
CUI_displayMsg help_detail ' if exists.'; echo
Expand All @@ -75,7 +76,8 @@ function usage () {
CUI_displayMsg help_detail ' and deleted files in the specified feature branch since its creation. If'
CUI_displayMsg help_detail ' no <b><featurename></b> is specified, then use current feature.'; echo
CUI_displayMsg help_detail "Prefix '$TWGIT_PREFIX_FEATURE' will be added to <b><featurename></b> and <b><newfeaturename></b>"
CUI_displayMsg help_detail "parameters."; echo
CUI_displayMsg help_detail "parameters.";
CUI_displayMsg help_detail "Prefix '$TWGIT_PREFIX_DEMO' will be added to <b><demoname></b> parameters."; echo
CUI_displayMsg help_detail '<b>[help]</b>'
CUI_displayMsg help_detail ' Display this help.'; echo
}
Expand Down Expand Up @@ -254,9 +256,9 @@ function cmd_start () {
require_parameter 'feature'
clean_prefixes "$RETVAL" 'feature'
local feature="$RETVAL"
parse_source_branch 'feature' 'demo'
local source_branch="$RETVAL"
start_simple_branch "$feature" "$TWGIT_PREFIX_FEATURE" "$source_branch"
parse_source_branch_info 'release' 'demo' 'feature'
local source_branch_info="$RETVAL"
start_simple_branch "$feature" "$TWGIT_PREFIX_FEATURE" ${source_branch_info}
echo
}

Expand Down Expand Up @@ -379,7 +381,7 @@ function cmd_merge-into-hotfix () {
die "You must be in a feature if you didn't specify one!"
else
echo -n $(CUI_displayMsg question "Are you sure to merge '$TWGIT_ORIGIN/$current_branch' into '$TWGIT_ORIGIN/$hotfix_fullname'? [y/N] "); read answer
[ "$answer" != "Y" ] && [ "$answer" != "y" ] && die 'Merge into current release aborted!'
[ "$answer" != "Y" ] && [ "$answer" != "y" ] && die 'Merge into current hotfix aborted!'
fi
feature_fullname="$current_branch"
feature="${feature_fullname:${#TWGIT_PREFIX_FEATURE}}"
Expand Down
2 changes: 1 addition & 1 deletion inc/twgit_release.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function usage () {
CUI_displayMsg help_detail ' the last tag (e.g. v1.2.3):'
CUI_displayMsg help_detail " <b>-M</b> for a new major version (-> ${TWGIT_PREFIX_RELEASE}2.0.0)"
CUI_displayMsg help_detail " <b>-m</b> for a new minor version (default, -> ${TWGIT_PREFIX_RELEASE}1.3.0)"; echo
CUI_displayMsg help_detail "Prefix '$TWGIT_PREFIX_DEMO' will be added to <b><demoname></b> parameter."
CUI_displayMsg help_detail "Prefix '$TWGIT_PREFIX_DEMO' will be added to <b><demoname></b> parameters."
CUI_displayMsg help_detail "Prefix '$TWGIT_PREFIX_RELEASE' will be added to <b><releasename></b> parameters."
CUI_displayMsg help_detail "Prefix '$TWGIT_PREFIX_TAG' will be added to <b><tagname></b> parameters."; echo
CUI_displayMsg help_detail '<b>[help]</b>'
Expand Down
Loading