Skip to content

Rugged::Commit#diff doesn't seem to return the expected values #651

@cedlemo

Description

@cedlemo

The following script walks over a local clone of https://github.com/ruby-gnome2/ruby-gnome2 and for the commits done at or after the day 2016-11-06, it displays the number of diff.

require "rugged"
require "date"

git_dir = "./ruby-gnome2/"

repo = Rugged::Repository.new(git_dir)
walker = Rugged::Walker.new(repo)
walker.sorting(Rugged::SORT_DATE| Rugged::SORT_REVERSE)
walker.push(repo.head.target)

walker.each do |commit|
  c_time = Time.at(commit.time)
  next unless c_time >= Date.new(2016,11,6).to_time

    puts c_time
    puts commit.diff.size
    puts commit.diff.stat.inspect
end

Here is the output:

ruby rugged_log.rb 
2016-11-06 06:25:04 +0100
2463
[2463, 0, 271333]
2016-11-06 06:26:42 +0100
2463
[2463, 0, 271338]
2016-11-06 09:43:32 +0100
2463
[2463, 0, 271338]
2016-11-06 09:43:59 +0100
2463
[2463, 0, 271338]
2016-11-06 13:30:14 +0100
2463
[2463, 0, 271338]
2016-11-06 14:08:08 +0100
2463
[2463, 0, 271340]

This means that for each commit there are 2463 files modified/deleted. The git command git log --name-status --oneline --after="2016-11-05" shows that it is not true:


965f344 Merge pull request #947 from cedlemo/gtk3_setlocale_C
fa07714 Merge pull request #953 from cedlemo/gstreamer_sample_text_color_example_rb
108bee8 Update copyright date
M       gstreamer/sample/text-color-example.rb
8b5b194 Use the method that returns a clock even if the pipeline is not playing
M       gstreamer/sample/text-color-example.rb
a1f5ee5 gi: return value is return type is void but pointer
M       gobject-introspection/lib/gobject-introspection/callable-info.rb
M       gobject-introspection/lib/gobject-introspection/loader.rb
204c40f gi: do nothing for void type return type
M       gobject-introspection/ext/gobject-introspection/rb-gi-argument.c

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions