AndrewRayCode / AndrewRayCode/Bash-Prompt-Builder

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

オープン
#40 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
32
フォーク
6
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。