-
Notifications
You must be signed in to change notification settings - Fork 17
/
pair
executable file
·94 lines (82 loc) · 2.45 KB
/
pair
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env ruby
# Configures the git author to a list of developers when pair programming
#
# Usage: pair lm bh (Sets the author to 'Luke Melia and Bryan Helmkamp')
# pair (Unsets the author so the git global config takes effect)
#
# Author: Bryan Helmkamp (http://brynary.com)
# http://www.brynary.com/2008/9/1/setting-the-git-commit-author-to-pair-programmers-names
#######################################################################
## Configuration
AUTHORS = {
"ad" => "Alan Dipert",
"ar" => "Alex Redington",
"aw" => "Alex Warr",
"ba" => "Brenton Ashworth",
"bc" => "Bobby Calderwood",
"bv" => "Ben Vandgrift",
"ca" => "Craig Andera",
"cd" => "Clinton Dreisbach",
"cr" => "Chris Redinger",
"dm" => "Daemian Mack",
"gh" => "Gabriel Horner",
"jd" => "Jon Distad",
"jg" => "Justin Gehtland",
"jk" => "Jamie Kite",
"jm" => "Jen Myers",
"jam" => "Jen Myers",
"jp" => "Jared Pace",
"jr" => "Jason Rudolph",
"ka" => "Kevin Altman",
"kn" => "Kevin Neaton",
"ke" => "Kelly Ehret",
"ld" => "Lake Denman",
"lk" => "Larry Karnowski",
"lv" => "Luke VanderHart",
"ma" => "Muness Alrubaie",
"mf" => "Michael Fogus",
"mn" => "Michael Nygard",
"mp" => "Michael Parenteau",
"rn" => "Ryan Neufeld",
"ro" => "Russ Olsen",
"sh" => "Stuart Halloway",
"ss" => "Stuart Sierra",
"su" => "Sam Umbach",
"tb" => "Timothy Baldridge",
"te" => "Tim Ewald",
"yh" => "Yoko Harada",
}
## End of configuration
#######################################################################
def to_sentence(things)
if things.size < 3
things.join(" and ")
else
"#{things.first}, #{to_sentence(things.drop(1))}"
end
end
def git_config_set(name, value)
`git config "#{name}" "#{value}"`
puts "#{name} = \"#{value}\""
end
def git_config_unset(name)
`git config --unset "#{name}"`
puts "Unset #{name}"
end
unless File.exists?(".git")
abort "This doesn't look like a git repository."
end
initials = ARGV.map(&:downcase).map(&:strip).reject(&:empty?).uniq
authors = initials.map do |initial|
AUTHORS[initial] or abort("Couldn't find author name for initials: #{initial}")
end
if authors.any?
pair_email = "pair+#{initials.sort.join('+')}@thinkrelevance.com"
git_config_set('user.name', to_sentence(authors))
git_config_set('user.initials', initials.join('/'))
git_config_set('user.email', pair_email)
else
git_config_unset('user.name')
git_config_unset('user.initials')
git_config_unset('user.email')
end