AndrewRayCode / AndrewRayCode/Bash-Prompt-Builder

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

Aberta
#40 1 comentário 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
JavaScript
Estrelas
32
Forks
6
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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)!
```

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.