scm-prompt: fix _dotfiles_scm_info

Summary: I was using """_dotfiles_scm_info '[%s] '""" in my prompt, which broke after the refactoring.  Add a unit test and fix the code.

Test Plan: wrote a test for the breakage, edited code until they all passed

Reviewers: rmcelroy, tja

Reviewed By: rmcelroy

Subscribers: mjpieters, #pe_security

Differential Revision: https://phabricator.intern.facebook.com/D4945132

Signature: t1:4945132:1493136425:4516151982d173584cf874985de9de1fed0962d5
This commit is contained in:
Greg Prosser 2017-04-25 10:56:35 -07:00
parent 63370254c8
commit 094b505444
2 changed files with 13 additions and 1 deletions

View File

@ -208,10 +208,13 @@ _scm_prompt()
_dotfiles_scm_info() {
local fmt
fmt=$1
if [[ -z "$fmt" ]]; then
if [[ -n "$WANT_OLD_SCM_PROMPT" ]]; then
fmt="%s"
else
fmt=' (%s)'
fi
fi
_scm_prompt $fmt
_scm_prompt "$fmt"
}

View File

@ -26,3 +26,12 @@ Test old mode
5cad84d (no-eol)
$ cmd hg book active
active (no-eol)
Test format string
$ oldcmd() {
> "$@"
> _dotfiles_scm_info "g g %s g g\n"
> }
$ hg init repo
$ oldcmd cd repo
g g empty g g