Fix extra spaces in git cl completion

The commands come from the output of git cl -h, which then goes through
an sed filter, matching on the ANSI escape sequence for green and reset.
This ends up having extra spaces, since the output aligns the
subcommands based on the longest subcommand. For shorter commands like
archive, it becomes "archive   ". So, tweak the sed regex to only
capture the part without the whitespaces.

Change-Id: I80a84f142520478547895f85def68331575fdd72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2209582
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
changes/82/2209582/3
Ng Zhi An 5 years ago committed by LUCI CQ
parent 620c56e90e
commit 4cfa04ff98

@ -19,7 +19,7 @@
# Parses commands from git cl -h.
__git_cl_commands () {
git cl -h 2> /dev/null | sed -n 's/^\s*\x1b\[32m\(.*\)\x1b\[39m.*$/\1/p'
git cl -h 2> /dev/null | sed -n 's/^\s*\x1b\[32m\(\S\+\)\s*\x1b\[39m.*$/\1/p'
}
# Caches variables in __git_cl_all_commands.

Loading…
Cancel
Save