Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions bin/git-pair
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions lib/git-pair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`
Expand All @@ -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?
Expand Down