From 4f5b5ccd48e801c72ff0026339b8f48203ad64f8 Mon Sep 17 00:00:00 2001 From: equt Date: Thu, 29 Oct 2020 23:13:59 +0800 Subject: [PATCH 1/7] [ feat ] Add XDG_CACHE_HOME check --- bin/git-ignore-io | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/git-ignore-io b/bin/git-ignore-io index cf594f0..30e937f 100755 --- a/bin/git-ignore-io +++ b/bin/git-ignore-io @@ -2,6 +2,10 @@ gitignore_io_url="https://www.gitignore.io/api/" default_path="$HOME/.gi_list" +if [[ ! -z "${XDG_CACHE_HOME}" ]]; then + default_path="$XDG_CACHE_HOME/git-extras/gi_list" + mkdir -p "$XDG_CACHE_HOME/git-extras" +fi update_gi_list() { curl -L -s "${gitignore_io_url}/list" > ~/.gi_list From 19531065caa30404c0cc08b3e809c7586b94c619 Mon Sep 17 00:00:00 2001 From: equt Date: Thu, 29 Oct 2020 23:14:32 +0800 Subject: [PATCH 2/7] [ fix ] Fix hardcode ignore list file path --- bin/git-ignore-io | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/git-ignore-io b/bin/git-ignore-io index 30e937f..a1b9abd 100755 --- a/bin/git-ignore-io +++ b/bin/git-ignore-io @@ -8,7 +8,7 @@ if [[ ! -z "${XDG_CACHE_HOME}" ]]; then fi update_gi_list() { - curl -L -s "${gitignore_io_url}/list" > ~/.gi_list + curl -L -s "${gitignore_io_url}/list" > $default_path } print_in_alphabetical_order() { @@ -77,8 +77,8 @@ show_usage() { echo " [-l|--list-in-table] Print available types in table format" echo " [-L|--list-alphabetically] Print available types in alphabetical order " echo " [-s|--search] Search word in available types" - echo " [-t|--show-update-time] Show the last modified time of ~/.gi_list (where the list of available types is stored)" - echo " [-u|--update-list] Update ~/.gi_list" + echo " [-t|--show-update-time] Show the last modified time of $default_path (where the list of available types is stored)" + echo " [-u|--update-list] Update $default_path" } From 54f8205478a6d792cd248e5f38f8adb77a4d25b4 Mon Sep 17 00:00:00 2001 From: Sinos Date: Mon, 2 Nov 2020 17:24:15 +0800 Subject: [PATCH 3/7] [ refactor ] Optimize var not existing check Co-authored-by: Sandro --- bin/git-ignore-io | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-ignore-io b/bin/git-ignore-io index a1b9abd..07b7582 100755 --- a/bin/git-ignore-io +++ b/bin/git-ignore-io @@ -2,7 +2,7 @@ gitignore_io_url="https://www.gitignore.io/api/" default_path="$HOME/.gi_list" -if [[ ! -z "${XDG_CACHE_HOME}" ]]; then +if [[ -n $XDG_CACHE_HOME ]]; then default_path="$XDG_CACHE_HOME/git-extras/gi_list" mkdir -p "$XDG_CACHE_HOME/git-extras" fi From 8ed7da3f021878470f17a126f8f36ea8f1b4f743 Mon Sep 17 00:00:00 2001 From: equt Date: Mon, 2 Nov 2020 18:10:49 +0800 Subject: [PATCH 4/7] [ feat ] Use default global ignore file --- bin/git-ignore | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/git-ignore b/bin/git-ignore index 723550c..b2957db 100755 --- a/bin/git-ignore +++ b/bin/git-ignore @@ -11,19 +11,23 @@ function show_contents { fi } +function global_ignore() { + git config --global core.excludesfile || echo $XDG_CONFIG_HOME/git/ignore || echo $HOME/.config/git/ignore +} + function show_global { - show_contents Global `git config --global core.excludesfile` + show_contents Global "$(global_ignore)" } function add_global { - local global_gitignore=$(git config --global core.excludesfile) + local global_gitignore="$(global_ignore)" if [ -z "$global_gitignore" ]; then echo "Can't find global .gitignore." echo "" echo "Use 'git config --global --add core.excludesfile ~/.gitignore-global' to set the path to your global gitignore file to '~/.gitignore-global'." echo "" else - add_patterns `git config --global core.excludesfile` "$@" + add_patterns "$global_gitignore" "$@" fi } From fa35cdab99496bd3f887805c702307988b28254e Mon Sep 17 00:00:00 2001 From: equt Date: Mon, 2 Nov 2020 20:22:53 +0800 Subject: [PATCH 5/7] [ fix ] Quote the XDG_CACHE_HOME --- bin/git-ignore-io | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-ignore-io b/bin/git-ignore-io index 07b7582..284801a 100755 --- a/bin/git-ignore-io +++ b/bin/git-ignore-io @@ -2,7 +2,7 @@ gitignore_io_url="https://www.gitignore.io/api/" default_path="$HOME/.gi_list" -if [[ -n $XDG_CACHE_HOME ]]; then +if [[ -n "$XDG_CACHE_HOME" ]]; then default_path="$XDG_CACHE_HOME/git-extras/gi_list" mkdir -p "$XDG_CACHE_HOME/git-extras" fi From ef13ed06a32c5dbd40cf75aed717a349e1a0c280 Mon Sep 17 00:00:00 2001 From: equt Date: Tue, 3 Nov 2020 10:49:42 +0800 Subject: [PATCH 6/7] [ fix ] Quote env var --- bin/git-ignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-ignore b/bin/git-ignore index b2957db..217adda 100755 --- a/bin/git-ignore +++ b/bin/git-ignore @@ -12,7 +12,7 @@ function show_contents { } function global_ignore() { - git config --global core.excludesfile || echo $XDG_CONFIG_HOME/git/ignore || echo $HOME/.config/git/ignore + git config --global core.excludesfile || echo "$XDG_CONFIG_HOME/git/ignore" || echo "$HOME/.config/git/ignore" } function show_global { From fca42774f8ad8a847911c08bb59d13ed9432e3f6 Mon Sep 17 00:00:00 2001 From: equt Date: Tue, 3 Nov 2020 12:04:55 +0800 Subject: [PATCH 7/7] [ feat ] Quote the default_path var --- bin/git-ignore-io | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-ignore-io b/bin/git-ignore-io index 284801a..048ed58 100755 --- a/bin/git-ignore-io +++ b/bin/git-ignore-io @@ -8,7 +8,7 @@ if [[ -n "$XDG_CACHE_HOME" ]]; then fi update_gi_list() { - curl -L -s "${gitignore_io_url}/list" > $default_path + curl -L -s "${gitignore_io_url}/list" > "$default_path" } print_in_alphabetical_order() {