Module: AgileCheckIn

Defined in:
lib/agile_check_in.rb,
lib/agile_check_in/git.rb,
lib/agile_check_in/version.rb

Defined Under Namespace

Modules: Git

Constant Summary collapse

VERSION =
"0.0.9"

Class Method Summary collapse

Class Method Details

.incremental(options = {}) ⇒ Object



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

.pre_commit_tasksObject



50
51
52
53
54
55
# File 'lib/agile_check_in.rb', line 50

def self.pre_commit_tasks
  if File::exists? '.agile_check_in.yml'
    file = File.read('.agile_check_in.yml')
    pre_commit_tasks = YAML::load(file)["pre_commit"]
  end
end

.push_and_testObject



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/agile_check_in.rb', line 66

def self.push_and_test
  if pre_commit_tasks
    if system(pre_commit_tasks)
      push_commits
    else
      puts "Tests failed. Shove aborted."
      exit(1)
    end
  else
    push_commits
  end
end

.push_commitsObject



57
58
59
60
61
62
63
64
# File 'lib/agile_check_in.rb', line 57

def self.push_commits
  puts "*******"
  puts "About to push these changes:"
  puts Git.local_commits
  puts "*******"
  puts "Shoving..."
  system("git push")
end