From f1a5fb5ee99f51f06a18b7b0ffecd8763f8d96d6 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 14 Apr 2022 12:05:02 +0200 Subject: fix(cli): fix `commit.gpgsign` test in `omz pr test` Since `set -e` is enabled, when `commit.gpgsign` is not set the `git config` command would show an error. Given that it is technically not ignored, the subshell would exit. With this change, the `commit.gpgsign` setting is properly tested by doing the fallback test if the command fails, so no exit status code ends up quiting the subshell. --- lib/cli.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/cli.zsh b/lib/cli.zsh index bf783d9f3..56d5b91de 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -578,8 +578,9 @@ function _omz::pr::test { # Back up commit.gpgsign setting: use --local to get the current repository # setting, not the global one. If --local is not a known option, it will # exit with a 129 status code. - gpgsign=$(command git config --local commit.gpgsign 2>/dev/null) - [[ $? -ne 129 ]] || gpgsign=$(command git config commit.gpgsign 2>/dev/null) + if ! gpgsign=$(command git config --local commit.gpgsign 2>/dev/null); then + [[ $? -ne 129 ]] || gpgsign=$(command git config commit.gpgsign 2>/dev/null) + fi command git config commit.gpgsign false command git rebase master ohmyzsh/pull-$1 || { -- cgit v1.2.3-70-g09d2 From 30e23a643ba4f892c42e8d8d8a2ab31a6e68a9a6 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 14 Apr 2022 12:13:53 +0200 Subject: refactor(cli): fix `commit.gpgsign` test in `omz pr test` --- lib/cli.zsh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/cli.zsh b/lib/cli.zsh index 56d5b91de..b71f6d9ce 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -573,14 +573,13 @@ function _omz::pr::test { # Rebase pull request branch against the current master _omz::log info "rebasing PR #$1..." - local gpgsign + local ret gpgsign { # Back up commit.gpgsign setting: use --local to get the current repository # setting, not the global one. If --local is not a known option, it will # exit with a 129 status code. - if ! gpgsign=$(command git config --local commit.gpgsign 2>/dev/null); then - [[ $? -ne 129 ]] || gpgsign=$(command git config commit.gpgsign 2>/dev/null) - fi + gpgsign=$(command git config --local commit.gpgsign 2>/dev/null) || ret=$? + [[ $ret -ne 129 ]] || gpgsign=$(command git config commit.gpgsign 2>/dev/null) command git config commit.gpgsign false command git rebase master ohmyzsh/pull-$1 || { -- cgit v1.2.3-70-g09d2 From 4674384d1a1182484705b3fa4bd7b3267295d9cc Mon Sep 17 00:00:00 2001 From: Will LE Date: Thu, 12 May 2022 16:31:00 +0700 Subject: fix(lib): don't return clean with `hide-dirty=1` in `parse_git_dirty` (#10897) --- lib/git.zsh | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/git.zsh b/lib/git.zsh index be9fa7e67..390c0ad4b 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -34,26 +34,30 @@ function git_prompt_info() { # Checks if working tree is dirty function parse_git_dirty() { + if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" == "1" ]]; then + return 0 + fi + local STATUS local -a FLAGS FLAGS=('--porcelain') - if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then - if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then - FLAGS+='--untracked-files=no' - fi - case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in - git) - # let git decide (this respects per-repo config in .gitmodules) - ;; - *) - # if unset: ignore dirty submodules - # other values are passed to --ignore-submodules - FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" - ;; - esac - STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1) + if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then + FLAGS+='--untracked-files=no' fi - if [[ -n $STATUS ]]; then + + case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in + git) + # let git decide (this respects per-repo config in .gitmodules) + ;; + *) + # if unset: ignore dirty submodules + # other values are passed to --ignore-submodules + FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" + ;; + esac + + STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1) + if [[ -n "$STATUS" ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" else echo "$ZSH_THEME_GIT_PROMPT_CLEAN" -- cgit v1.2.3-70-g09d2 From dfee71c7735b739d6db478b2353752aeb6bc1ae2 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 12 May 2022 18:25:02 +0200 Subject: Revert "fix(lib): don't return clean with `hide-dirty=1` in `parse_git_dirty`" (#10927) --- lib/git.zsh | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'lib') diff --git a/lib/git.zsh b/lib/git.zsh index 390c0ad4b..be9fa7e67 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -34,30 +34,26 @@ function git_prompt_info() { # Checks if working tree is dirty function parse_git_dirty() { - if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" == "1" ]]; then - return 0 - fi - local STATUS local -a FLAGS FLAGS=('--porcelain') - if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then - FLAGS+='--untracked-files=no' + if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then + if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then + FLAGS+='--untracked-files=no' + fi + case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in + git) + # let git decide (this respects per-repo config in .gitmodules) + ;; + *) + # if unset: ignore dirty submodules + # other values are passed to --ignore-submodules + FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" + ;; + esac + STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1) fi - - case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in - git) - # let git decide (this respects per-repo config in .gitmodules) - ;; - *) - # if unset: ignore dirty submodules - # other values are passed to --ignore-submodules - FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" - ;; - esac - - STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1) - if [[ -n "$STATUS" ]]; then + if [[ -n $STATUS ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" else echo "$ZSH_THEME_GIT_PROMPT_CLEAN" -- cgit v1.2.3-70-g09d2 From 39b600e9e564db3dec265fcf2e3db4b5568dd93a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 15 May 2022 13:20:33 +0200 Subject: fix(lib): encode all arguments besides the first in `omz_urlencode` Fixes https://github.com/ohmyzsh/ohmyzsh/commit/140c977a3d82410f48c198596de193d2d6b7b9b5#commitcomment-73688165 --- lib/functions.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/functions.zsh b/lib/functions.zsh index 61f4dd49e..dfcc4d961 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -144,7 +144,7 @@ zmodload zsh/langinfo # Returns nonzero if encoding failed. # # Usage: -# omz_urlencode [-r] [-m] [-P] +# omz_urlencode [-r] [-m] [-P] [ ...] # # -r causes reserved characters (;/?:@&=+$,) to be escaped # @@ -156,7 +156,7 @@ function omz_urlencode() { local -a opts zparseopts -D -E -a opts r m P - local in_str=$1 + local in_str="$@" local url_str="" local spaces_as_plus if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi -- cgit v1.2.3-70-g09d2