Skip to content

Commit d4eddcd

Browse files
Supporting #last on Git::Log
closes ruby-git#49
1 parent c7f4b26 commit d4eddcd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/git/log.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ def first
8989
check_log
9090
@commits.first rescue nil
9191
end
92+
93+
def last
94+
check_log
95+
@commits.last rescue nil
96+
end
9297

9398
private
9499

tests/units/test_log.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ def setup
99
@git = Git.open(@wdir)
1010
end
1111

12-
def test_get_log_entries
12+
def test_get_fisrt_and_last_entries
1313
log = @git.log
1414
assert(log.first.is_a?(Git::Object::Commit))
15+
assert_equal('5e53019b3238362144c2766f02a2c00d91fcc023', log.first.objectish)
16+
17+
assert(log.last.is_a?(Git::Object::Commit))
18+
assert_equal('f1410f8735f6f73d3599eb9b5cdd2fb70373335c', log.last.objectish)
1519
end
1620

1721
def test_get_log_entries

0 commit comments

Comments
 (0)