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
|
# File 'lib/agile_check_in.rb', line 6
def self.incremental options={}
pair_names = ""
story_number = ""
if Git.has_local_changes?
history_file = '/tmp/agile_check_in_history.yml'
if File.exists?(history_file)
shove_history = YAML::load(File.open(history_file))["shove"]
pair_names = shove_history["pair"]
story_number = shove_history["story"]
end
begin
$stdout.write "Pair names (separated with '/') [#{pair_names}]: "
input = $stdin.gets.strip
pair_names = input unless input.empty?
end until !pair_names.empty?
begin
$stdout.write "Story number (NA) [#{story_number}]: "
input = $stdin.gets.strip
story_number = input unless input.empty?
end until !story_number.empty?
File.open(history_file, 'w') do |out|
YAML.dump({ "shove" => { "pair" => pair_names, "story" => story_number } }, out)
end
if story_number.delete("/").downcase == "na"
commit_message = ""
else
commit_message = "[##{story_number}] "
end
author = "#{pair_names} <agile_check_in@#{`hostname`}>"
system("git add -A") if options[:add]
system("EDITOR=vim git commit --author='#{author}' -e -m '#{commit_message}'")
else
puts "No local changes to commit."
end
end
|