Skip to content

Commit

Permalink
Fix that adding the same name multiple times wasn't idempotent
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisk committed Dec 12, 2009
1 parent becca1f commit 6cfd8c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 0 additions & 4 deletions README.markdown
Expand Up @@ -31,10 +31,6 @@ out their names, the current pair, and some other information.
## Known issues

* I just shoved everything into a gem. Refactor into separate files.
* Don't add duplicate authors to the git-config (doesn't affect the proper
functioning of git-pair, but makes `git pair --add` not idempotent and
clutters up your config file if you keep adding the same person). There's a
failing test for this now.
* Test coverage is low -- I'm working on a cucumber suite.

## Feature hit list
Expand Down
13 changes: 11 additions & 2 deletions lib/git-pair.rb
Expand Up @@ -9,16 +9,25 @@ class MissingConfigurationError < RuntimeError; end


module Commands
def add(name)
def add(new_name)
@config_changed = true
`git config --add git-pair.authors "#{name}"`
names = Helpers.author_names.push(new_name).sort.uniq
remove_all
names.each do |name|
`git config --add git-pair.authors "#{name}"`
end
end

def remove(name)
@config_changed = true
`git config --unset-all git-pair.authors "^#{name}$"`
end

def remove_all
@config_changed = true
`git config --unset-all git-pair.authors`
end

def set_email_template(email)
@config_changed = true
`git config git-pair.email "#{email}"`
Expand Down

0 comments on commit 6cfd8c5

Please sign in to comment.