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
|
# File 'lib/ssp/application/pair.rb', line 15
def set_author(pair=nil)
chek_dot_git!
me = %x{git config --global user.name}.chomp
my_email = sspdevs[me]
devs = sspdevs.map {|name,_| name}.sort
devs.delete(me)
if pair.nil?
say "Pairing?", :bold
devs.each_with_index do |name, index|
say_status "#{index + 1}:", name, :cyan
end
say_status "g:", "Gumikacsa", :cyan
print "Enter the index of your pair or leave blank if not pairing: "
while (choice = File.new("/dev/tty").readline.chomp) !~ /\A\d*|[Gg]\Z/
say "Bad input `#{choice}'"
end
elsif pair =~ /^(|x|me|not)$/i
choice = ""
else
pair = pair.downcase
if pair == "g"
choice = "g"
else
pair = devs.detect do |dev|
initial = dev.split(" ").map {|x| x[0..0]}.join.downcase
initial == pair or dev.downcase.split(" ").include?(pair)
end
raise Thor::Error, "No such pair" unless pair
choice = devs.index(pair) + 1
end
end
commit_name, commit_email = if choice == ''
[me, my_email]
else
pair = choice.downcase == "g" ? "Gumikacsa" : devs[choice.to_i - 1]
["#{me} & #{pair}", options[:pair_email].sub('@', initials(me, pair)+'@')]
end
say "Setting #{shell.set_color("commit author", :bold)} to #{shell.set_color(commit_name, :green)}"
%x{git config user.name '#{commit_name}'}
say "Setting #{shell.set_color("commit email", :bold)} to #{shell.set_color(commit_email, :green)}"
%x{git config user.email '#{commit_email}'}
end
|