浏览代码

Use default branch on recently created Mercurial repository. (#4985)

After `hg init` command, sometimes Mercurial does not create `.hg/branch` file so we'll use 'default' as fallback, which is the master branch in Mercurial repositories.

Signed-off-by: Marc Cornellà <marc.cornella@live.com>
Victor Torres 8 年之前
父节点
当前提交
c195189231
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      plugins/branch/branch.plugin.zsh

+ 6 - 1
plugins/branch/branch.plugin.zsh

@@ -17,7 +17,12 @@ function branch_prompt_info() {
     # Mercurial repository
     if [[ -d "${current_dir}/.hg" ]]
     then
-      echo '☿' $(<"$current_dir/.hg/branch")
+      if [[ -f "$current_dir/.hg/branch" ]]
+      then
+        echo '☿' $(<"$current_dir/.hg/branch")
+      else
+        echo '☿ default'
+      fi
       return;
     fi
     # Defines path as parent directory and keeps looking for :)