From: "Nate DeSimone" <nathaniel.l.desimone@intel.com>
To: devel@edk2.groups.io
Cc: Ashley DeSimone <ashley.e.desimone@intel.com>,
Puja Pandya <puja.pandya@intel.com>,
Erik Bjorge <erik.c.bjorge@intel.com>,
Prince Agyeman <prince.agyeman@intel.com>,
Bret Barkelew <Bret.Barkelew@microsoft.com>,
Philippe Mathieu-Daude <philmd@redhat.com>
Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Update combo displayed in shell after checkout
Date: Sat, 11 Apr 2020 17:26:30 -0700 [thread overview]
Message-ID: <20200412002630.4790-1-nathaniel.l.desimone@intel.com> (raw)
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.desimone@intel.com>
Cc: Ashley DeSimone <ashley.e.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Philippe Mathieu-Daude <philmd@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
next reply other threads:[~2020-04-12 0:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-12 0:26 Nate DeSimone [this message]
2020-04-13 17:54 ` [edk2-staging/EdkRepo] [PATCH] EdkRepo: Update combo displayed in shell after checkout Ashley E Desimone
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200412002630.4790-1-nathaniel.l.desimone@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox