-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#: * `analytics` [`state`]: | ||
#: Display anonymous user behaviour analytics state. | ||
#: Read more at <https://git.io/brew-analytics>. | ||
#: | ||
#: * `analytics` (`on`|`off`): | ||
#: Turn on/off Homebrew's analytics. | ||
#: | ||
#: * `analytics` `regenerate-uuid`: | ||
#: Regenerate UUID used in Homebrew's analytics. | ||
|
||
module Homebrew | ||
def analytics | ||
config_file = HOMEBREW_REPOSITORY/".git/config" | ||
|
||
raise UsageError if ARGV.named.size > 1 | ||
case ARGV.named.first | ||
when nil, "state" | ||
analyticsdisabled = \ | ||
Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsdisabled").chuzzle | ||
uuid = \ | ||
Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsuuid").chuzzle | ||
if ENV["HOMEBREW_NO_ANALYTICS"] | ||
puts "Analytics is disabled (by HOMEBREW_NO_ANALYTICS)." | ||
elsif analyticsdisabled == "true" | ||
puts "Analytics is disabled." | ||
else | ||
puts "Analytics is enabled." | ||
puts "UUID: #{uuid}" if uuid | ||
end | ||
when "on" | ||
safe_system "git", "config", "--file=#{config_file}", | ||
"--replace-all", "homebrew.analyticsdisabled", "false" | ||
safe_system "git", "config", "--file=#{config_file}", | ||
"--replace-all", "homebrew.analyticsmessage", "true" | ||
when "off" | ||
safe_system "git", "config", "--file=#{config_file}", | ||
"--replace-all", "homebrew.analyticsdisabled", "true" | ||
system "git", "config", "--file=#{config_file}", "--unset-all", "homebrew.analyticsuuid" | ||
when "regenerate-uuid" | ||
# it will be regenerated in next run. | ||
system "git", "config", "--file=#{config_file}", "--unset-all", "homebrew.analyticsuuid" | ||
else | ||
raise UsageError | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters