From 7aaaf9d8dbfd3c8dc7045de434f8f79206922164 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Tue, 26 Apr 2016 15:53:52 +0800 Subject: fix setup-analytics (#154) DO not invoke git config because HOMEBREW_NO_ANALYTICS, otherwise it will disable analytics for everyone when running `brew update` in following manners: * `brew update` will set HOMEBREW_NO_ANALYTICS because the absence of `homebrew.analyticsmessage` * `brew update-report` will set `homebrew.analyticsdisabled` because of HOMEBREW_NO_ANALYTICS. Also reduce file IO.--- Library/Homebrew/utils/analytics.sh | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'Library/Homebrew') diff --git a/Library/Homebrew/utils/analytics.sh b/Library/Homebrew/utils/analytics.sh index e851fec92..70e698f7c 100644 --- a/Library/Homebrew/utils/analytics.sh +++ b/Library/Homebrew/utils/analytics.sh @@ -3,20 +3,11 @@ setup-analytics() { # recreated with no adverse effect (beyond our user counts being inflated). HOMEBREW_ANALYTICS_USER_UUID_FILE="$HOME/.homebrew_analytics_user_uuid" - if [[ -n "$HOMEBREW_NO_ANALYTICS" ]] - then - rm -f "$HOMEBREW_ANALYTICS_USER_UUID_FILE" - git config --file="$HOMEBREW_REPOSITORY/.git/config" --replace-all homebrew.analyticsdisabled true - fi - - if [[ "$(git config --file="$HOMEBREW_REPOSITORY/.git/config" --get homebrew.analyticsmessage)" != "true" ]] - then - export HOMEBREW_NO_ANALYTICS="1" - return - fi - - if [[ "$(git config --file="$HOMEBREW_REPOSITORY/.git/config" --get homebrew.analyticsdisabled)" = "true" ]] + if [[ -n "$HOMEBREW_NO_ANALYTICS" || + "$(git config --file="$HOMEBREW_REPOSITORY/.git/config" --get homebrew.analyticsmessage)" != "true" || + "$(git config --file="$HOMEBREW_REPOSITORY/.git/config" --get homebrew.analyticsdisabled)" = "true" ]] then + [[ -f "$HOMEBREW_ANALYTICS_USER_UUID_FILE" ]] && rm -f "$HOMEBREW_ANALYTICS_USER_UUID_FILE" export HOMEBREW_NO_ANALYTICS="1" return fi -- cgit v1.2.3