From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.4184.1586651199013405411 for ; Sat, 11 Apr 2020 17:26:39 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: nathaniel.l.desimone@intel.com) IronPort-SDR: Bi2dRClhz1wCN5o2LNV5NwZ5t8Y6VTaREjrvcItdsXWWGtLBKt5yIjbHijzscH143TJX60EnN1 eELdI0kI9ZHg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2020 17:26:38 -0700 IronPort-SDR: IZGk6u9GM9mS5VfbkYr20lTI+9PJyEaqt6X8q4TE+PAHDBIUqXmjA1lla4ohnQFBUxcMrgEe/X MxNBENlxlZfQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,372,1580803200"; d="scan'208";a="264461990" Received: from nldesimo-desk1.amr.corp.intel.com ([10.7.159.63]) by orsmga008.jf.intel.com with ESMTP; 11 Apr 2020 17:26:37 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Ashley DeSimone , Puja Pandya , Erik Bjorge , Prince Agyeman , Bret Barkelew , Philippe Mathieu-Daude Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Update combo displayed in shell after checkout Date: Sat, 11 Apr 2020 17:26:30 -0700 Message-Id: <20200412002630.4790-1-nathaniel.l.desimone@intel.com> X-Mailer: git-send-email 2.26.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Ashley DeSimone Cc: Puja Pandya Cc: Erik Bjorge Cc: Prince Agyeman Cc: Bret Barkelew Cc: Philippe Mathieu-Daude --- .../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 . # 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 . # 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 . # 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