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.
This commit is contained in:
Xu Cheng 2016-04-26 15:53:52 +08:00
parent be336159fb
commit 7aaaf9d8db

View File

@ -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