AndrewRayCode / AndrewRayCode/Bash-Prompt-Builder

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

Đang mở
#40 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
32
Fork
6
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.