agile_check_in 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,54 +1,60 @@
1
1
  require "agile_check_in/version"
2
+ require "agile_check_in/git"
2
3
  require "yaml"
3
4
 
4
5
  module AgileCheckIn
5
6
  def self.incremental
6
7
  pair_names = ""
7
8
  story_number = ""
8
-
9
- history_file = '/tmp/agile_check_in_history.yml'
10
- if File.exists?(history_file)
11
- shove_history = YAML::load(File.open(history_file))["shove"]
12
- pair_names = shove_history["pair"]
13
- story_number = shove_history["story"]
14
- end
15
-
16
- begin
17
- $stdout.write "Pair names (separated with '/') [#{pair_names}]: "
18
- input = $stdin.gets.strip
19
- pair_names = input unless input.empty?
20
- end until !pair_names.empty?
21
-
22
- begin
23
- $stdout.write "Story number [#{story_number}]: "
24
- input = $stdin.gets.strip
25
- story_number = input unless input.empty?
26
- end until !story_number.empty?
27
-
28
- File.open(history_file, 'w') do |out|
29
- YAML.dump({ "shove" => { "pair" => pair_names, "story" => story_number } }, out)
9
+
10
+ if Git.has_local_changes?
11
+ history_file = '/tmp/agile_check_in_history.yml'
12
+ if File.exists?(history_file)
13
+ shove_history = YAML::load(File.open(history_file))["shove"]
14
+ pair_names = shove_history["pair"]
15
+ story_number = shove_history["story"]
16
+ end
17
+
18
+ begin
19
+ $stdout.write "Pair names (separated with '/') [#{pair_names}]: "
20
+ input = $stdin.gets.strip
21
+ pair_names = input unless input.empty?
22
+ end until !pair_names.empty?
23
+
24
+ begin
25
+ $stdout.write "Story number [#{story_number}]: "
26
+ input = $stdin.gets.strip
27
+ story_number = input unless input.empty?
28
+ end until !story_number.empty?
29
+
30
+ File.open(history_file, 'w') do |out|
31
+ YAML.dump({ "shove" => { "pair" => pair_names, "story" => story_number } }, out)
32
+ end
33
+
34
+ commit_message = "[#{pair_names} - ##{story_number}] "
35
+
36
+ system("git add -A")
37
+ system("EDITOR=vim git commit -e -m '#{commit_message}'")
38
+ else
39
+ puts "No local changes to commit."
30
40
  end
31
41
 
32
- commit_message = "[#{pair_names} - ##{story_number}] "
33
-
34
- system("git add -A")
35
- system("EDITOR=vim git commit -e -m '#{commit_message}'")
36
42
  end
37
43
 
38
44
  def self.push_and_test
39
45
  puts "*******"
40
46
  puts "About to test these changes:"
41
- puts `git log origin/develop..HEAD`
47
+ puts Git.local_commits
42
48
  puts "*******"
43
49
 
44
50
 
45
51
  if system("rake spec")
46
52
  puts "*******"
47
53
  puts "About to push these changes:"
48
- puts `git log origin/develop..HEAD`
54
+ puts Git.local_commits
49
55
  puts "*******"
50
56
  puts "Shoving..."
51
- system("git push origin develop")
57
+ system("git push")
52
58
  else
53
59
  puts "Tests failed. Shove aborted."
54
60
  exit(1)
@@ -0,0 +1,19 @@
1
+ module AgileCheckIn
2
+ module Git
3
+ def self.current_branch
4
+ `git branch --no-color 2> /dev/null`.split("\n")
5
+ .select{ |branch| branch.match(/\* /) }
6
+ .first
7
+ .split("* ")
8
+ .last
9
+ end
10
+
11
+ def self.local_commits
12
+ `git log origin/#{current_branch}..HEAD`
13
+ end
14
+
15
+ def self.has_local_changes?
16
+ !`git status`.match(/working directory clean/)
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module AgileCheckIn
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agile_check_in
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -31,6 +31,7 @@ files:
31
31
  - bin/ci
32
32
  - bin/cii
33
33
  - lib/agile_check_in.rb
34
+ - lib/agile_check_in/git.rb
34
35
  - lib/agile_check_in/version.rb
35
36
  homepage: ''
36
37
  licenses: []