With the current version of the command completion script, after running "edkrepo checkout" the branch combination listed in the shell prompt is not updated to reflect the new branch combination. The reason for this is because the branch combination isn't checked for changes unless the present working directory was changed by the previous command.
To fix this bug, the scripts have been updated to check for changes to the branch combination when the last command run by the user was "edkrepo" OR the present working directory was changed by the previous command. Signed-off-by: Nate DeSimone <nathaniel.l.desim...@intel.com> Cc: Ashley DeSimone <ashley.e.desim...@intel.com> Cc: Puja Pandya <puja.pan...@intel.com> Cc: Erik Bjorge <erik.c.bjo...@intel.com> Cc: Prince Agyeman <prince.agye...@intel.com> Cc: Bret Barkelew <bret.barke...@microsoft.com> Cc: Philippe Mathieu-Daude <phi...@redhat.com> --- .../Vendor/win_edkrepo_prompt.sh | 17 ++++++++- edkrepo_installer/linux-scripts/install.py | 38 +++++++++++++++++-- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/edkrepo_installer/Vendor/win_edkrepo_prompt.sh b/edkrepo_installer/Vendor/win_edkrepo_prompt.sh index 5404175..91496a7 100644 --- a/edkrepo_installer/Vendor/win_edkrepo_prompt.sh +++ b/edkrepo_installer/Vendor/win_edkrepo_prompt.sh @@ -39,7 +39,16 @@ if [ -x "$(command -v edkrepo)" ] && [ -x "$(command -v $command_completion_edkr # manifest XML, which is a relatively expensive operation to do every time # the user presses <Enter>. # As a performance optimization, only do this if the present working directory - # changed + # changed or if the last command executed was edkrepo + do_combo_check="0" + edkrepo_check_last_command() { + if [[ "$BASH_COMMAND" == *"edkrepo"* ]] && [[ "$BASH_COMMAND" != *"_edkrepo"* ]]; then + if [[ "$BASH_COMMAND" != *"edkrepo_"* ]]; then + do_combo_check="1" + fi + fi + } + trap 'edkrepo_check_last_command' DEBUG if [[ ! -z ${PROMPT_COMMAND+x} ]] && [[ "$PROMPT_COMMAND" != "edkrepo_combo_chpwd" ]]; then old_prompt_command=$PROMPT_COMMAND fi @@ -48,6 +57,10 @@ if [ -x "$(command -v edkrepo)" ] && [ -x "$(command -v $command_completion_edkr if [[ "$(pwd)" != "$old_pwd" ]]; then old_pwd=$(pwd) current_edkrepo_combo=$(command_completion_edkrepo current-combo) + do_combo_check="0" + elif [ "$do_combo_check" == "1" ]; then + current_edkrepo_combo=$(command_completion_edkrepo current-combo) + do_combo_check="0" fi if [[ ! -z ${PROMPT_COMMAND+x} ]]; then eval $old_prompt_command @@ -57,4 +70,4 @@ if [ -x "$(command -v edkrepo)" ] && [ -x "$(command -v $command_completion_edkr fi PS1="$newps1$prompt_suffix" -MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc +MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.bashrc diff --git a/edkrepo_installer/linux-scripts/install.py b/edkrepo_installer/linux-scripts/install.py index 099954d..f9f324a 100755 --- a/edkrepo_installer/linux-scripts/install.py +++ b/edkrepo_installer/linux-scripts/install.py @@ -296,7 +296,16 @@ if [ -x "$(command -v edkrepo)" ] && [ -x "$(command -v command_completion_edkre # manifest XML, which is a relatively expensive operation to do every time # the user presses <Enter>. # As a performance optimization, only do this if the present working directory - # changed + # changed or if the last command executed was edkrepo + do_combo_check="0" + edkrepo_check_last_command() { + if [[ "$BASH_COMMAND" == *"edkrepo"* ]] && [[ "$BASH_COMMAND" != *"_edkrepo"* ]]; then + if [[ "$BASH_COMMAND" != *"edkrepo_"* ]]; then + do_combo_check="1" + fi + fi + } + trap 'edkrepo_check_last_command' DEBUG if [[ ! -z ${PROMPT_COMMAND+x} ]] && [[ "$PROMPT_COMMAND" != "edkrepo_combo_chpwd" ]]; then old_prompt_command=$PROMPT_COMMAND fi @@ -305,6 +314,10 @@ if [ -x "$(command -v edkrepo)" ] && [ -x "$(command -v command_completion_edkre if [[ "$(pwd)" != "$old_pwd" ]]; then old_pwd=$(pwd) current_edkrepo_combo=$(command_completion_edkrepo current-combo) + do_combo_check="0" + elif [ "$do_combo_check" == "1" ]; then + current_edkrepo_combo=$(command_completion_edkrepo current-combo) + do_combo_check="0" fi if [[ ! -z ${PROMPT_COMMAND+x} ]]; then eval $old_prompt_command @@ -346,16 +359,34 @@ if [ -x "$(command -v edkrepo)" ] && [ -x "$(command -v command_completion_edkre # manifest XML, which is a relatively expensive operation to do every time # the user presses <Enter>. # As a performance optimization, only do this if the present working directory - # changed + # changed or if the last command executed was edkrepo + do_combo_check="0" function edkrepo_combo_chpwd() { current_edkrepo_combo=$(command_completion_edkrepo current-combo) + do_combo_check="0" } chpwd_functions=(${chpwd_functions[@]} "edkrepo_combo_chpwd") + function edkrepo_combo_preexec() { + if [[ "$1" = *"edkrepo"* ]] && [[ "$1" != *"_edkrepo"* ]]; then + if [[ "$1" != *"edkrepo_"* ]]; then + do_combo_check="1" + fi + fi + } + preexec_functions=(${preexec_functions[@]} "edkrepo_combo_preexec") + function edkrepo_combo_precmd() { + if [ "$do_combo_check" = "1" ]; then + current_edkrepo_combo=$(command_completion_edkrepo current-combo) + do_combo_check="0" + fi + } + precmd_functions=(${precmd_functions[@]} "edkrepo_combo_precmd") fi # Load version control information autoload -Uz vcs_info -precmd() { vcs_info } +git_precmd() { vcs_info } +precmd_functions=(${precmd_functions[@]} "git_precmd") # Format the vcs_info_msg_0_ variable zstyle ':vcs_info:git:*' formats " %{$fg[cyan]%}(%b)%{$reset_color%}" @@ -363,6 +394,7 @@ zstyle ':vcs_info:git:*' formats " %{$fg[cyan]%}(%b)%{$reset_color%}" # Set up the prompt (with git branch name) setopt PROMPT_SUBST eval "PROMPT='$new_prompt\${vcs_info_msg_0_}\$prompt_suffix'" + ''' def add_command_to_startup_script(script_file, regex, command, username): -- 2.26.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#57263): https://edk2.groups.io/g/devel/message/57263 Mute This Topic: https://groups.io/mt/72956799/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-