diff --git a/README.markdown b/README.markdown index df75374..006312c 100644 --- a/README.markdown +++ b/README.markdown @@ -20,6 +20,7 @@ And here's how to use it! -e, --set-email TEMPLATE Set the email template. A value like devs@example.com will be interpolated with the current authors' initials into something like devs+aa+bb@example.com. + -x, --reset Reset to name and email in global config. Switching authors: git pair AA [BB] Where AA and BB are any abbreviation of an diff --git a/bin/git-pair b/bin/git-pair old mode 100644 new mode 100755 index 44e28f2..979be11 --- a/bin/git-pair +++ b/bin/git-pair @@ -14,6 +14,7 @@ begin opts.on("-e", "--set-email TEMPLATE", "Set the email template. A value like devs@example.com", "will be interpolated with the current authors' initials", "into something like devs+aa+bb@example.com.") { |email| GitPair::Commands.set_email_template email } + opts.on("-x", "--reset", "Reset to name and email in global config.") { GitPair::Commands.reset } opts.separator " " opts.separator ["#{$reverse} Switching authors: #{$reset}", @@ -33,6 +34,8 @@ begin elsif unused_options.any? GitPair::Commands.switch(unused_options) puts GitPair::Helpers.display_string_for_current_info + elsif GitPair::Commands.reset? + puts GitPair::Helpers.display_string_for_current_info elsif ARGV.empty? puts parser.help end diff --git a/lib/git-pair.rb b/lib/git-pair.rb index 1c81cd7..55df938 100644 --- a/lib/git-pair.rb +++ b/lib/git-pair.rb @@ -19,6 +19,12 @@ def remove(name) `git config --unset-all git-pair.authors "^#{name}$"` end + def reset + @reset = true + `git config --unset user.name` + `git config --unset user.email` + end + def set_email_template(email) @config_changed = true `git config git-pair.email "#{email}"` @@ -28,6 +34,10 @@ def config_change_made? @config_changed end + def reset? + @reset + end + def switch(abbreviations) raise MissingConfigurationError, "Please add some authors first" if Helpers.author_names.empty? raise MissingConfigurationError, "Please set the email template first" if Helpers.email_template.empty?