AndrewRayCode / AndrewRayCode/Bash-Prompt-Builder

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

未關閉
#40 1 則留言 0 個 reaction 已指派 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 摘要。