Module: GitPair::Config
Constant Summary collapse
- DEFAULT_PATTERN =
"devs+%abbr+%abbr@%domain"
Instance Method Summary collapse
- #add_author(author) ⇒ Object
- #all_author_strings ⇒ Object
- #current_author ⇒ Object
- #current_email ⇒ Object
- #default_domain ⇒ Object
- #default_email ⇒ Object
- #get_pattern ⇒ Object
- #pattern ⇒ Object
- #remove_author(name) ⇒ Object
- #remove_pattern ⇒ Object
- #reset ⇒ Object
- #set_pattern(pattern) ⇒ Object
- #switch(authors) ⇒ Object
Instance Method Details
#add_author(author) ⇒ Object
31 32 33 34 35 |
# File 'lib/git-pair/config.rb', line 31 def () unless Author.exists?() `git config --global --add git-pair.authors "#{author.name} <#{author.email}>"` end end |
#all_author_strings ⇒ Object
7 8 9 |
# File 'lib/git-pair/config.rb', line 7 def `git config --get-all git-pair.authors`.split("\n") end |
#current_author ⇒ Object
60 61 62 |
# File 'lib/git-pair/config.rb', line 60 def `git config --get user.name`.strip end |
#current_email ⇒ Object
64 65 66 |
# File 'lib/git-pair/config.rb', line 64 def current_email `git config --get user.email`.strip end |
#default_domain ⇒ Object
56 57 58 |
# File 'lib/git-pair/config.rb', line 56 def default_domain default_email.split('@').last end |
#default_email ⇒ Object
52 53 54 |
# File 'lib/git-pair/config.rb', line 52 def default_email `git config --global --get user.email`.strip end |
#get_pattern ⇒ Object
19 20 21 |
# File 'lib/git-pair/config.rb', line 19 def get_pattern `git config --get git-pair.pattern`.strip end |
#pattern ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/git-pair/config.rb', line 11 def pattern if get_pattern.length > 0 get_pattern else DEFAULT_PATTERN end end |
#remove_author(name) ⇒ Object
37 38 39 40 |
# File 'lib/git-pair/config.rb', line 37 def (name) `git config --global --unset-all git-pair.authors "^#{name} <"` `git config --global --remove-section git-pair` if .empty? end |
#remove_pattern ⇒ Object
27 28 29 |
# File 'lib/git-pair/config.rb', line 27 def remove_pattern `git config --global --unset-all git-pair.pattern` end |
#reset ⇒ Object
48 49 50 |
# File 'lib/git-pair/config.rb', line 48 def reset `git config --remove-section user` end |
#set_pattern(pattern) ⇒ Object
23 24 25 |
# File 'lib/git-pair/config.rb', line 23 def set_pattern(pattern) `git config --global --replace-all git-pair.pattern "#{pattern}"` end |
#switch(authors) ⇒ Object
42 43 44 45 46 |
# File 'lib/git-pair/config.rb', line 42 def switch() .sort! `git config user.name "#{authors.map { |a| a.name }.join(' + ')}"` `git config user.email "#{pair_email(authors)}"` end |