last_hit 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/last_hit/configure.rb +1 -1
- data/lib/last_hit/rc_adapter/git_adapter.rb +21 -0
- data/lib/last_hit/test_handler.rb +2 -1
- data/lib/last_hit/version.rb +1 -1
- data/lib/last_hit.rb +11 -0
- data/lib/tasks/last_hit.rake +8 -2
- metadata +3 -3
data/lib/last_hit/configure.rb
CHANGED
@@ -5,6 +5,27 @@ module LastHit
|
|
5
5
|
def get_modified_files
|
6
6
|
`git status -z`.split("\x0").map { |line| line.split(" ").last }
|
7
7
|
end
|
8
|
+
|
9
|
+
def get_current_branch_files(another_branch)
|
10
|
+
current_sha = current_commit_sha
|
11
|
+
ancestor_sha = common_ancestor(current_branch, another_branch)
|
12
|
+
|
13
|
+
`git diff --name-only #{current_sha} #{ancestor_sha} -z`.split("\x0")
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def current_branch
|
19
|
+
`git rev-parse --abbrev-ref HEAD`
|
20
|
+
end
|
21
|
+
|
22
|
+
def current_commit_sha
|
23
|
+
`git rev-parse --verify HEAD`
|
24
|
+
end
|
25
|
+
|
26
|
+
def common_ancestor(branch_1, branch_2)
|
27
|
+
`git merge-base #{branch_1} #{branch_2}`
|
28
|
+
end
|
8
29
|
end
|
9
30
|
end
|
10
31
|
end
|
data/lib/last_hit/version.rb
CHANGED
data/lib/last_hit.rb
CHANGED
@@ -11,6 +11,17 @@ module LastHit
|
|
11
11
|
class << self
|
12
12
|
def run_modified_tests
|
13
13
|
files = RcAdapter::GitAdapter.get_modified_files
|
14
|
+
process(files)
|
15
|
+
end
|
16
|
+
|
17
|
+
def run_current_branch_tests(another_branch)
|
18
|
+
files = RcAdapter::GitAdapter.get_current_branch_files(another_branch)
|
19
|
+
process(files)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def process(files)
|
14
25
|
tests = FileFilter::SpecFilter.get_files(files)
|
15
26
|
TestHandler.run(tests)
|
16
27
|
end
|
data/lib/tasks/last_hit.rake
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
namespace :last_hit do
|
2
|
-
desc "Run current modified tests"
|
3
|
-
task :
|
2
|
+
desc "Run current modified tests before commiting"
|
3
|
+
task :current_modified => :environment do
|
4
4
|
LastHit.run_modified_tests
|
5
5
|
end
|
6
|
+
|
7
|
+
desc "Run all changed tests of a branch from its fork with another branch"
|
8
|
+
task :current_branch, [:another_branch] => :environment do |task, args|
|
9
|
+
args.with_defaults(another_branch: LastHit::Configure.default_base_branch)
|
10
|
+
LastHit.run_current_branch_tests(args.another_branch)
|
11
|
+
end
|
6
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: last_hit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
segments:
|
114
114
|
- 0
|
115
|
-
hash:
|
115
|
+
hash: 2685193332422107205
|
116
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
segments:
|
123
123
|
- 0
|
124
|
-
hash:
|
124
|
+
hash: 2685193332422107205
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
127
|
rubygems_version: 1.8.23.2
|