浏览代码

fix(git-auto-fetch): cancel fetch if we don't have permission over git folder (#10010)

Xuehai Pan 2 年之前
父节点
当前提交
ab8b9913cb
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      plugins/git-auto-fetch/git-auto-fetch.plugin.zsh

+ 3 - 2
plugins/git-auto-fetch/git-auto-fetch.plugin.zsh

@@ -11,8 +11,9 @@ function git-fetch-all {
       return 0
     fi
 
-    # Do nothing if auto-fetch disabled
-    if [[ -z "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]]; then
+    # Do nothing if auto-fetch is disabled or don't have permissions
+    if [[ ! -w "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]] ||
+       [[ -f "$gitdir/FETCH_LOG" && ! -w "$gitdir/FETCH_LOG" ]]; then
       return 0
     fi