I am iterating over a git repo, or sub repos recursively and I want to output (along with other details) the revision id of the latest commit (aka most recent) of when a file was modified.
My problem is that the revision id and date stay the same all the time, and I can't find my bug! Can you please help me?
A part of my code:
Dir.glob(Dir.pwd << "/**/*").each do |file|
filename = "#{File.basename file}"
output = `git log -1 -r -n 1 --abbrev=5 --`pretty=format:\"%cd [%h]: #{filename}\"
# Splits the string into different lines.
gitLogArray = output.split("\n")
# Outputs the content of the array.
gitLogArray.each { |singleFile| file }
puts gitLogArray
end
end
As a result, I am getting:
2016-10-12T20:21:47+01:00 [6a2b6]: simple.sh
2016-10-12T20:21:47+01:00 [6a2b6]: writeexit.o
2016-10-12T20:21:47+01:00 [6a2b6]: writeexit.s