AndrewRayCode / AndrewRayCode/Bash-Prompt-Builder

hg branch shows error from cat if .hg/branch does not exist yet

Abierto
#40 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
32
Forks
6
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Steps to repro:
1. Use [these settings](http://andrewray.me/bash-prompt-builder/index.html#git=1&color-git=3&color-git-prefix=3&color-git-ahead=6b&git-modified=1&color-git-modified=3&git-conflicted=1&color-git-conflicted=1&color-git-revno=3&git-bisect=1&color-git-bisect=2&option-submodule=1&color-option-submodule=2&color-git-ontag=3&hg=1&color-hg=5&color-hg-prefix=5&hg-modified=1&color-hg-modified=5&hg-conflicted=1&color-hg-conflicted=1&color-hg-revno=5&hg-bisect=1&color-hg-bisect=2&hg-patches=1&color-hg-patches=2&color-svn=6&color-svn-modified=6&color-svn-revno=6&option-modified=%E2%9C%8E&option-conflict=%E2%98%A2&color-option-conflict=3&max-conflicted-files=2&option-nobranch=no%20branch&color-option-nobranch=1&bisecting-text=%E2%9C%84&submodule-text=submodule%20) and `PS1="\$(${dvcs_function})\[$COLOR_RESET\] \h:\W \u\$ "`
2. $ hg init empty
3. cd empty

Expected:

```
(default) Ed-Brannins-MacBook-Pro:empty ed$
```

Observed:

```
cat: /Users/ed/tmp/empty/.hg/branch: No such file or directory
() Ed-Brannins-MacBook-Pro:empty ed$
```

I tried replacing this line:

```
# If we are in mercurial ...
if [ -n \"\$_hg_dir\" ]; then
hgBranch=\`cat \"\$_hg_dir/.hg/branch\"\`
```

with this one:

```
# If we are in mercurial ...
if [ -n \"\$_hg_dir\" ]; then
hgBranch=`hg branch`
```

...but now I get this upon opening a new shell, which is why this isn't a pull request:

```
abort: no repository found in '/Users/ed' (.hg not found)!
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.