From ab8b9913cb6cba35da3126887d4c0b67f033fffa Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Mon, 6 Sep 2021 23:46:56 +0800 Subject: fix(git-auto-fetch): cancel fetch if we don't have permission over git folder (#10010) --- plugins/git-auto-fetch/git-auto-fetch.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins/git-auto-fetch/git-auto-fetch.plugin.zsh') diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh index 0da84f2f5..dbc949621 100644 --- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh +++ b/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 -- cgit v1.2.3-70-g09d2 From af271c9e387f9b536205a7f459802369cb26a7e0 Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Mon, 6 Sep 2021 18:56:39 +0300 Subject: feat(git-auto-fetch): add date to git-auto-fetch log file (#10021) --- plugins/git-auto-fetch/git-auto-fetch.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins/git-auto-fetch/git-auto-fetch.plugin.zsh') diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh index dbc949621..efe8cbe66 100644 --- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh +++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh @@ -25,8 +25,9 @@ function git-fetch-all { fi # Fetch all remotes (avoid ssh passphrase prompt) + date -R &>! "$gitdir/FETCH_LOG" GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \ - command git fetch --all 2>/dev/null &>! "$gitdir/FETCH_LOG" + command git fetch --all 2>/dev/null &>> "$gitdir/FETCH_LOG" ) &| } -- cgit v1.2.3-70-g09d2